2019-05-17 13:14:16 -04:00
|
|
|
.equ RAMSTART 0x4000
|
2019-07-23 16:50:19 -04:00
|
|
|
.equ ZASM_REG_MAXCNT 0xff
|
|
|
|
.equ ZASM_LREG_MAXCNT 0x40
|
|
|
|
.equ ZASM_REG_BUFSZ 0x1000
|
|
|
|
.equ ZASM_LREG_BUFSZ 0x200
|
|
|
|
|
2019-10-04 20:26:21 -04:00
|
|
|
; declare DIREC_LASTVAL manually so that we don't have to include directive.asm
|
|
|
|
.equ DIREC_LASTVAL RAMSTART
|
|
|
|
|
2019-05-17 13:14:16 -04:00
|
|
|
jp test
|
|
|
|
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "core.asm"
|
2019-11-14 09:55:31 -05:00
|
|
|
.inc "str.asm"
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "lib/util.asm"
|
2019-11-22 14:45:12 -05:00
|
|
|
.inc "lib/ari.asm"
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "zasm/util.asm"
|
|
|
|
.inc "zasm/const.asm"
|
|
|
|
.inc "lib/parse.asm"
|
|
|
|
.inc "zasm/parse.asm"
|
2019-10-04 20:26:21 -04:00
|
|
|
.equ SYM_RAMSTART DIREC_LASTVAL+2
|
2019-10-06 14:32:23 -04:00
|
|
|
.inc "zasm/symbol.asm"
|
2019-11-18 15:52:07 -05:00
|
|
|
.equ EXPR_PARSE parseNumberOrSymbol
|
|
|
|
.inc "lib/expr.asm"
|
2019-05-17 13:14:16 -04:00
|
|
|
|
|
|
|
; Pretend that we aren't in first pass
|
|
|
|
zasmIsFirstPass:
|
|
|
|
jp unsetZ
|
|
|
|
|
2019-05-20 09:17:50 -04:00
|
|
|
zasmGetPC:
|
|
|
|
ret
|
|
|
|
|
2019-05-17 13:14:16 -04:00
|
|
|
testNum: .db 1
|
|
|
|
|
|
|
|
s1: .db "2+2", 0
|
|
|
|
s2: .db "0x4001+0x22", 0
|
|
|
|
s3: .db "FOO+BAR", 0
|
2019-05-18 15:17:56 -04:00
|
|
|
s4: .db "BAR*3", 0
|
2019-05-18 14:51:11 -04:00
|
|
|
s5: .db "FOO-3", 0
|
2019-05-18 15:17:56 -04:00
|
|
|
s6: .db "FOO+BAR*4", 0
|
2019-05-17 13:14:16 -04:00
|
|
|
|
|
|
|
sFOO: .db "FOO", 0
|
|
|
|
sBAR: .db "BAR", 0
|
|
|
|
|
|
|
|
test:
|
2019-11-22 15:03:16 -05:00
|
|
|
ld sp, 0xffff
|
2019-05-17 13:14:16 -04:00
|
|
|
|
2019-11-22 15:03:16 -05:00
|
|
|
; Old-style tests, not touching them now.
|
2019-05-17 13:14:16 -04:00
|
|
|
ld hl, s1
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-17 13:14:16 -04:00
|
|
|
or a
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-17 13:14:16 -04:00
|
|
|
cp 4
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
|
|
|
ld hl, s2
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-17 13:14:16 -04:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-17 13:14:16 -04:00
|
|
|
cp 0x23
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
|
|
|
; before the next test, let's set up FOO and BAR symbols
|
|
|
|
call symInit
|
|
|
|
ld hl, sFOO
|
|
|
|
ld de, 0x4000
|
2019-07-22 15:59:47 -04:00
|
|
|
call symRegisterGlobal
|
2019-05-17 13:14:16 -04:00
|
|
|
jp nz, fail
|
|
|
|
ld hl, sBAR
|
|
|
|
ld de, 0x20
|
2019-07-22 15:59:47 -04:00
|
|
|
call symRegisterGlobal
|
2019-05-17 13:14:16 -04:00
|
|
|
jp nz, fail
|
|
|
|
|
|
|
|
ld hl, s3
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-17 13:14:16 -04:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-17 13:14:16 -04:00
|
|
|
cp 0x20
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-17 22:22:10 -04:00
|
|
|
ld hl, s4
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-17 22:22:10 -04:00
|
|
|
or a
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-18 15:17:56 -04:00
|
|
|
cp 0x60
|
2019-05-17 22:22:10 -04:00
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 14:51:11 -04:00
|
|
|
ld hl, s5
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 14:51:11 -04:00
|
|
|
cp 0x3f
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-18 14:51:11 -04:00
|
|
|
cp 0xfd
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 15:17:56 -04:00
|
|
|
ld hl, s6
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 15:17:56 -04:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 07:50:23 -04:00
|
|
|
ld a, l
|
2019-05-18 15:17:56 -04:00
|
|
|
cp 0x80
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-11-22 15:03:16 -05:00
|
|
|
; New-style tests
|
|
|
|
call testParseExpr
|
2019-05-17 13:14:16 -04:00
|
|
|
; success
|
|
|
|
xor a
|
|
|
|
halt
|
|
|
|
|
2019-11-22 15:03:16 -05:00
|
|
|
testParseExpr:
|
|
|
|
ld iy, .t1
|
|
|
|
call .testEQ
|
|
|
|
ld iy, .t2
|
|
|
|
call .testEQ
|
|
|
|
ret
|
|
|
|
|
|
|
|
.testEQ:
|
|
|
|
push iy \ pop hl
|
|
|
|
inc hl \ inc hl
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
|
|
|
push ix \ pop de
|
|
|
|
ld a, e
|
|
|
|
cp (iy)
|
|
|
|
jp nz, fail
|
|
|
|
ld a, d
|
|
|
|
cp (iy+1)
|
|
|
|
jp nz, fail
|
|
|
|
jp nexttest
|
|
|
|
|
|
|
|
.t1:
|
|
|
|
.dw 7
|
|
|
|
.db "42/6", 0
|
|
|
|
.t2:
|
|
|
|
.dw 1
|
|
|
|
.db "7%3", 0
|
|
|
|
|
2019-05-17 13:14:16 -04:00
|
|
|
nexttest:
|
|
|
|
ld a, (testNum)
|
|
|
|
inc a
|
|
|
|
ld (testNum), a
|
|
|
|
ret
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ld a, (testNum)
|
|
|
|
halt
|