mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-24 14:28:06 +11:00
zasm: fix 3-digit hex parsing
This commit is contained in:
parent
cdb6cce914
commit
f44c3e5413
@ -27,6 +27,8 @@
|
||||
; intoDE
|
||||
; intoHL
|
||||
; findchar
|
||||
; parseHex
|
||||
; parseHexPair
|
||||
; blkSel
|
||||
; fsFindFN
|
||||
; fsOpen
|
||||
|
@ -72,12 +72,21 @@ parseHexadecimal:
|
||||
call strlen
|
||||
cp 3
|
||||
jr c, .single
|
||||
cp 4
|
||||
jr c, .doubleShort ; 0x123
|
||||
cp 5
|
||||
jr c, .double
|
||||
jr c, .double ; 0x1234
|
||||
; too long, error
|
||||
jr .error
|
||||
.double:
|
||||
call parseHexPair ; moves HL to last char of pair
|
||||
call parseHexPair
|
||||
jr c, .error
|
||||
inc hl ; now HL is on first char of next pair
|
||||
ld ixh, a
|
||||
jr .single
|
||||
.doubleShort:
|
||||
ld a, (hl)
|
||||
call parseHex
|
||||
jr c, .error
|
||||
inc hl ; now HL is on first char of next pair
|
||||
ld ixh, a
|
||||
|
@ -17,6 +17,7 @@ jp unsetZ
|
||||
jp intoDE
|
||||
jp intoHL
|
||||
jp findchar
|
||||
jp parseHex
|
||||
jp parseHexPair
|
||||
jp blkSel
|
||||
jp fsFindFN
|
||||
|
@ -7,13 +7,14 @@ unsetZ .equ 0x0f
|
||||
intoDE .equ 0x12
|
||||
intoHL .equ 0x15
|
||||
findchar .equ 0x18
|
||||
parseHexPair .equ 0x1b
|
||||
blkSel .equ 0x1e
|
||||
fsFindFN .equ 0x21
|
||||
fsOpen .equ 0x24
|
||||
fsGetC .equ 0x27
|
||||
fsSeek .equ 0x2a
|
||||
fsTell .equ 0x2d
|
||||
parseHex .equ 0x1b
|
||||
parseHexPair .equ 0x1e
|
||||
blkSel .equ 0x21
|
||||
fsFindFN .equ 0x24
|
||||
fsOpen .equ 0x27
|
||||
fsGetC .equ 0x2a
|
||||
fsSeek .equ 0x2d
|
||||
fsTell .equ 0x30
|
||||
|
||||
.equ FS_HANDLE_SIZE 8
|
||||
.equ STDERR_PORT 0x04
|
||||
|
@ -16,6 +16,7 @@ testNum: .db 1
|
||||
|
||||
s99: .db "99", 0
|
||||
s0x99: .db "0x99", 0
|
||||
s0x100: .db "0x100", 0
|
||||
s0b0101: .db "0b0101", 0
|
||||
s0b01010101: .db "0b01010101", 0
|
||||
sFoo: .db "Foo", 0
|
||||
@ -35,6 +36,17 @@ test:
|
||||
jp nz, fail
|
||||
call nexttest
|
||||
|
||||
ld hl, s0x100
|
||||
call parseLiteral
|
||||
jp nz, fail
|
||||
ld a, ixh
|
||||
cp 1
|
||||
jp nz, fail
|
||||
ld a, ixl
|
||||
or a
|
||||
jp nz, fail
|
||||
call nexttest
|
||||
|
||||
ld hl, sFoo
|
||||
call parseLiteral
|
||||
jp z, fail
|
||||
|
Loading…
Reference in New Issue
Block a user