tobiasvl / tobiasvl.github.io

Tobias V. Langhoff's website and blog
https://tobiasvl.github.io
3 stars 1 forks source link

Extending CHIPOS with more CHIP-8 instructions #1

Closed utterances-bot closed 1 month ago

utterances-bot commented 4 years ago

Comments for https://tobiasvl.github.io/blog/chipos-hacking/

peterferrie commented 4 years ago

could you change FILL to: LDX #DISBUF-ENDBUF FILL: STAA ENDBUF,X INX BNE FILL ?

peterferrie commented 4 years ago

can you change FETCH this way: FETCH: LDX PPC ; POINT TO NEXT INSTR LDAB 0,X ; COPY TO PIR STAB PIR ANDB #$0F STAB ZHI JSR SKIP2 ; BUMP PRGM-CTR ?

peterferrie commented 4 years ago

can you move SKIP2 here: SKFEQ: CMPA VX BNE RETMON SKIP2: LDX PPC ; ADD 2 TO PPC INX INX STX PPC RTS ?

peterferrie commented 4 years ago

for RANDOM, why not: LDX #$C0 ; HIGH-ORDER BYTE OF RNDX = STX RNDX ; =MSB OF CHIP8 START ADRS ?

peterferrie commented 4 years ago

it looks like SHOW3 should move down by one line.

tobiasvl commented 4 years ago

@peterferrie Thanks so much for your suggestions! Let me know if I misunderstood any of them.

could you change FILL to:

Huh. Very clever! Thank you! (Did you mean #ENDBUF-DISBUF though?)

can you change FETCH this way:

Sadly, CHIP-8 instructions are two bytes long. So both PIR and ZHI need to point to both of those bytes (PIR+1 and ZLO).

can you move SKIP2 here:

I put it where it is now so SKFNV can fall through to SKIP2 – if I move it up so that SKFEQ falls through to SKIP2 instead, I'll need to branch from SKFNV instead. I could move SKIP2 within that whole segment, but all the routines there need to branch to it except one which can fall through. Right?

for RANDOM, why not:

Not sure I understand that one. Won't that set RNDX to $C000 every time RANDOM is called? That should be the initial seed, but the lower byte should increment between calls.

it looks like SHOW3 should move down by one line.

Good catch!! Definitely burning some unnecessary cycles there.

peterferrie commented 4 years ago

could you change FILL to:

Huh. Very clever! Thank you! (Did you mean #ENDBUF-DISBUF though?)

No, I meant DISBUF-ENDBUF so that X has a negative value and you increment until it reaches zero.

can you change FETCH this way:

Sadly, CHIP-8 instructions are two bytes long. So both PIR and ZHI need to point to both of those bytes (PIR+1 and ZLO).

Yes, I see it now.

can you move SKIP2 here:

I put it where it is now so SKFNV can fall through to SKIP2

SKFNV doesn't fall through to SKIP2 - it's gated by a BRA. That's why I thought that SKIP2 can move.

for RANDOM, why not:

Not sure I understand that one. Won't that set RNDX to $C000 every time RANDOM is called? That should be the initial seed, but the lower byte should increment between calls.

Yes, ignore that. It's my mistake again about X being 16-bit not 8-bit.