Skip to main content
1 of 3
dav
  • 1.1k
  • 1
  • 11
  • 16

Fixing obscure 8080 emulator bug?

I'm using the cpudiag.bin from http://www.emulator101.com/files/cpudiag.bin to test my emulator. I've already implemented the CP/M CALL function at 0x05, offset the program at 0x100 and fixed the offset at byte 112 + 0x100 as per this site. http://emulator101.com/

I get the error


 CPU HAS FAILED! ERROR EXIT=78=:

and added myself that there was a JMP to 0000 from 0x698. Here are the last 10 instructions run by the emulator before failing:

Instructions Ran: 79
Program Counter: 016C
Memory Immediate: 0xFA
Instruction: JM adr 71 1
Registers (B/C/D/E/H/L/A): 00 02 00 3D 01 DA 0A
Flags (Z/S/P/C/AC): 1 0 1 0 0
Stack Pointer: 7A7
Cycles: 724
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 80
Program Counter: 0171
Memory Immediate: 0xC6
Instruction: ADI D8 30
Registers (B/C/D/E/H/L/A): 00 02 00 3D 01 DA 0A
Flags (Z/S/P/C/AC): 1 0 1 0 0
Stack Pointer: 7A7
Cycles: 734
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 81
Program Counter: 0173
Memory Immediate: 0xC9
Instruction: RET
Registers (B/C/D/E/H/L/A): 00 02 00 3D 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A7
Cycles: 741
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 82
Program Counter: 0160
Memory Immediate: 0x5F
Instruction: MOV E, A
Registers (B/C/D/E/H/L/A): 00 02 00 3D 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A9
Cycles: 751
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 83
Program Counter: 0161
Memory Immediate: 0xC3
Instruction: JMP adr 4E 1
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A9
Cycles: 756
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 84
Program Counter: 014E
Memory Immediate: 0x0E
Instruction: MVI C, D8 2
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A9
Cycles: 766
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 85
Program Counter: 0150
Memory Immediate: 0xCD
Instruction: CALL adr 5 0
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A9
Cycles: 773
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 86
Program Counter: 0005
Memory Immediate: 0xC9
Instruction: RET
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A7
Cycles: 790
Interrupt enabled: false
Interrupt op:
-------------------
:Instructions Ran: 87
Program Counter: 0153
Memory Immediate: 0xC9
Instruction: RET
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7A9
Cycles: 800
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 88
Program Counter: 0698
Memory Immediate: 0xC3
Instruction: JMP adr 0 0
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7AB
Cycles: 810
Interrupt enabled: false
Interrupt op:
-------------------
Instructions Ran: 89
Program Counter: 0000
Memory Immediate: 0x00
Instruction: NOP
Registers (B/C/D/E/H/L/A): 00 02 00 3A 01 DA 3A
Flags (Z/S/P/C/AC): 0 0 1 0 1
Stack Pointer: 7AB
Cycles: 820
Interrupt enabled: false
Interrupt op:
-------------------
JMP to 0000 from 0x698

I'm new to emulating so could anyone give me a hint or point me in the right direction on how to debug this?

dav
  • 1.1k
  • 1
  • 11
  • 16