diff --git a/apps/zasm/directive.asm b/apps/zasm/directive.asm index 9c42901..8d4c8da 100644 --- a/apps/zasm/directive.asm +++ b/apps/zasm/directive.asm @@ -118,6 +118,7 @@ handleFIL: call ioPutC djnz .loop pop bc + ret handleINC: call readWord diff --git a/apps/zasm/expr.asm b/apps/zasm/expr.asm index 2b315fc..958af50 100644 --- a/apps/zasm/expr.asm +++ b/apps/zasm/expr.asm @@ -2,11 +2,6 @@ ; We expect (HL) to be disposable: we mutate it to avoid having to make a copy. ; Sets Z on success, unset on error. parseExpr: - ; Before we evaluate an expression, we first try for a regular number or - ; symbol. We do this because parsing expressions can mess up some values - ; with its splitting logic. For example '-' is going to end up '\0'. - call parseNumberOrSymbol - ret z push de push hl call _parseExpr @@ -24,7 +19,7 @@ _parseExpr: ld a, '*' call _findAndSplit jp z, _applyMult - ret ; failure + jp parseNumberOrSymbol ; Given a string in (HL) and a separator char in A, return a splitted string, ; that is, the same (HL) string but with the found A char replaced by a null @@ -32,6 +27,7 @@ _parseExpr: ; Sets Z if found, unset if not found. _findAndSplit: push hl + call .skipCharLiteral call findchar jr nz, .end ; nothing found ; Alright, we have our char and we're pointing at it. Let's replace it @@ -45,6 +41,27 @@ _findAndSplit: pop hl ; HL is back to the start ret +.skipCharLiteral: + ; special case: if our first char is ', skip the first 3 characters + ; so that we don't mistake a literal for an iterator + push af + ld a, (hl) + cp 0x27 ; ' + jr nz, .skipCharLiteralEnd ; not a ' + xor a ; check for null char during skipping + ; skip 3 + inc hl + cp (hl) + jr z, .skipCharLiteralEnd + inc hl + cp (hl) + jr z, .skipCharLiteralEnd + inc hl +.skipCharLiteralEnd: + pop af + ret +.find: + ; parse expression on the left (HL) and the right (DE) and put the results in ; DE (left) and IX (right) _resolveLeftAndRight: diff --git a/tools/emul/zasm/zasm.bin b/tools/emul/zasm/zasm.bin index f842fac..162e76e 100644 Binary files a/tools/emul/zasm/zasm.bin and b/tools/emul/zasm/zasm.bin differ