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-10-05 10:26:21 +10:00
|
|
|
; declare DIREC_LASTVAL manually so that we don't have to include directive.asm
|
|
|
|
.equ DIREC_LASTVAL RAMSTART
|
|
|
|
|
2019-05-18 03:14:16 +10:00
|
|
|
jp test
|
|
|
|
|
2019-12-24 07:41:25 +11:00
|
|
|
.inc "ascii.h"
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "core.asm"
|
2019-11-15 01:55:31 +11:00
|
|
|
.inc "str.asm"
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "lib/util.asm"
|
2019-11-23 06:45:12 +11:00
|
|
|
.inc "lib/ari.asm"
|
2019-12-24 07:41:25 +11:00
|
|
|
.inc "lib/fmt.asm"
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/util.asm"
|
|
|
|
.inc "zasm/const.asm"
|
|
|
|
.inc "lib/parse.asm"
|
|
|
|
.inc "zasm/parse.asm"
|
2019-10-05 10:26:21 +10:00
|
|
|
.equ SYM_RAMSTART DIREC_LASTVAL+2
|
2019-10-07 05:32:23 +11:00
|
|
|
.inc "zasm/symbol.asm"
|
2019-11-19 07:52:07 +11:00
|
|
|
.equ EXPR_PARSE parseNumberOrSymbol
|
|
|
|
.inc "lib/expr.asm"
|
2019-12-24 07:41:25 +11:00
|
|
|
.equ STDIO_RAMSTART SYM_RAMEND
|
|
|
|
.inc "stdio.asm"
|
|
|
|
.inc "common.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
|
|
|
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:
|
2019-11-23 07:03:16 +11:00
|
|
|
ld sp, 0xffff
|
2019-05-18 03:14:16 +10:00
|
|
|
|
2019-12-24 07:41:25 +11:00
|
|
|
; New-style tests
|
|
|
|
;call testParseExpr
|
|
|
|
|
2019-11-23 07:03:16 +11:00
|
|
|
; Old-style tests, not touching them now.
|
2019-05-18 03:14:16 +10:00
|
|
|
ld hl, s1
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 4
|
|
|
|
call assertEQW
|
2019-05-18 03:14:16 +10:00
|
|
|
call nexttest
|
|
|
|
|
|
|
|
ld hl, s2
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 0x4023
|
|
|
|
call assertEQW
|
2019-05-18 03:14:16 +10:00
|
|
|
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
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 0x4020
|
|
|
|
call assertEQW
|
2019-05-18 03:14:16 +10:00
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 12:22:10 +10:00
|
|
|
ld hl, s4
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 0x60
|
|
|
|
call assertEQW
|
2019-05-18 12:22:10 +10:00
|
|
|
call nexttest
|
|
|
|
|
2019-05-19 04:51:11 +10:00
|
|
|
ld hl, s5
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 0x3ffd
|
|
|
|
call assertEQW
|
2019-05-19 04:51:11 +10:00
|
|
|
call nexttest
|
|
|
|
|
2019-05-19 05:17:56 +10:00
|
|
|
ld hl, s6
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld hl, 0x4080
|
|
|
|
call assertEQW
|
2019-05-19 05:17:56 +10:00
|
|
|
call nexttest
|
|
|
|
|
2019-05-18 03:14:16 +10:00
|
|
|
; success
|
|
|
|
xor a
|
|
|
|
halt
|
|
|
|
|
2019-11-23 07:03:16 +11:00
|
|
|
testParseExpr:
|
|
|
|
ld iy, .t1
|
|
|
|
call .testEQ
|
|
|
|
ld iy, .t2
|
|
|
|
call .testEQ
|
2019-11-23 09:16:51 +11:00
|
|
|
ld iy, .t3
|
|
|
|
call .testEQ
|
|
|
|
ld iy, .t4
|
|
|
|
call .testEQ
|
|
|
|
ld iy, .t5
|
|
|
|
call .testEQ
|
2019-11-23 10:35:10 +11:00
|
|
|
ld iy, .t6
|
|
|
|
call .testEQ
|
|
|
|
ld iy, .t7
|
|
|
|
call .testEQ
|
2019-11-24 06:56:23 +11:00
|
|
|
ld iy, .t8
|
|
|
|
call .testEQ
|
2019-12-24 07:41:25 +11:00
|
|
|
ld iy, .t9
|
|
|
|
call .testEQ
|
2019-11-23 07:03:16 +11:00
|
|
|
ret
|
|
|
|
|
|
|
|
.testEQ:
|
|
|
|
push iy \ pop hl
|
|
|
|
inc hl \ inc hl
|
2019-12-24 11:13:44 +11:00
|
|
|
call parseExpr
|
2019-12-24 07:41:25 +11:00
|
|
|
call assertZ
|
|
|
|
ld l, (iy)
|
|
|
|
ld h, (iy+1)
|
|
|
|
call assertEQW
|
2019-11-23 07:03:16 +11:00
|
|
|
jp nexttest
|
|
|
|
|
|
|
|
.t1:
|
|
|
|
.dw 7
|
|
|
|
.db "42/6", 0
|
|
|
|
.t2:
|
|
|
|
.dw 1
|
|
|
|
.db "7%3", 0
|
2019-11-23 09:16:51 +11:00
|
|
|
.t3:
|
|
|
|
.dw 0x0907
|
|
|
|
.db "0x99f7&0x0f0f", 0
|
|
|
|
.t4:
|
|
|
|
.dw 0x9fff
|
|
|
|
.db "0x99f7|0x0f0f", 0
|
|
|
|
.t5:
|
|
|
|
.dw 0x96f8
|
|
|
|
.db "0x99f7^0x0f0f", 0
|
2019-11-23 10:35:10 +11:00
|
|
|
.t6:
|
|
|
|
.dw 0x133e
|
|
|
|
.db "0x99f7}3", 0
|
|
|
|
.t7:
|
|
|
|
.dw 0xcfb8
|
|
|
|
.db "0x99f7{3", 0
|
2019-11-24 06:56:23 +11:00
|
|
|
.t8:
|
|
|
|
.dw 0xffff
|
|
|
|
.db "-1", 0
|
2019-12-24 07:41:25 +11:00
|
|
|
.t9:
|
|
|
|
.dw 10
|
|
|
|
.db "2*3+4", 0
|