Browse Source

zasm: add support for "$" symbol

Allows for the ".fill x-$" pattern.
pull/10/head
Virgil Dupras 5 years ago
parent
commit
e18f9b53a9
7 changed files with 25 additions and 3 deletions
  1. +16
    -1
      apps/zasm/parse.asm
  2. +1
    -1
      tools/emul/user.h
  3. BIN
      tools/emul/zasm/zasm.bin
  4. +3
    -0
      tools/tests/unit/test_expr.asm
  5. +3
    -0
      tools/tests/unit/test_parse.asm
  6. +1
    -0
      tools/tests/unit/test_parse_z.asm
  7. +1
    -1
      tools/tests/zasm/test1.asm

+ 16
- 1
apps/zasm/parse.asm View File

@@ -226,7 +226,13 @@ parseLiteral:
parseNumberOrSymbol:
call parseLiteral
ret z
; Not a number. Try symbol
; Not a number. Try PC
push de
ld de, .sDollar
call strcmp
pop de
jr z, .returnPC
; Not PC either, try symbol
call symSelect
call symFind
jr nz, .notfound
@@ -244,3 +250,12 @@ parseNumberOrSymbol:
; Otherwise return error. Z is already unset, so in fact, this is the
; same as jumping to zasmIsFirstPass
jp zasmIsFirstPass

.returnPC:
push hl
call zasmGetPC
push hl \ pop ix
pop hl
ret
.sDollar:
.db '$', 0

+ 1
- 1
tools/emul/user.h View File

@@ -1,5 +1,5 @@
.equ USER_CODE 0x4800
.equ USER_RAMSTART 0x5800
.equ USER_RAMSTART 0x6000
.equ FS_HANDLE_SIZE 8

; *** JUMP TABLE ***


BIN
tools/emul/zasm/zasm.bin View File


+ 3
- 0
tools/tests/unit/test_expr.asm View File

@@ -13,6 +13,9 @@ jp test
zasmIsFirstPass:
jp unsetZ

zasmGetPC:
ret

testNum: .db 1

s1: .db "2+2", 0


+ 3
- 0
tools/tests/unit/test_parse.asm View File

@@ -3,6 +3,9 @@ jp test
#include "core.asm"
#include "parse.asm"

zasmGetPC:
ret

testNum: .db 1

sFoo: .db "Foo", 0


+ 1
- 0
tools/tests/unit/test_parse_z.asm View File

@@ -6,6 +6,7 @@ jp test
#include "zasm/parse.asm"

; mocks. aren't used in tests
zasmGetPC:
zasmIsFirstPass:
symSelect:
symFind:


+ 1
- 1
tools/tests/zasm/test1.asm View File

@@ -27,4 +27,4 @@ label2: .dw 0x42
rlc c
cp '-'
sbc hl, de
.fill 0x10
.fill 0x50-$

Loading…
Cancel
Save