2019-05-18 03:14:16 +10:00
|
|
|
.equ RAMSTART 0x4000
|
2019-07-24 06:50:19 +10:00
|
|
|
.equ ZASM_REG_MAXCNT 0xff
|
|
|
|
.equ ZASM_LREG_MAXCNT 0x40
|
|
|
|
.equ ZASM_REG_BUFSZ 0x1000
|
|
|
|
.equ ZASM_LREG_BUFSZ 0x200
|
|
|
|
|
2019-05-18 03:14:16 +10:00
|
|
|
jp test
|
|
|
|
|
|
|
|
#include "core.asm"
|
|
|
|
#include "parse.asm"
|
2019-07-20 04:24:35 +10:00
|
|
|
#include "lib/util.asm"
|
2019-05-18 10:22:32 +10:00
|
|
|
#include "zasm/util.asm"
|
2019-05-28 07:45:05 +10:00
|
|
|
#include "zasm/const.asm"
|
2019-07-20 04:24:35 +10:00
|
|
|
#include "lib/parse.asm"
|
2019-05-18 10:22:32 +10:00
|
|
|
#include "zasm/parse.asm"
|
2019-05-18 03:14:16 +10:00
|
|
|
.equ SYM_RAMSTART RAMSTART
|
2019-05-18 10:22:32 +10:00
|
|
|
#include "zasm/symbol.asm"
|
|
|
|
#include "zasm/expr.asm"
|
2019-05-18 03:14:16 +10:00
|
|
|
|
|
|
|
; Pretend that we aren't in first pass
|
|
|
|
zasmIsFirstPass:
|
|
|
|
jp unsetZ
|
|
|
|
|
2019-05-20 23:17:50 +10:00
|
|
|
zasmGetPC:
|
|
|
|
ret
|
|
|
|
|
2019-05-18 03:14:16 +10:00
|
|
|
testNum: .db 1
|
|
|
|
|
|
|
|
s1: .db "2+2", 0
|
|
|
|
s2: .db "0x4001+0x22", 0
|
|
|
|
s3: .db "FOO+BAR", 0
|
2019-05-19 05:17:56 +10:00
|
|
|
s4: .db "BAR*3", 0
|
2019-05-19 04:51:11 +10:00
|
|
|
s5: .db "FOO-3", 0
|
2019-05-19 05:17:56 +10:00
|
|
|
s6: .db "FOO+BAR*4", 0
|
2019-05-18 03:14:16 +10:00
|
|
|
|
|
|
|
sFOO: .db "FOO", 0
|
|
|
|
sBAR: .db "BAR", 0
|
|
|
|
|
|
|
|
test:
|
|
|
|
ld hl, 0xffff
|
|
|
|
ld sp, hl
|
|
|
|
|
|
|
|
ld hl, s1
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 03:14:16 +10:00
|
|
|
or a
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-18 03:14:16 +10:00
|
|
|
cp 4
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
|
|
|
ld hl, s2
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 03:14:16 +10:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-18 03:14:16 +10: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-23 05:59:47 +10:00
|
|
|
call symRegisterGlobal
|
2019-05-18 03:14:16 +10:00
|
|
|
jp nz, fail
|
|
|
|
ld hl, sBAR
|
|
|
|
ld de, 0x20
|
2019-07-23 05:59:47 +10:00
|
|
|
call symRegisterGlobal
|
2019-05-18 03:14:16 +10:00
|
|
|
jp nz, fail
|
|
|
|
|
|
|
|
ld hl, s3
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 03:14:16 +10:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-18 03:14:16 +10:00
|
|
|
cp 0x20
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 12:22:10 +10:00
|
|
|
ld hl, s4
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-18 12:22:10 +10:00
|
|
|
or a
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-19 05:17:56 +10:00
|
|
|
cp 0x60
|
2019-05-18 12:22:10 +10:00
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-19 04:51:11 +10:00
|
|
|
ld hl, s5
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-19 04:51:11 +10:00
|
|
|
cp 0x3f
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-19 04:51:11 +10:00
|
|
|
cp 0xfd
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-19 05:17:56 +10:00
|
|
|
ld hl, s6
|
|
|
|
call parseExpr
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
push ix \ pop hl
|
|
|
|
ld a, h
|
2019-05-19 05:17:56 +10:00
|
|
|
cp 0x40
|
|
|
|
jp nz, fail
|
2019-05-20 21:50:23 +10:00
|
|
|
ld a, l
|
2019-05-19 05:17:56 +10:00
|
|
|
cp 0x80
|
|
|
|
jp nz, fail
|
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 03:14:16 +10:00
|
|
|
; success
|
|
|
|
xor a
|
|
|
|
halt
|
|
|
|
|
|
|
|
nexttest:
|
|
|
|
ld a, (testNum)
|
|
|
|
inc a
|
|
|
|
ld (testNum), a
|
|
|
|
ret
|
|
|
|
|
|
|
|
fail:
|
|
|
|
ld a, (testNum)
|
|
|
|
halt
|