1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 16:38:05 +11:00

zasm: print progress indicator while assembling

This commit is contained in:
Virgil Dupras 2019-06-19 11:42:39 -04:00
parent 66fbd20e21
commit 7cdc288ef2
8 changed files with 51 additions and 3 deletions

View File

@ -80,6 +80,7 @@ handleDB:
jr z, .stopStrLit ; be our closing quote. Stop. jr z, .stopStrLit ; be our closing quote. Stop.
; Normal character, output ; Normal character, output
call ioPutC call ioPutC
jr nz, .ioError
jr .stringLiteral jr .stringLiteral
handleDW: handleDW:
@ -93,13 +94,18 @@ handleDW:
push ix \ pop hl push ix \ pop hl
ld a, l ld a, l
call ioPutC call ioPutC
jr nz, .ioError
ld a, h ld a, h
call ioPutC call ioPutC
jr nz, .ioError
call readComma call readComma
jr z, .loop jr z, .loop
cp a ; ensure Z cp a ; ensure Z
pop hl pop hl
ret ret
.ioError:
ld a, SHELL_ERR_IO_ERROR
jr .error
.badfmt: .badfmt:
ld a, ERR_BAD_FMT ld a, ERR_BAD_FMT
jr .error jr .error
@ -181,10 +187,14 @@ handleFIL:
ld b, c ld b, c
.loop: .loop:
call ioPutC call ioPutC
jr nz, .ioError
djnz .loop djnz .loop
cp a ; ensure Z cp a ; ensure Z
pop bc pop bc
ret ret
.ioError:
ld a, SHELL_ERR_IO_ERROR
jr .error
.badfmt: .badfmt:
ld a, ERR_BAD_FMT ld a, ERR_BAD_FMT
jr .error jr .error

View File

@ -18,7 +18,6 @@
; during the first pass so forward references are not allowed. ; during the first pass so forward references are not allowed.
; ;
; *** Requirements *** ; *** Requirements ***
; blockdev
; strncmp ; strncmp
; addDE ; addDE
; addHL ; addHL
@ -41,6 +40,7 @@
; _blkPutC ; _blkPutC
; _blkSeek ; _blkSeek
; _blkTell ; _blkTell
; printstr
; FS_HANDLE_SIZE ; FS_HANDLE_SIZE
; BLOCKDEV_SIZE ; BLOCKDEV_SIZE

View File

@ -223,6 +223,7 @@ ioInInclude:
; Open include file name specified in (HL). ; Open include file name specified in (HL).
; Sets Z on success, unset on error. ; Sets Z on success, unset on error.
ioOpenInclude: ioOpenInclude:
call ioPrintLN
call fsFindFN call fsFindFN
ret nz ret nz
ld ix, IO_INCLUDE_HDL ld ix, IO_INCLUDE_HDL
@ -257,3 +258,13 @@ _ioIncGetC:
_ioIncBlk: _ioIncBlk:
.dw _ioIncGetC, unsetZ .dw _ioIncGetC, unsetZ
; call printstr followed by newline
ioPrintLN:
push hl
call printstr
ld hl, .sCRLF
call printstr
pop hl
ret
.sCRLF:
.db 0x0a, 0x0d, 0

View File

@ -53,11 +53,15 @@ zasmMain:
call symInit call symInit
; First pass ; First pass
ld hl, .sFirstPass
call ioPrintLN
ld a, 1 ld a, 1
ld (ZASM_FIRST_PASS), a ld (ZASM_FIRST_PASS), a
call zasmParseFile call zasmParseFile
jr nz, .end jr nz, .end
; Second pass ; Second pass
ld hl, .sSecondPass
call ioPrintLN
xor a xor a
ld (ZASM_FIRST_PASS), a ld (ZASM_FIRST_PASS), a
call zasmParseFile call zasmParseFile
@ -66,6 +70,10 @@ zasmMain:
.argspecs: .argspecs:
.db 0b001, 0b001, 0 .db 0b001, 0b001, 0
.sFirstPass:
.db "First pass", 0
.sSecondPass:
.db "Second pass", 0
; Sets Z according to whether we're in first pass. ; Sets Z according to whether we're in first pass.
zasmIsFirstPass: zasmIsFirstPass:

View File

@ -31,6 +31,7 @@ jp _blkGetC
jp _blkPutC jp _blkPutC
jp _blkSeek jp _blkSeek
jp _blkTell jp _blkTell
jp printstr
#include "core.asm" #include "core.asm"
#include "err.h" #include "err.h"
@ -43,7 +44,10 @@ jp _blkTell
.dw unsetZ, emulPutC .dw unsetZ, emulPutC
.dw fsdevGetC, fsdevPutC .dw fsdevGetC, fsdevPutC
.equ FS_RAMSTART BLOCKDEV_RAMEND .equ STDIO_RAMSTART BLOCKDEV_RAMEND
#include "stdio.asm"
.equ FS_RAMSTART STDIO_RAMEND
.equ FS_HANDLE_COUNT 0 .equ FS_HANDLE_COUNT 0
#include "fs.asm" #include "fs.asm"
@ -51,6 +55,9 @@ init:
di di
ld hl, 0xffff ld hl, 0xffff
ld sp, hl ld sp, hl
ld hl, unsetZ
ld de, stderrPutC
call stdioInit
ld a, 2 ; select fsdev ld a, 2 ; select fsdev
ld de, BLOCKDEV_SEL ld de, BLOCKDEV_SEL
call blkSel call blkSel
@ -85,6 +92,11 @@ emulPutC:
cp a ; ensure Z cp a ; ensure Z
ret ret
stderrPutC:
out (STDERR_PORT), a
cp a ; ensure Z
ret
fsdevGetC: fsdevGetC:
ld a, e ld a, e
out (FS_SEEK_PORT), a out (FS_SEEK_PORT), a

View File

@ -26,3 +26,4 @@
.equ _blkPutC 0x3c .equ _blkPutC 0x3c
.equ _blkSeek 0x3f .equ _blkSeek 0x3f
.equ _blkTell 0x42 .equ _blkTell 0x42
.equ printstr 0x45

View File

@ -40,6 +40,9 @@
// When defined, we dump memory instead of dumping expected stdout // When defined, we dump memory instead of dumping expected stdout
//#define MEMDUMP //#define MEMDUMP
//#define DEBUG //#define DEBUG
// By default, we don't spit what zasm prints. Too noisy. Define VERBOSE if
// you want to spit this content to stderr.
//#define VERBOSE
static Z80Context cpu; static Z80Context cpu;
static uint8_t mem[0x10000]; static uint8_t mem[0x10000];
@ -132,7 +135,9 @@ static void io_write(int unused, uint16_t addr, uint8_t val)
#endif #endif
} }
} else if (addr == STDERR_PORT) { } else if (addr == STDERR_PORT) {
#ifdef VERBOSE
fputc(val, stderr); fputc(val, stderr);
#endif
} else { } else {
fprintf(stderr, "Out of bounds I/O write: %d / %d (0x%x)\n", addr, val, val); fprintf(stderr, "Out of bounds I/O write: %d / %d (0x%x)\n", addr, val, val);
} }

View File

@ -1,6 +1,6 @@
.equ USER_CODE 0x4800 .equ USER_CODE 0x4800
.equ USER_RAMSTART 0x5800 .equ USER_RAMSTART 0x5800
.equ FS_HANDLE_SIZE 8 .equ FS_HANDLE_SIZE 6
.equ BLOCKDEV_SIZE 8 .equ BLOCKDEV_SIZE 8
; *** JUMP TABLE *** ; *** JUMP TABLE ***
@ -26,6 +26,7 @@
.equ _blkPutC 0x3c .equ _blkPutC 0x3c
.equ _blkSeek 0x3f .equ _blkSeek 0x3f
.equ _blkTell 0x42 .equ _blkTell 0x42
.equ printstr 0x45
#include "err.h" #include "err.h"
#include "zasm/const.asm" #include "zasm/const.asm"