I recently had another "don't know what you don't know" moments - in that I thought I was generally OK with the 65C02 instruction set, however for some weird reason, jmp (abs,x) escaped me and I only noticed it when brushing up on the '816 instruction set...
I recently posted a command-dispatcher that looked like:
Code:
lda cmdI ; Get command index
asl a ; Double to index into jump table
tay
lda commandList,y
sta wooly+1
iny
lda commandList,y
sta wooly+2
jsr wooly ; JSR to the command and hope for an RTS
jmp rubyOsCmd
; The wooly jumper
wooly: jmp $FFFF ; Modified
The immediate optimisation (not that's it's really needed is to remove the iny and replace the subsequent lsa with lda commandList+1,y, however the jmp (abs,x) mechanism is far more compact, less cycles and less code, so why not, and I've now replaced all that with:
Code:
lda cmdI ; Get command index
asl a ; Double to index into jump table
tax
jmp (commandList,x)
Anyway, there you are, in-case it helps anyone else, or jogs their little grey cells...
Cheers,
-Gordon
_________________
--
Gordon Henderson.
See my
Ruby 6502 and 65816 SBC projects here:
https://projects.drogon.net/ruby/