mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 17:18:05 +11:00
parseExprDE --> parseExpr
This commit is contained in:
parent
5301200d6f
commit
6d88c3a754
@ -222,7 +222,7 @@ basPRINT:
|
|||||||
call rdWord
|
call rdWord
|
||||||
push hl ; --> lvl 1
|
push hl ; --> lvl 1
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .parseError
|
jr nz, .parseError
|
||||||
ld hl, SCRATCHPAD
|
ld hl, SCRATCHPAD
|
||||||
call fmtDecimalS
|
call fmtDecimalS
|
||||||
@ -251,7 +251,7 @@ basGOTO:
|
|||||||
ld de, SCRATCHPAD
|
ld de, SCRATCHPAD
|
||||||
call rdWord
|
call rdWord
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
ret nz
|
ret nz
|
||||||
call bufFind
|
call bufFind
|
||||||
jr nz, .notFound
|
jr nz, .notFound
|
||||||
@ -314,7 +314,7 @@ basINPUT:
|
|||||||
call spitQuoted
|
call spitQuoted
|
||||||
call rdSep
|
call rdSep
|
||||||
call stdioReadLine
|
call stdioReadLine
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
ld (VAR_TBL), de
|
ld (VAR_TBL), de
|
||||||
call printcrlf
|
call printcrlf
|
||||||
cp a ; ensure Z
|
cp a ; ensure Z
|
||||||
|
@ -40,7 +40,7 @@ parseTruth:
|
|||||||
ret
|
ret
|
||||||
|
|
||||||
.simple:
|
.simple:
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
ld a, d
|
ld a, d
|
||||||
or e
|
or e
|
||||||
@ -132,11 +132,11 @@ parseTruth:
|
|||||||
.parseLeftRight:
|
.parseLeftRight:
|
||||||
; let's start with HL
|
; let's start with HL
|
||||||
push de ; --> lvl 1
|
push de ; --> lvl 1
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
pop hl ; <-- lvl 1, orig DE
|
pop hl ; <-- lvl 1, orig DE
|
||||||
ret nz
|
ret nz
|
||||||
push de ; --> lvl 1. save HL value in stack.
|
push de ; --> lvl 1. save HL value in stack.
|
||||||
; Now, for DE. (DE) is now in HL
|
; Now, for DE. (DE) is now in HL
|
||||||
call parseExprDE ; DE in place
|
call parseExpr ; DE in place
|
||||||
pop hl ; <-- lvl 1. restore saved HL
|
pop hl ; <-- lvl 1. restore saved HL
|
||||||
ret
|
ret
|
||||||
|
@ -91,7 +91,7 @@ rdExpr:
|
|||||||
call rdWord
|
call rdWord
|
||||||
push hl
|
push hl
|
||||||
ex de, hl
|
ex de, hl
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
push de \ pop ix
|
push de \ pop ix
|
||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
@ -52,7 +52,7 @@ varTryAssign:
|
|||||||
call rdWord
|
call rdWord
|
||||||
ex de, hl
|
ex de, hl
|
||||||
; Now, evaluate that expression now in (HL)
|
; Now, evaluate that expression now in (HL)
|
||||||
call parseExprDE ; --> number in DE
|
call parseExpr ; --> number in DE
|
||||||
jr nz, .exprErr
|
jr nz, .exprErr
|
||||||
pop af ; <-- lvl 4
|
pop af ; <-- lvl 4
|
||||||
call varAssign
|
call varAssign
|
||||||
|
@ -11,25 +11,12 @@
|
|||||||
;
|
;
|
||||||
; *** Code ***
|
; *** Code ***
|
||||||
;
|
;
|
||||||
; Parse expression in string at (HL) and returns the result in IX.
|
|
||||||
|
; Parse expression in string at (HL) and returns the result in DE.
|
||||||
; **This routine mutates (HL).**
|
; **This routine mutates (HL).**
|
||||||
; We expect (HL) to be disposable: we mutate it to avoid having to make a copy.
|
; We expect (HL) to be disposable: we mutate it to avoid having to make a copy.
|
||||||
; Sets Z on success, unset on error.
|
; Sets Z on success, unset on error.
|
||||||
; TODO: the IX output register is a bit awkward. Nearly everywhere, I need
|
|
||||||
; to push \ pop that thing. See if we could return the result in DE
|
|
||||||
; instead.
|
|
||||||
parseExpr:
|
parseExpr:
|
||||||
push de
|
|
||||||
push hl
|
|
||||||
call _parseExpr
|
|
||||||
pop hl
|
|
||||||
pop de
|
|
||||||
ret
|
|
||||||
|
|
||||||
; Same as parseExpr, but preserves IX and puts result in DE. This is a
|
|
||||||
; transitionary routine and will replace parseExpr when everyone has jumped
|
|
||||||
; ship.
|
|
||||||
parseExprDE:
|
|
||||||
push ix
|
push ix
|
||||||
push hl
|
push hl
|
||||||
call _parseExpr
|
call _parseExpr
|
||||||
@ -116,17 +103,18 @@ _resolveLeftAndRight:
|
|||||||
or a
|
or a
|
||||||
jr z, .skip
|
jr z, .skip
|
||||||
; Parse left operand in (HL)
|
; Parse left operand in (HL)
|
||||||
|
push de ; --> lvl 1
|
||||||
call parseExpr
|
call parseExpr
|
||||||
|
pop hl ; <-- lvl 1, orig DE
|
||||||
ret nz ; return immediately if error
|
ret nz ; return immediately if error
|
||||||
.skip:
|
.skip:
|
||||||
; Now we have parsed everything to the left and we have its result in
|
; Now we have parsed everything to the left and we have its result in
|
||||||
; IX. What we need to do now is the same thing on (DE) and then apply
|
; DE. What we need to do now is the same thing on (DE) and then apply
|
||||||
; the + operator. Let's save IX somewhere and parse this.
|
; the + operator. Let's save DE somewhere and parse this.
|
||||||
ex de, hl ; right expr now in HL
|
push de ; --> lvl 1
|
||||||
push ix ; --> lvl 1
|
; right expr in (HL)
|
||||||
call parseExpr
|
call parseExpr ; DE is set
|
||||||
pop hl ; <-- lvl 1. left
|
pop hl ; <-- lvl 1. left value
|
||||||
push ix \ pop de ; right
|
|
||||||
ret ; Z is parseExpr's result
|
ret ; Z is parseExpr's result
|
||||||
|
|
||||||
; Routines in here all have the same signature: they take two numbers, DE (left)
|
; Routines in here all have the same signature: they take two numbers, DE (left)
|
||||||
|
@ -644,7 +644,7 @@ _readK8:
|
|||||||
|
|
||||||
_readDouble:
|
_readDouble:
|
||||||
push de
|
push de
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
ld b, d
|
ld b, d
|
||||||
ld c, e
|
ld c, e
|
||||||
@ -658,7 +658,7 @@ _readk7:
|
|||||||
push hl
|
push hl
|
||||||
push de
|
push de
|
||||||
push ix
|
push ix
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
; If we're in first pass, stop now. The value of HL doesn't matter and
|
; If we're in first pass, stop now. The value of HL doesn't matter and
|
||||||
; truncation checks might falsely fail.
|
; truncation checks might falsely fail.
|
||||||
@ -742,7 +742,7 @@ _readExpr:
|
|||||||
push de
|
push de
|
||||||
push bc
|
push bc
|
||||||
ld b, a
|
ld b, a
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
ld a, b
|
ld a, b
|
||||||
call _DE2A
|
call _DE2A
|
||||||
|
@ -48,7 +48,7 @@ handleDB:
|
|||||||
ld hl, scratchpad
|
ld hl, scratchpad
|
||||||
call enterDoubleQuotes
|
call enterDoubleQuotes
|
||||||
jr z, .stringLiteral
|
jr z, .stringLiteral
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ld a, d
|
ld a, d
|
||||||
or a ; cp 0
|
or a ; cp 0
|
||||||
@ -96,7 +96,7 @@ handleDW:
|
|||||||
call readWord
|
call readWord
|
||||||
jr nz, .badfmt
|
jr nz, .badfmt
|
||||||
ld hl, scratchpad
|
ld hl, scratchpad
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ld a, e
|
ld a, e
|
||||||
call ioPutB
|
call ioPutB
|
||||||
@ -148,7 +148,7 @@ handleEQU:
|
|||||||
call readWord
|
call readWord
|
||||||
jr nz, .badfmt
|
jr nz, .badfmt
|
||||||
ld hl, scratchpad
|
ld hl, scratchpad
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ld hl, DIREC_SCRATCHPAD
|
ld hl, DIREC_SCRATCHPAD
|
||||||
; Save value in "@" special variable
|
; Save value in "@" special variable
|
||||||
@ -183,7 +183,7 @@ handleORG:
|
|||||||
push de
|
push de
|
||||||
call readWord
|
call readWord
|
||||||
jr nz, .badfmt
|
jr nz, .badfmt
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ex de, hl
|
ex de, hl
|
||||||
ld (DIREC_LASTVAL), hl
|
ld (DIREC_LASTVAL), hl
|
||||||
@ -204,7 +204,7 @@ handleORG:
|
|||||||
handleFIL:
|
handleFIL:
|
||||||
call readWord
|
call readWord
|
||||||
jr nz, .badfmt
|
jr nz, .badfmt
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ld a, d
|
ld a, d
|
||||||
cp 0xd0
|
cp 0xd0
|
||||||
@ -243,7 +243,7 @@ handleOUT:
|
|||||||
call zasmIsFirstPass ; No .out during first pass
|
call zasmIsFirstPass ; No .out during first pass
|
||||||
jr z, .end
|
jr z, .end
|
||||||
ld hl, scratchpad
|
ld hl, scratchpad
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
jr nz, .badarg
|
jr nz, .badarg
|
||||||
ld a, d
|
ld a, d
|
||||||
out (ZASM_DEBUG_PORT), a
|
out (ZASM_DEBUG_PORT), a
|
||||||
|
@ -246,7 +246,7 @@ parseArg:
|
|||||||
ld de, 0 ; in first pass, return a clean zero
|
ld de, 0 ; in first pass, return a clean zero
|
||||||
call zasmIsFirstPass
|
call zasmIsFirstPass
|
||||||
ret z
|
ret z
|
||||||
jp parseExprDE
|
jp parseExpr
|
||||||
|
|
||||||
; Returns, with Z, whether A is a groupId
|
; Returns, with Z, whether A is a groupId
|
||||||
isGroupId:
|
isGroupId:
|
||||||
|
@ -52,14 +52,14 @@ test:
|
|||||||
|
|
||||||
; Old-style tests, not touching them now.
|
; Old-style tests, not touching them now.
|
||||||
ld hl, s1
|
ld hl, s1
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 4
|
ld hl, 4
|
||||||
call assertEQW
|
call assertEQW
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
ld hl, s2
|
ld hl, s2
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 0x4023
|
ld hl, 0x4023
|
||||||
call assertEQW
|
call assertEQW
|
||||||
@ -77,28 +77,28 @@ test:
|
|||||||
jp nz, fail
|
jp nz, fail
|
||||||
|
|
||||||
ld hl, s3
|
ld hl, s3
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 0x4020
|
ld hl, 0x4020
|
||||||
call assertEQW
|
call assertEQW
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
ld hl, s4
|
ld hl, s4
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 0x60
|
ld hl, 0x60
|
||||||
call assertEQW
|
call assertEQW
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
ld hl, s5
|
ld hl, s5
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 0x3ffd
|
ld hl, 0x3ffd
|
||||||
call assertEQW
|
call assertEQW
|
||||||
call nexttest
|
call nexttest
|
||||||
|
|
||||||
ld hl, s6
|
ld hl, s6
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld hl, 0x4080
|
ld hl, 0x4080
|
||||||
call assertEQW
|
call assertEQW
|
||||||
@ -132,7 +132,7 @@ testParseExpr:
|
|||||||
.testEQ:
|
.testEQ:
|
||||||
push iy \ pop hl
|
push iy \ pop hl
|
||||||
inc hl \ inc hl
|
inc hl \ inc hl
|
||||||
call parseExprDE
|
call parseExpr
|
||||||
call assertZ
|
call assertZ
|
||||||
ld l, (iy)
|
ld l, (iy)
|
||||||
ld h, (iy+1)
|
ld h, (iy+1)
|
||||||
|
Loading…
Reference in New Issue
Block a user