1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-23 23:48:05 +11:00
collapseos/tests/unit/test_symbol.asm

70 lines
917 B
NASM
Raw Normal View History

.equ RAMSTART 0x4000
.equ ZASM_REG_MAXCNT 0xff
.equ ZASM_LREG_MAXCNT 0x40
.equ ZASM_REG_BUFSZ 0x1000
.equ ZASM_LREG_BUFSZ 0x200
jp test
.inc "core.asm"
.inc "str.asm"
.inc "lib/util.asm"
.inc "zasm/util.asm"
.inc "zasm/const.asm"
.equ SYM_RAMSTART RAMSTART
.inc "zasm/symbol.asm"
testNum: .db 1
sFOO: .db "FOO", 0
sFOOBAR: .db "FOOBAR", 0
sOther: .db "Other", 0
test:
ld sp, 0xffff
; Check that we compare whole strings (a prefix will not match a longer
; string).
call symInit
ld hl, sFOOBAR
ld de, 42
2019-07-23 05:59:47 +10:00
call symRegisterGlobal
jp nz, fail
ld hl, sFOO
ld de, 43
2019-07-23 05:59:47 +10:00
call symRegisterGlobal
jp nz, fail
ld hl, sFOO
call symFindVal ; don't match FOOBAR
jp nz, fail
ld a, d
or a
jp nz, fail
ld a, e
cp 43
jp nz, fail
call nexttest
ld hl, sOther
call symFindVal
jp z, fail
call nexttest
; success
xor a
halt
nexttest:
ld hl, testNum
inc (hl)
ret
fail:
ld a, (testNum)
halt