Started by erikarn, 06:20, 06 September 10
0 Members and 1 Guest are viewing this topic.
Quote from: erikarn on 06:20, 06 September 10Hi,I'm writing a little Forth-ish stack VM in Z80 assembler for the CPC and I've hit a stupid, trivial snag. I'd like to use a jumptable of calls based on the opcode but I couldn't figure out a nice way of doing it.What I'm currently doing just to get around it (from memory):PUSH IXPUSH BCLD IX, jumptableLD BC, 0LD C, A ; A has the jumpcode op in itADD IX, BCADD IX, BC ; jumptable is two bytes per entryLD C, (IX+0)LD B, (IX+1)LD IX, call_offsetLD (IX+1), CLD (IX+2), BPOP BCPOP IXcall_offset: CALL &0RETNow - this is fine for RAM code but I'd like to eventually put this VM in a ROM, rather than in RAM. I can always just use scratch RAM for that rather than self-modifying in-line code.Does anyone have any suggestions on better (tighter, faster) ways of doing this? Besides the obvious "two 16-bit ADDs? are you crazy?" :-)Thanks!
Page created in 0.142 seconds with 28 queries.