@@ -127,6 +127,13 @@ allowed. An included file cannot have an `#inc` directive. | |||||
explicitly with `.fill`, if needed. Often used to assemble binaries | explicitly with `.fill`, if needed. Often used to assemble binaries | ||||
designed to run at offsets other than zero (userland). | designed to run at offsets other than zero (userland). | ||||
**.out**: Outputs the value of the expression supplied as an argument to | |||||
`ZASM_DEBUG_PORT`. The value is always interpreted as a word, so | |||||
there's always two `out` instruction executed per directive. High byte | |||||
is sent before low byte. Useful or debugging, quickly figuring our | |||||
RAM constants, etc. The value is only outputted during the second | |||||
pass. | |||||
**#inc**: Takes a string literal as an argument. Open the file name specified | **#inc**: Takes a string literal as an argument. Open the file name specified | ||||
in the argument in the currently active filesystem, parse that file | in the argument in the currently active filesystem, parse that file | ||||
and output its binary content as is the code has been in the includer | and output its binary content as is the code has been in the includer | ||||
@@ -19,3 +19,6 @@ | |||||
; Out of memory | ; Out of memory | ||||
.equ ERR_OOM 0x07 | .equ ERR_OOM 0x07 | ||||
; *** Other *** | |||||
.equ ZASM_DEBUG_PORT 42 |
@@ -5,7 +5,8 @@ | |||||
.equ D_EQU 0x02 | .equ D_EQU 0x02 | ||||
.equ D_ORG 0x03 | .equ D_ORG 0x03 | ||||
.equ D_FIL 0x04 | .equ D_FIL 0x04 | ||||
.equ D_INC 0x05 | |||||
.equ D_OUT 0x05 | |||||
.equ D_INC 0x06 | |||||
.equ D_BAD 0xff | .equ D_BAD 0xff | ||||
; *** Variables *** | ; *** Variables *** | ||||
@@ -20,6 +21,7 @@ directiveNames: | |||||
.db ".EQU" | .db ".EQU" | ||||
.db ".ORG" | .db ".ORG" | ||||
.db ".FIL" | .db ".FIL" | ||||
.db ".OUT" | |||||
.db "#inc" | .db "#inc" | ||||
; This is a list of handlers corresponding to indexes in directiveNames | ; This is a list of handlers corresponding to indexes in directiveNames | ||||
@@ -29,6 +31,7 @@ directiveHandlers: | |||||
.dw handleEQU | .dw handleEQU | ||||
.dw handleORG | .dw handleORG | ||||
.dw handleFIL | .dw handleFIL | ||||
.dw handleOUT | |||||
.dw handleINC | .dw handleINC | ||||
handleDB: | handleDB: | ||||
@@ -187,6 +190,33 @@ handleFIL: | |||||
call unsetZ | call unsetZ | ||||
ret | ret | ||||
handleOUT: | |||||
push hl | |||||
; Read our expression | |||||
call readWord | |||||
jr nz, .badfmt | |||||
call zasmIsFirstPass ; No .out during first pass | |||||
jr z, .end | |||||
ld hl, scratchpad | |||||
call parseExpr | |||||
jr nz, .badarg | |||||
push ix \ pop hl | |||||
ld a, h | |||||
out (ZASM_DEBUG_PORT), a | |||||
ld a, l | |||||
out (ZASM_DEBUG_PORT), a | |||||
jr .end | |||||
.badfmt: | |||||
ld a, ERR_BAD_FMT | |||||
jr .error | |||||
.badarg: | |||||
ld a, ERR_BAD_ARG | |||||
.error: | |||||
call unsetZ | |||||
.end: | |||||
pop hl | |||||
ret | |||||
handleINC: | handleINC: | ||||
call readWord | call readWord | ||||
jr nz, .badfmt | jr nz, .badfmt | ||||