1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 12:58:09 +11:00

zasm: make the instruction table fixed

Looping is easier
This commit is contained in:
Virgil Dupras 2019-04-16 22:46:04 -04:00
parent 8cd400651a
commit 38e40bfc16

View File

@ -3,6 +3,7 @@
; *** Consts *** ; *** Consts ***
ARGSPEC_SINGLE_CNT .equ 7 ARGSPEC_SINGLE_CNT .equ 7
ARGSPEC_TBL_CNT .equ 12 ARGSPEC_TBL_CNT .equ 12
INSTR_TBL_PRIMARYC_CNT .equ 25
; *** Code *** ; *** Code ***
.org USER_CODE .org USER_CODE
@ -229,18 +230,16 @@ matchPrimaryRow:
parseLine: parseLine:
call readLine call readLine
push de push de
ld de, instTBlPrimary ld de, instrTBlPrimaryC
ld b, INSTR_TBL_PRIMARYC_CNT
.loop: .loop:
ld a, (de) ld a, (de)
cp 0
jr z, .nomatch ; we reached last entry
call matchPrimaryRow call matchPrimaryRow
jr z, .match jr z, .match
ld a, 7 ld a, 7
call JUMP_ADDDE call JUMP_ADDDE
jr .loop djnz .loop
; no match
.nomatch:
xor a xor a
pop de pop de
ret ret
@ -283,7 +282,7 @@ argspecTbl:
; 1 byte for arg constant ; 1 byte for arg constant
; 1 byte for 2nd arg constant ; 1 byte for 2nd arg constant
; 1 byte for upcode ; 1 byte for upcode
instTBlPrimary: instrTBlPrimaryC:
.db "ADD", 0, 'A', 'h', 0x86 ; ADD A, HL .db "ADD", 0, 'A', 'h', 0x86 ; ADD A, HL
.db "CCF", 0, 0, 0, 0x3f ; CCF .db "CCF", 0, 0, 0, 0x3f ; CCF
.db "CPL", 0, 0, 0, 0x2f ; CPL .db "CPL", 0, 0, 0, 0x2f ; CPL
@ -309,7 +308,6 @@ instTBlPrimary:
.db "RRA", 0, 0, 0, 0x1f ; RRA .db "RRA", 0, 0, 0, 0x1f ; RRA
.db "RRCA", 0, 0, 0x0f ; RRCA .db "RRCA", 0, 0, 0x0f ; RRCA
.db "SCF", 0, 0, 0, 0x37 ; SCF .db "SCF", 0, 0, 0, 0x37 ; SCF
.db 0
; *** Variables *** ; *** Variables ***
; enough space for 4 chars and a null ; enough space for 4 chars and a null