1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-02 10:20:55 +11:00

Compare commits

...

2 Commits

Author SHA1 Message Date
Virgil Dupras
400ef99b54 forth: fix dumb bug in (?br)
inc (hl) is 8 bit, inc (hl) is 8 bit, inc (hl) is 8 bit. Now I hope
I'll remember...
2020-03-29 22:17:25 -04:00
Virgil Dupras
d2dcd96ce1 emul: add useful emul_trace() debugging tool 2020-03-29 22:13:54 -04:00
3 changed files with 16 additions and 4 deletions

View File

@ -7,6 +7,7 @@ They all run on the same kind of virtual machine: A z80 CPU, 64K of RAM/ROM.
#include "emul.h"
static Machine m;
static ushort traceval = 0;
static uint8_t io_read(int unused, uint16_t addr)
{
@ -92,6 +93,15 @@ void emul_loop()
while (emul_step());
}
void emul_trace(ushort addr)
{
ushort newval = m.mem[addr+1] << 8 | m.mem[addr];
if (newval != traceval) {
traceval = newval;
fprintf(stderr, "trace: %04x PC: %04x\n", traceval, m.cpu.PC);
}
}
void emul_printdebug()
{
fprintf(stderr, "Min SP: %04x\n", m.minsp);

View File

@ -30,4 +30,5 @@ Machine* emul_init();
bool emul_step();
bool emul_steps(unsigned int steps);
void emul_loop();
void emul_trace(ushort addr);
void emul_printdebug();

View File

@ -683,12 +683,13 @@ CBR:
or l
jp z, BR+2 ; False, branch
; True, skip next 2 bytes and don't branch
ld hl, IP
inc (hl)
inc (hl)
ld hl, (IP)
inc hl
inc hl
ld (IP), hl
jp next
.fill 18
.fill 15
.db ","
.dw $-CBR