Too bad that you need SI for the program counter, and DI to emulate some addressing modes that the 8080 could do but x86 can't.
Even if translating code ahead of time, "LD (BC), A" needs to be emulated as something like "MOV DI,CX; MOV [DI],AL".
Even if translating code ahead of time, "LD (BC), A" needs to be emulated as something like "MOV DI,CX; MOV [DI],AL".
Yes, I agree. I also used SI as the PC so I could use "lodsb" (cute HN name BTW) and "lodsw" for 2 byte args.
My register use was
286 Z80
--- ---
BX HL
CX BC
DX DE
DI A
SI PC
When emulating the DD, FD and CB prefixes I pre-loaded BP with either IX+d, IY+d (IX, IY were stored in memory) or BX and jumping to common code.Basic structure was like
OP_00:
XOR AH,AH
LODSB
SHL AX,1
MOV BP,AX
JMP CS:OP_table[BP]
For OP_02 - "LD (BC),A" I used, OP_02:
XCHG CX,DI
MOV [DI], CL
XCHG CX,DI
JMP OP_00
I did see some opportunities for additional code-golf. Also noticed that EX AF,AF' did not properly exchange the flags (so that will need to get fixed!).I was mostly only running m80, l80 and mload.