1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 22:58:06 +11:00

zasm: fix 3-digit hex parsing

This commit is contained in:
Virgil Dupras 2019-05-17 23:00:57 -04:00
parent cdb6cce914
commit f44c3e5413
5 changed files with 34 additions and 9 deletions

View File

@ -27,6 +27,8 @@
; intoDE ; intoDE
; intoHL ; intoHL
; findchar ; findchar
; parseHex
; parseHexPair
; blkSel ; blkSel
; fsFindFN ; fsFindFN
; fsOpen ; fsOpen

View File

@ -72,12 +72,21 @@ parseHexadecimal:
call strlen call strlen
cp 3 cp 3
jr c, .single jr c, .single
cp 4
jr c, .doubleShort ; 0x123
cp 5 cp 5
jr c, .double jr c, .double ; 0x1234
; too long, error ; too long, error
jr .error jr .error
.double: .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 jr c, .error
inc hl ; now HL is on first char of next pair inc hl ; now HL is on first char of next pair
ld ixh, a ld ixh, a

View File

@ -17,6 +17,7 @@ jp unsetZ
jp intoDE jp intoDE
jp intoHL jp intoHL
jp findchar jp findchar
jp parseHex
jp parseHexPair jp parseHexPair
jp blkSel jp blkSel
jp fsFindFN jp fsFindFN

View File

@ -7,13 +7,14 @@ unsetZ .equ 0x0f
intoDE .equ 0x12 intoDE .equ 0x12
intoHL .equ 0x15 intoHL .equ 0x15
findchar .equ 0x18 findchar .equ 0x18
parseHexPair .equ 0x1b parseHex .equ 0x1b
blkSel .equ 0x1e parseHexPair .equ 0x1e
fsFindFN .equ 0x21 blkSel .equ 0x21
fsOpen .equ 0x24 fsFindFN .equ 0x24
fsGetC .equ 0x27 fsOpen .equ 0x27
fsSeek .equ 0x2a fsGetC .equ 0x2a
fsTell .equ 0x2d fsSeek .equ 0x2d
fsTell .equ 0x30
.equ FS_HANDLE_SIZE 8 .equ FS_HANDLE_SIZE 8
.equ STDERR_PORT 0x04 .equ STDERR_PORT 0x04

View File

@ -16,6 +16,7 @@ testNum: .db 1
s99: .db "99", 0 s99: .db "99", 0
s0x99: .db "0x99", 0 s0x99: .db "0x99", 0
s0x100: .db "0x100", 0
s0b0101: .db "0b0101", 0 s0b0101: .db "0b0101", 0
s0b01010101: .db "0b01010101", 0 s0b01010101: .db "0b01010101", 0
sFoo: .db "Foo", 0 sFoo: .db "Foo", 0
@ -35,6 +36,17 @@ test:
jp nz, fail jp nz, fail
call nexttest 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 ld hl, sFoo
call parseLiteral call parseLiteral
jp z, fail jp z, fail