Extending CHIPOS with more CHIP-8 instructions
utterances-bot opened this issue · comments
Comments for https://tobiasvl.github.io/blog/chipos-hacking/
could you change FILL to:
LDX #DISBUF-ENDBUF
FILL: STAA ENDBUF,X
INX
BNE FILL
?
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
?
can you move SKIP2 here:
SKFEQ: CMPA VX
BNE RETMON
SKIP2: LDX PPC ; ADD 2 TO PPC
INX
INX
STX PPC
RTS
?
for RANDOM, why not:
LDX #$C0 ; HIGH-ORDER BYTE OF RNDX =
STX RNDX ; =MSB OF CHIP8 START ADRS
?
it looks like SHOW3 should move down by one line.
@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.