zasm: make instr unt write directly to ioPutC

Couldn't get rid of instrUpcode though, too complicated.
This commit is contained in:
Virgil Dupras 2019-05-17 15:35:49 -04:00
parent 26d6dd1912
commit b0318f4891
2 changed files with 16 additions and 22 deletions

View File

@ -381,7 +381,7 @@ handleJPIXY:
ld c, 2 ld c, 2
ret ret
.error: .error:
xor c ld c, 0
ret ret
; Handle the first argument of BIT. Sets Z if first argument is valid, unset it ; Handle the first argument of BIT. Sets Z if first argument is valid, unset it
@ -394,7 +394,7 @@ handleBIT:
cp a ; ensure Z cp a ; ensure Z
ret ret
.error: .error:
xor c ld c, 0
call unsetZ call unsetZ
ret ret
@ -733,8 +733,8 @@ processArg:
ret ret
; Parse instruction specified in A (I_* const) with args in I/O and write ; Parse instruction specified in A (I_* const) with args in I/O and write
; resulting opcode(s) in (instrUpcode). Returns the number of bytes written in ; resulting opcode(s) in I/O.
; A. ; Sets Z on success.
parseInstruction: parseInstruction:
push bc push bc
push hl push hl
@ -775,9 +775,19 @@ parseInstruction:
; We have our matching instruction row. We're getting pretty near our ; We have our matching instruction row. We're getting pretty near our
; goal here! ; goal here!
call getUpcode call getUpcode
or a ; is zero?
jr z, .error
ld b, a ; save output byte count
ld hl, instrUpcode
.loopWrite:
ld a, (hl)
call ioPutC
inc hl
djnz .loopWrite
cp a ; ensure Z
jr .end jr .end
.error: .error:
xor a call unsetZ
.end: .end:
pop de pop de
pop hl pop hl

View File

@ -150,23 +150,7 @@ parseLine:
_parseInstr: _parseInstr:
ld a, c ; I_* ld a, c ; I_*
call parseInstruction jp parseInstruction
or a ; is zero?
jr z, .error
ld b, a ; save output byte count
ld hl, instrUpcode
.loopInstr:
ld a, (hl)
call ioPutC
inc hl
djnz .loopInstr
; continue to success
.success:
xor a ; ensure Z
ret
.error:
call unsetZ
ret
_parseDirec: _parseDirec:
ld a, c ; D_* ld a, c ; D_*