zasm: refactoring
This commit is contained in:
parent
2c0166814f
commit
7972b92be1
@ -123,9 +123,23 @@ parseLine:
|
|||||||
cp TOK_LABEL
|
cp TOK_LABEL
|
||||||
jr z, .label
|
jr z, .label
|
||||||
cp TOK_EMPTY
|
cp TOK_EMPTY
|
||||||
jr z, .success ; empty line? do nothing but don't error out.
|
jr .end ; Z is correct. If empty, Z is set and not an
|
||||||
jr .error ; token not supported
|
; error, otherwise, it means bad token and
|
||||||
|
; errors out.
|
||||||
.instr:
|
.instr:
|
||||||
|
call _parseInstr
|
||||||
|
jr .end ; Z is correct
|
||||||
|
.direc:
|
||||||
|
call _parseDirec
|
||||||
|
jr .end ; Z is correct
|
||||||
|
.label:
|
||||||
|
call _parseLabel
|
||||||
|
; Continue to .end, Z has proper value
|
||||||
|
.end:
|
||||||
|
pop bc
|
||||||
|
ret
|
||||||
|
|
||||||
|
_parseInstr:
|
||||||
ld a, c ; I_*
|
ld a, c ; I_*
|
||||||
call parseInstruction
|
call parseInstruction
|
||||||
or a ; is zero?
|
or a ; is zero?
|
||||||
@ -140,8 +154,15 @@ parseLine:
|
|||||||
call ioPutC
|
call ioPutC
|
||||||
inc hl
|
inc hl
|
||||||
djnz .loopInstr
|
djnz .loopInstr
|
||||||
jr .success
|
; continue to success
|
||||||
.direc:
|
.success:
|
||||||
|
xor a ; ensure Z
|
||||||
|
ret
|
||||||
|
.error:
|
||||||
|
call JUMP_UNSETZ
|
||||||
|
ret
|
||||||
|
|
||||||
|
_parseDirec:
|
||||||
ld a, c ; D_*
|
ld a, c ; D_*
|
||||||
call parseDirective
|
call parseDirective
|
||||||
or a ; cp 0
|
or a ; cp 0
|
||||||
@ -156,8 +177,12 @@ parseLine:
|
|||||||
call ioPutC
|
call ioPutC
|
||||||
inc hl
|
inc hl
|
||||||
djnz .loopDirec
|
djnz .loopDirec
|
||||||
jr .success
|
; continue to success
|
||||||
.label:
|
.success:
|
||||||
|
xor a ; ensure Z
|
||||||
|
ret
|
||||||
|
|
||||||
|
_parseLabel:
|
||||||
; The string in (scratchpad) is a label with its trailing ':' removed.
|
; The string in (scratchpad) is a label with its trailing ':' removed.
|
||||||
ex hl, de ; save current HL (end of label) in DE,
|
ex hl, de ; save current HL (end of label) in DE,
|
||||||
; we will need it later
|
; we will need it later
|
||||||
@ -169,10 +194,11 @@ parseLine:
|
|||||||
; When we're not in the first pass, we set the context (if label is not
|
; When we're not in the first pass, we set the context (if label is not
|
||||||
; local) to that label.
|
; local) to that label.
|
||||||
call symIsLabelLocal
|
call symIsLabelLocal
|
||||||
jr z, .success ; local? nothing to do.
|
jr z, .noContext ; local? don't set context
|
||||||
call symSetContext
|
call symSetContext
|
||||||
jr nz, .error ; NZ? this means that (HL) couldn't be
|
jr nz, .error ; NZ? this means that (HL) couldn't be
|
||||||
; found in symbol list. Weird
|
; found in symbol list. Weird
|
||||||
|
.noContext:
|
||||||
; We're finished here. However, because it's a label, it's possible that
|
; We're finished here. However, because it's a label, it's possible that
|
||||||
; another logical line follows directly after the label. Let's parse
|
; another logical line follows directly after the label. Let's parse
|
||||||
; this and propagate error.
|
; this and propagate error.
|
||||||
@ -188,11 +214,9 @@ parseLine:
|
|||||||
; continue to .success
|
; continue to .success
|
||||||
.success:
|
.success:
|
||||||
xor a ; ensure Z
|
xor a ; ensure Z
|
||||||
jr .end
|
ret
|
||||||
.error:
|
.error:
|
||||||
call JUMP_UNSETZ
|
call JUMP_UNSETZ
|
||||||
.end:
|
|
||||||
pop bc
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; *** Variables ***
|
; *** Variables ***
|
||||||
|
Loading…
Reference in New Issue
Block a user