2019-05-17 23:33:20 +10:00
|
|
|
jp test
|
|
|
|
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "core.asm"
|
2019-11-16 07:37:49 +11:00
|
|
|
.inc "lib/util.asm"
|
|
|
|
.inc "lib/parse.asm"
|
2019-05-17 23:33:20 +10:00
|
|
|
|
2019-05-20 23:17:50 +10:00
|
|
|
zasmGetPC:
|
|
|
|
ret
|
|
|
|
|
2019-05-17 23:33:20 +10:00
|
|
|
testNum: .db 1
|
|
|
|
|
|
|
|
test:
|
2019-12-30 13:05:09 +11:00
|
|
|
ld sp, 0xffff
|
2019-05-17 23:33:20 +10:00
|
|
|
|
2019-11-09 02:18:54 +11:00
|
|
|
call testParseHex
|
2019-12-30 13:39:51 +11:00
|
|
|
call testParseHexadecimal
|
2019-11-09 02:18:54 +11:00
|
|
|
|
|
|
|
; success
|
|
|
|
xor a
|
|
|
|
halt
|
|
|
|
|
|
|
|
testParseHex:
|
2019-05-17 23:33:20 +10:00
|
|
|
ld a, '8'
|
|
|
|
call parseHex
|
|
|
|
jp c, fail
|
|
|
|
cp 8
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
|
|
|
ld a, 'e'
|
|
|
|
call parseHex
|
|
|
|
jp c, fail
|
|
|
|
cp 0xe
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
|
|
|
ld a, 'x'
|
|
|
|
call parseHex
|
|
|
|
jp nc, fail
|
|
|
|
call nexttest
|
2019-11-09 02:18:54 +11:00
|
|
|
ret
|
2019-05-17 23:33:20 +10:00
|
|
|
|
2019-12-30 13:39:51 +11:00
|
|
|
testParseHexadecimal:
|
2019-11-09 02:18:54 +11:00
|
|
|
ld hl, .s99
|
2019-12-30 13:39:51 +11:00
|
|
|
call parseHexadecimal
|
|
|
|
jp nz, fail
|
|
|
|
ld a, e
|
2019-05-17 23:33:20 +10:00
|
|
|
cp 0x99
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-11-09 02:18:54 +11:00
|
|
|
ld hl, .saB
|
2019-12-30 13:39:51 +11:00
|
|
|
call parseHexadecimal
|
|
|
|
jp nz, fail
|
|
|
|
ld a, e
|
2019-05-17 23:33:20 +10:00
|
|
|
cp 0xab
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-12-30 13:39:51 +11:00
|
|
|
; The string "Foo" will not cause a failure. We will parse up to "o"
|
|
|
|
; and then stop.
|
2019-11-09 02:18:54 +11:00
|
|
|
ld hl, .sFoo
|
2019-12-30 13:39:51 +11:00
|
|
|
call parseHexadecimal
|
|
|
|
jp nz, fail
|
|
|
|
ld a, e
|
|
|
|
cp 0xf
|
2019-05-17 23:33:20 +10:00
|
|
|
call nexttest
|
2019-11-09 02:18:54 +11:00
|
|
|
ret
|
2019-05-17 23:33:20 +10:00
|
|
|
|
2019-11-09 02:18:54 +11:00
|
|
|
.sFoo: .db "Foo", 0
|
|
|
|
.saB: .db "aB", 0
|
|
|
|
.s99: .db "99", 0
|
|
|
|
|
2019-05-17 23:33:20 +10:00
|
|
|
nexttest:
|
|
|
|
ld a, (testNum)
|
|
|
|
inc a
|
|
|
|
ld (testNum), a
|
|
|
|
ret
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ld a, (testNum)
|
|
|
|
halt
|
2019-11-09 02:18:54 +11:00
|
|
|
|
|
|
|
; used as RAM
|
|
|
|
sandbox:
|