3 ms·
Given that the 8086 has SI and DI with a +imm8 mode, like the (IX+imm8) and (IY+imm8) instructions on the Z80. I do wonder if Z80 CP/M machines were the real ta
by VogonPoetry 4y ago
Given that the 8086 has SI and DI with a +imm8 mode, like the (IX+imm8) and (IY+imm8) instructions on the Z80. I do wonder if Z80 CP/M machines were the real target rather than the 8080.
I did write an 8086 assembly based Z80 emulator (in the late 80's) that was surprisingly compact and had acceptable Z80 performance on a 12MhZ AMD 80286. It passed CP/M system calls to Concurrent DOS.
I should see if I still have the code and run an emulator torture test to see how bad it was.
- rep_lodsb 4y agoToo 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".
- VogonPoetry 4y agoI went and found my code, with a side trip into being able to "unzoo" the archive! 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.