From cc754e12aaa5d433fbfb275eb06ad47d713c46e9 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 23 Dec 2019 15:59:55 -0500 Subject: [PATCH] parseExpr --> parseExprDE: easy ones Those replacements were trivially equivalent. For the other ones, an examination of the context is necessary. --- apps/basic/main.asm | 10 ++++------ apps/basic/parse.asm | 6 ++---- apps/basic/var.asm | 3 +-- apps/zasm/avr.asm | 7 +++---- apps/zasm/directive.asm | 3 +-- 5 files changed, 11 insertions(+), 18 deletions(-) diff --git a/apps/basic/main.asm b/apps/basic/main.asm index a1f8ef2..5317513 100644 --- a/apps/basic/main.asm +++ b/apps/basic/main.asm @@ -222,9 +222,8 @@ basPRINT: call rdWord push hl ; --> lvl 1 ex de, hl - call parseExpr + call parseExprDE jr nz, .parseError - push ix \ pop de ld hl, SCRATCHPAD call fmtDecimalS call printstr @@ -252,9 +251,8 @@ basGOTO: ld de, SCRATCHPAD call rdWord ex de, hl - call parseExpr + call parseExprDE ret nz - push ix \ pop de call bufFind jr nz, .notFound push ix \ pop de @@ -316,8 +314,8 @@ basINPUT: call spitQuoted call rdSep call stdioReadLine - call parseExpr - ld (VAR_TBL), ix + call parseExprDE + ld (VAR_TBL), de call printcrlf cp a ; ensure Z ret diff --git a/apps/basic/parse.asm b/apps/basic/parse.asm index 11703e9..38b2583 100644 --- a/apps/basic/parse.asm +++ b/apps/basic/parse.asm @@ -40,9 +40,8 @@ parseTruth: ret .simple: - call parseExpr + call parseExprDE jr nz, .end - push ix \ pop de ld a, d or e jr .success @@ -136,8 +135,7 @@ parseTruth: ret nz push ix ; --> lvl 1. save (HL) value in stack. ex de, hl - call parseExpr + call parseExprDE ret nz - push ix \ pop de pop hl ; <-- lvl 1. restore. ret diff --git a/apps/basic/var.asm b/apps/basic/var.asm index 085e420..a6f7af6 100644 --- a/apps/basic/var.asm +++ b/apps/basic/var.asm @@ -52,10 +52,9 @@ varTryAssign: call rdWord ex de, hl ; Now, evaluate that expression now in (HL) - call parseExpr ; --> number in IX + call parseExprDE ; --> number in DE jr nz, .exprErr pop af ; <-- lvl 4 - push ix \ pop de ; send number to DE call varAssign xor a ; ensure Z .end: diff --git a/apps/zasm/avr.asm b/apps/zasm/avr.asm index 3a4df82..13aaa9e 100644 --- a/apps/zasm/avr.asm +++ b/apps/zasm/avr.asm @@ -657,19 +657,18 @@ _readk7: push hl push de push ix - call parseExpr + call parseExprDE jr nz, .end ; If we're in first pass, stop now. The value of HL doesn't matter and ; truncation checks might falsely fail. call zasmIsFirstPass jr z, .end - ; IX contains an absolute value. Turn this into a -64/+63 relative + ; DE contains an absolute value. Turn this into a -64/+63 relative ; value by subtracting PC from it. However, before we do that, let's ; add 0x7f to it, which we'll remove later. This will simplify bounds ; checks. (we use 7f instead of 3f because we deal in bytes here, not ; in words) - push ix \ pop hl - ld de, 0x7f + ld hl, 0x7f add hl, de ; Carry cleared ex de, hl call zasmGetPC ; --> HL diff --git a/apps/zasm/directive.asm b/apps/zasm/directive.asm index e796900..0b5da5d 100644 --- a/apps/zasm/directive.asm +++ b/apps/zasm/directive.asm @@ -146,10 +146,9 @@ handleEQU: call readWord jr nz, .badfmt ld hl, scratchpad - call parseExpr + call parseExprDE jr nz, .badarg ld hl, DIREC_SCRATCHPAD - push ix \ pop de ; Save value in "@" special variable ld (DIREC_LASTVAL), de call symRegisterConst ; A and Z set