diff --git a/apps/zasm/main.asm b/apps/zasm/main.asm index 7bd3566..ddd72f4 100644 --- a/apps/zasm/main.asm +++ b/apps/zasm/main.asm @@ -27,6 +27,8 @@ ; intoDE ; intoHL ; findchar +; parseHex +; parseHexPair ; blkSel ; fsFindFN ; fsOpen diff --git a/apps/zasm/parse.asm b/apps/zasm/parse.asm index 3163409..b29d3b7 100644 --- a/apps/zasm/parse.asm +++ b/apps/zasm/parse.asm @@ -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 diff --git a/tools/emul/zasm/glue.asm b/tools/emul/zasm/glue.asm index 286a91b..46d449b 100644 --- a/tools/emul/zasm/glue.asm +++ b/tools/emul/zasm/glue.asm @@ -17,6 +17,7 @@ jp unsetZ jp intoDE jp intoHL jp findchar +jp parseHex jp parseHexPair jp blkSel jp fsFindFN diff --git a/tools/emul/zasm/user.asm b/tools/emul/zasm/user.asm index aa24063..ff39220 100644 --- a/tools/emul/zasm/user.asm +++ b/tools/emul/zasm/user.asm @@ -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 diff --git a/tools/tests/unit/test_parse_z.asm b/tools/tests/unit/test_parse_z.asm index 2649a18..ecb7131 100644 --- a/tools/tests/unit/test_parse_z.asm +++ b/tools/tests/unit/test_parse_z.asm @@ -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