mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 22:48:05 +11:00
zasm: have .fill generate an error on overflow
Can possibly avoid a lot of debugging pain.
This commit is contained in:
parent
8d46895dd3
commit
82995eb346
@ -121,15 +121,20 @@ allowed. An included file cannot have an `.inc` directive.
|
|||||||
expression written as the second parameter. Example:
|
expression written as the second parameter. Example:
|
||||||
`.equ foo 0x42+'A'`
|
`.equ foo 0x42+'A'`
|
||||||
|
|
||||||
If the symbol specified has already been defined, no error occur and
|
If the symbol specified has already been defined, no error occur and
|
||||||
the first value defined stays intact. This allows for "user override"
|
the first value defined stays intact. This allows for "user override"
|
||||||
of programs.
|
of programs.
|
||||||
|
|
||||||
**.fill**: Outputs the number of null bytes specified by its argument, an
|
**.fill**: Outputs the number of null bytes specified by its argument, an
|
||||||
expression. Often used with `$` to fill our binary up to a certain
|
expression. Often used with `$` to fill our binary up to a certain
|
||||||
offset. For example, if we want to place an instruction exactly at
|
offset. For example, if we want to place an instruction exactly at
|
||||||
byte 0x38, we would precede it with `.fill 0x38-$`.
|
byte 0x38, we would precede it with `.fill 0x38-$`.
|
||||||
|
|
||||||
|
The maximum value possible for `.fill` is `0xd000`. We do this to
|
||||||
|
avoid "overshoot" errors, that is, error where `$` is greater than
|
||||||
|
the offset you're trying to reach in an expression like `.fill X-$`
|
||||||
|
(such an expression overflows to `0xffff`).
|
||||||
|
|
||||||
**.org**: Sets the Program Counter to the value of the argument, an expression.
|
**.org**: Sets the Program Counter to the value of the argument, an expression.
|
||||||
For example, a label being defined right after a `.org 0x400`, would
|
For example, a label being defined right after a `.org 0x400`, would
|
||||||
have a value of `0x400`. Does not do any filling. You have to do that
|
have a value of `0x400`. Does not do any filling. You have to do that
|
||||||
|
@ -201,8 +201,11 @@ handleFIL:
|
|||||||
jr nz, .badfmt
|
jr nz, .badfmt
|
||||||
call parseExpr
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
push bc
|
push bc ; --> lvl 1
|
||||||
push ix \ pop bc
|
push ix \ pop bc
|
||||||
|
ld a, b
|
||||||
|
cp 0xd0
|
||||||
|
jr nc, .overflow
|
||||||
.loop:
|
.loop:
|
||||||
ld a, b
|
ld a, b
|
||||||
or c
|
or c
|
||||||
@ -213,20 +216,22 @@ handleFIL:
|
|||||||
dec bc
|
dec bc
|
||||||
jr .loop
|
jr .loop
|
||||||
.loopend:
|
.loopend:
|
||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
pop bc
|
pop bc ; <-- lvl 1
|
||||||
ret
|
ret
|
||||||
.ioError:
|
.ioError:
|
||||||
ld a, SHELL_ERR_IO_ERROR
|
ld a, SHELL_ERR_IO_ERROR
|
||||||
jr .error
|
jp unsetZ
|
||||||
.badfmt:
|
.badfmt:
|
||||||
ld a, ERR_BAD_FMT
|
ld a, ERR_BAD_FMT
|
||||||
jr .error
|
jp unsetZ
|
||||||
.badarg:
|
.badarg:
|
||||||
ld a, ERR_BAD_ARG
|
ld a, ERR_BAD_ARG
|
||||||
.error:
|
jp unsetZ
|
||||||
call unsetZ
|
.overflow:
|
||||||
ret
|
pop bc ; <-- lvl 1
|
||||||
|
ld a, ERR_OVFL
|
||||||
|
jp unsetZ
|
||||||
|
|
||||||
handleOUT:
|
handleOUT:
|
||||||
push hl
|
push hl
|
||||||
|
@ -54,6 +54,7 @@ chkerr ".inc" 19
|
|||||||
chkerr ".inc foo" 19
|
chkerr ".inc foo" 19
|
||||||
chkerr "ld a, 0x100" 20
|
chkerr "ld a, 0x100" 20
|
||||||
chkerr ".db 0x100" 20
|
chkerr ".db 0x100" 20
|
||||||
|
chkerr $'nop \ nop \ nop\n.fill 2-$' 20
|
||||||
chkerr ".inc \"doesnotexist\"" 21
|
chkerr ".inc \"doesnotexist\"" 21
|
||||||
chkerr "foo:\\foo:" 22
|
chkerr "foo:\\foo:" 22
|
||||||
chkoom
|
chkoom
|
||||||
|
Loading…
Reference in New Issue
Block a user