zasm: rename curOutputOffset to ZASM_PC

This commit is contained in:
Virgil Dupras 2019-05-15 13:31:49 -04:00
parent a994867a86
commit 33a1ee250d
2 changed files with 11 additions and 14 deletions

View File

@ -632,7 +632,7 @@ getUpcode:
bit 7, (ix+3) bit 7, (ix+3)
jr z, .absoluteValue ; bit not set? regular byte value, jr z, .absoluteValue ; bit not set? regular byte value,
; Our argument is a relative address ("e" type in djnz and jr). We have ; Our argument is a relative address ("e" type in djnz and jr). We have
; to subtract (curOutputOffset) from it. ; to subtract (ZASM_PC) from it.
; First, check whether we're on first pass. If we are, skip processing ; First, check whether we're on first pass. If we are, skip processing
; below because not having real symbol value makes relative address ; below because not having real symbol value makes relative address
@ -643,7 +643,7 @@ getUpcode:
; We're on second pass ; We're on second pass
push de ; Don't let go of this, that's our dest push de ; Don't let go of this, that's our dest
ld de, (curOutputOffset) ld de, (ZASM_PC)
call JUMP_INTOHL call JUMP_INTOHL
dec hl ; what we write is "e-2" dec hl ; what we write is "e-2"
dec hl dec hl

View File

@ -37,7 +37,9 @@
; that when we parse instructions and directive that error out because of a ; that when we parse instructions and directive that error out because of a
; missing symbol, we don't error out and just write down a dummy value. ; missing symbol, we don't error out and just write down a dummy value.
.equ ZASM_FIRST_PASS RAMSTART .equ ZASM_FIRST_PASS RAMSTART
.equ ZASM_RAMEND ZASM_FIRST_PASS+1 ; The offset where we currently are with regards to outputting opcodes
.equ ZASM_PC ZASM_FIRST_PASS+1
.equ ZASM_RAMEND ZASM_PC+2
; *** Code *** ; *** Code ***
jp zasmMain jp zasmMain
@ -85,12 +87,12 @@ zasmIsFirstPass:
cp 1 cp 1
ret ret
; Increase (curOutputOffset) by A ; Increase (ZASM_PC) by A
incOutputOffset: incOutputOffset:
push de push de
ld de, (curOutputOffset) ld de, (ZASM_PC)
call JUMP_ADDDE call JUMP_ADDDE
ld (curOutputOffset), de ld (ZASM_PC), de
pop de pop de
ret ret
@ -99,7 +101,7 @@ incOutputOffset:
; be read (first line is 1). ; be read (first line is 1).
zasmParseFile: zasmParseFile:
ld de, 0 ld de, 0
ld (curOutputOffset), de ld (ZASM_PC), de
.loop: .loop:
inc de inc de
call ioReadLine call ioReadLine
@ -110,7 +112,7 @@ zasmParseFile:
jr .loop jr .loop
; Parse line in (HL), write the resulting opcode(s) through ioPutC and increases ; Parse line in (HL), write the resulting opcode(s) through ioPutC and increases
; (curOutputOffset) by the number of bytes written. ; (ZASM_PC) by the number of bytes written.
; Sets Z if parse was successful, unset if there was an error or EOF. ; Sets Z if parse was successful, unset if there was an error or EOF.
parseLine: parseLine:
push bc push bc
@ -208,7 +210,7 @@ _parseLabel:
; NZ? this means that (HL) couldn't be found in symbol list. Weird ; NZ? this means that (HL) couldn't be found in symbol list. Weird
jr .error jr .error
.registerLabel: .registerLabel:
ld de, (curOutputOffset) ld de, (ZASM_PC)
call symRegister call symRegister
jr nz, .error jr nz, .error
; continue to .success ; continue to .success
@ -218,8 +220,3 @@ _parseLabel:
.error: .error:
call JUMP_UNSETZ call JUMP_UNSETZ
ret ret
; *** Variables ***
; The offset where we currently are with regards to outputting opcodes
curOutputOffset:
.fill 2