@@ -5,6 +5,7 @@ | |||||
.equ STDIN_SEEK 0x01 | .equ STDIN_SEEK 0x01 | ||||
.equ FS_DATA_PORT 0x02 | .equ FS_DATA_PORT 0x02 | ||||
.equ FS_SEEK_PORT 0x03 | .equ FS_SEEK_PORT 0x03 | ||||
.equ STDERR_PORT 0x04 | |||||
jp init ; 3 bytes | jp init ; 3 bytes | ||||
; *** JUMP TABLE *** | ; *** JUMP TABLE *** | ||||
@@ -53,6 +54,7 @@ init: | |||||
; signal the emulator we're done | ; signal the emulator we're done | ||||
halt | halt | ||||
; *** I/O *** | |||||
emulGetC: | emulGetC: | ||||
in a, (STDIO_PORT) | in a, (STDIO_PORT) | ||||
or a ; cp 0 | or a ; cp 0 | ||||
@@ -16,7 +16,51 @@ fsSeek .equ 0x2a | |||||
fsTell .equ 0x2d | fsTell .equ 0x2d | ||||
.equ FS_HANDLE_SIZE 8 | .equ FS_HANDLE_SIZE 8 | ||||
.equ STDERR_PORT 0x04 | |||||
.equ USER_CODE 0x4800 | .equ USER_CODE 0x4800 | ||||
.equ RAMSTART 0x5800 | .equ RAMSTART 0x5800 | ||||
.org USER_CODE | .org USER_CODE | ||||
call zasmMain | |||||
;call dumpSymTable | |||||
ret | |||||
#include "main.asm" | #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 | |||||
@@ -31,6 +31,7 @@ | |||||
#define STDIN_SEEK_PORT 0x01 | #define STDIN_SEEK_PORT 0x01 | ||||
#define FS_DATA_PORT 0x02 | #define FS_DATA_PORT 0x02 | ||||
#define FS_SEEK_PORT 0x03 | #define FS_SEEK_PORT 0x03 | ||||
#define STDERR_PORT 0x04 | |||||
// Other consts | // Other consts | ||||
#define STDIN_BUFSIZE 0x8000 | #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_ptr = (val << 8) & 0xff00; | ||||
fsdev_middle_of_seek_tell = 1; | fsdev_middle_of_seek_tell = 1; | ||||
} | } | ||||
} else if (addr == STDERR_PORT) { | |||||
fputc(val, stderr); | |||||
} else { | } else { | ||||
fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val); | fprintf(stderr, "Out of bounds I/O write: %d / %d\n", addr, val); | ||||
} | } | ||||