zasm emul: add dumpSymbolTable debug routine

Very helpful...
This commit is contained in:
Virgil Dupras 2019-05-17 13:22:45 -04:00
parent c1b09123f1
commit 807bd70b63
3 changed files with 49 additions and 0 deletions

View File

@ -5,6 +5,7 @@
.equ STDIN_SEEK 0x01
.equ FS_DATA_PORT 0x02
.equ FS_SEEK_PORT 0x03
.equ STDERR_PORT 0x04
jp init ; 3 bytes
; *** JUMP TABLE ***
@ -53,6 +54,7 @@ init:
; signal the emulator we're done
halt
; *** I/O ***
emulGetC:
in a, (STDIO_PORT)
or a ; cp 0

View File

@ -16,7 +16,51 @@ fsSeek .equ 0x2a
fsTell .equ 0x2d
.equ FS_HANDLE_SIZE 8
.equ STDERR_PORT 0x04
.equ USER_CODE 0x4800
.equ RAMSTART 0x5800
.org USER_CODE
call zasmMain
;call dumpSymTable
ret
#include "main.asm"
; *** Debug ***
debugPrint:
push af
push hl
.loop:
ld a, (hl)
or a
jr z, .end
out (STDERR_PORT), a
inc hl
jr .loop
.end:
ld a, 0x0a
out (STDERR_PORT), a
pop hl
pop af
ret
dumpSymTable:
ld hl, SYM_NAMES
ld de, SYM_VALUES
.loop:
call debugPrint
ld a, (de)
out (12), a
inc de
ld a, (de)
out (12), a
inc de
xor a
call findchar
inc hl
ld a, (hl)
or a
ret z
jr .loop

View File

@ -31,6 +31,7 @@
#define STDIN_SEEK_PORT 0x01
#define FS_DATA_PORT 0x02
#define FS_SEEK_PORT 0x03
#define STDERR_PORT 0x04
// Other consts
#define STDIN_BUFSIZE 0x8000
@ -128,6 +129,8 @@ static void io_write(int unused, uint16_t addr, uint8_t val)
fsdev_ptr = (val << 8) & 0xff00;
fsdev_middle_of_seek_tell = 1;
}
} else if (addr == STDERR_PORT) {
fputc(val, stderr);
} else {
fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val);
}