1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-26 10:38:07 +11:00

Compare commits

..

No commits in common. "518df7a05e8aba8e5cd899903b28b4dd37decdf6" and "17cc28e211aadf5cbb33e5145307819588ee1b54" have entirely different histories.

4 changed files with 12 additions and 21 deletions

View File

@ -20,6 +20,7 @@
; *** Requirements *** ; *** Requirements ***
; strncmp ; strncmp
; addDE ; addDE
; addHL
; upcase ; upcase
; unsetZ ; unsetZ
; intoDE ; intoDE
@ -33,6 +34,7 @@
; fsFindFN ; fsFindFN
; fsOpen ; fsOpen
; fsGetB ; fsGetB
; cpHLDE
; parseArgs ; parseArgs
; _blkGetB ; _blkGetB
; _blkPutB ; _blkPutB

View File

@ -1,6 +1,8 @@
; *** Consts *** ; *** Consts ***
; Number of rows in the argspec table ; Number of rows in the argspec table
.equ ARGSPEC_TBL_CNT 33 .equ ARGSPEC_TBL_CNT 33
; Number of rows in the primary instructions table
.equ INSTR_TBL_CNT 147
; size in bytes of each row in the primary instructions table ; size in bytes of each row in the primary instructions table
.equ INSTR_TBL_ROWSIZE 6 .equ INSTR_TBL_ROWSIZE 6
; Instruction IDs They correspond to the index of the table in instrNames ; Instruction IDs They correspond to the index of the table in instrNames
@ -871,28 +873,15 @@ parseInstruction:
jr nz, .error ; A is set to error jr nz, .error ; A is set to error
.nomorearg: .nomorearg:
; Parsing done, no error, let's move forward to instr row matching! ; Parsing done, no error, let's move forward to instr row matching!
; To speed up things a little, we use a poor man's indexing. Full
; bisecting would involve too much complexity.
ld a, c ; recall A param
ld de, instrTBl ld de, instrTBl
cp I_EX ld b, INSTR_TBL_CNT
jr c, .loop
ld de, instrTBlEX
cp I_LD
jr c, .loop
ld de, instrTBlLD
cp I_RET
jr c, .loop
ld de, instrTBlRET
.loop: .loop:
ld a, c ; recall A param ld a, c ; recall A param
call matchPrimaryRow call matchPrimaryRow
jr z, .match jr z, .match
ld a, INSTR_TBL_ROWSIZE ld a, INSTR_TBL_ROWSIZE
call addDE call addDE
ld a, (de) djnz .loop
cp 0xff
jr nz, .loop
; No signature match ; No signature match
ld a, ERR_BAD_ARG ld a, ERR_BAD_ARG
jr .error jr .error
@ -1077,7 +1066,6 @@ instrNames:
; custom code. ; custom code.
; Bit 4: When in an 'l' argspec, this means "I accept IX and IY variants". ; Bit 4: When in an 'l' argspec, this means "I accept IX and IY variants".
; This table needs to be kept in ascending order of I_* value.
instrTBl: instrTBl:
.db I_ADC, 'A', 'l', 0, 0x8e , 0 ; ADC A, (HL) .db I_ADC, 'A', 'l', 0, 0x8e , 0 ; ADC A, (HL)
.db I_ADC, 'A', 0xb, 0, 0b10001000 , 0 ; ADC A, r .db I_ADC, 'A', 0xb, 0, 0b10001000 , 0 ; ADC A, r
@ -1114,7 +1102,6 @@ instrTBl:
.db I_DI, 0, 0, 0, 0xf3 , 0 ; DI .db I_DI, 0, 0, 0, 0xf3 , 0 ; DI
.db I_DJNZ,'n', 0, 0x80, 0x10 , 0 ; DJNZ e .db I_DJNZ,'n', 0, 0x80, 0x10 , 0 ; DJNZ e
.db I_EI, 0, 0, 0, 0xfb , 0 ; EI .db I_EI, 0, 0, 0, 0xfb , 0 ; EI
instrTBlEX:
.db I_EX, 'p', 'h', 0, 0xe3 , 0 ; EX (SP), HL .db I_EX, 'p', 'h', 0, 0xe3 , 0 ; EX (SP), HL
.db I_EX, 'p', 'X', 0, 0xdd, 0xe3 ; EX (SP), IX .db I_EX, 'p', 'X', 0, 0xdd, 0xe3 ; EX (SP), IX
.db I_EX, 'p', 'Y', 0, 0xfd, 0xe3 ; EX (SP), IY .db I_EX, 'p', 'Y', 0, 0xfd, 0xe3 ; EX (SP), IY
@ -1144,7 +1131,6 @@ instrTBlEX:
.db I_JR, '=', 'n', 0x80, 0x30 , 0 ; JR NC, e .db I_JR, '=', 'n', 0x80, 0x30 , 0 ; JR NC, e
.db I_JR, 'Z', 'n', 0x80, 0x28 , 0 ; JR Z, e .db I_JR, 'Z', 'n', 0x80, 0x28 , 0 ; JR Z, e
.db I_JR, 'z', 'n', 0x80, 0x20 , 0 ; JR NZ, e .db I_JR, 'z', 'n', 0x80, 0x20 , 0 ; JR NZ, e
instrTBlLD:
.db I_LD, 'c', 'A', 0, 0x02 , 0 ; LD (BC), A .db I_LD, 'c', 'A', 0, 0x02 , 0 ; LD (BC), A
.db I_LD, 'e', 'A', 0, 0x12 , 0 ; LD (DE), A .db I_LD, 'e', 'A', 0, 0x12 , 0 ; LD (DE), A
.db I_LD, 'A', 'c', 0, 0x0a , 0 ; LD A, (BC) .db I_LD, 'A', 'c', 0, 0x0a , 0 ; LD A, (BC)
@ -1199,7 +1185,6 @@ instrTBlLD:
.db I_PUSH,0x1, 0, 4, 0b11000101 , 0 ; PUSH qq .db I_PUSH,0x1, 0, 4, 0b11000101 , 0 ; PUSH qq
.db I_RES, 0xc, 'l', 0x53, 0xcb, 0b10000110 ; RES b, (HL) + (IX/Y) .db I_RES, 0xc, 'l', 0x53, 0xcb, 0b10000110 ; RES b, (HL) + (IX/Y)
.db I_RES, 0xc, 0xb, 0x20 \ .dw handleRESR ; RES b, r .db I_RES, 0xc, 0xb, 0x20 \ .dw handleRESR ; RES b, r
instrTBlRET:
.db I_RET, 0, 0, 0, 0xc9 , 0 ; RET .db I_RET, 0, 0, 0, 0xc9 , 0 ; RET
.db I_RET, 0xa, 0, 3, 0b11000000 , 0 ; RET cc .db I_RET, 0xa, 0, 3, 0b11000000 , 0 ; RET cc
.db I_RETI,0, 0, 0, 0xed, 0x4d ; RETI .db I_RETI,0, 0, 0, 0xed, 0x4d ; RETI
@ -1229,4 +1214,3 @@ instrTBlRET:
.db I_XOR, 'l', 0, 0, 0xae , 0 ; XOR (HL) .db I_XOR, 'l', 0, 0, 0xae , 0 ; XOR (HL)
.db I_XOR, 0xb, 0, 0, 0b10101000 , 0 ; XOR r .db I_XOR, 0xb, 0, 0, 0b10101000 , 0 ; XOR r
.db I_XOR, 'n', 0, 0, 0xee , 0 ; XOR n .db I_XOR, 'n', 0, 0, 0xee , 0 ; XOR n
.db 0xff

View File

@ -11,6 +11,7 @@ jp init ; 3 bytes
; *** JUMP TABLE *** ; *** JUMP TABLE ***
jp strncmp jp strncmp
jp addDE jp addDE
jp addHL
jp upcase jp upcase
jp unsetZ jp unsetZ
jp intoDE jp intoDE
@ -24,6 +25,7 @@ jp blkSet
jp fsFindFN jp fsFindFN
jp fsOpen jp fsOpen
jp fsGetB jp fsGetB
jp cpHLDE
jp parseArgs jp parseArgs
jp _blkGetB jp _blkGetB
jp _blkPutB jp _blkPutB
@ -81,7 +83,8 @@ emulGetB:
cp a ; ensure z cp a ; ensure z
ret ret
.eof: .eof:
jp unsetZ call unsetZ
ret
emulPutB: emulPutB:
out (STDIO_PORT), a out (STDIO_PORT), a

View File

@ -6,6 +6,7 @@
; *** JUMP TABLE *** ; *** JUMP TABLE ***
.equ strncmp 0x03 .equ strncmp 0x03
.equ addDE @+3 .equ addDE @+3
.equ addHL @+3
.equ upcase @+3 .equ upcase @+3
.equ unsetZ @+3 .equ unsetZ @+3
.equ intoDE @+3 .equ intoDE @+3
@ -19,6 +20,7 @@
.equ fsFindFN @+3 .equ fsFindFN @+3
.equ fsOpen @+3 .equ fsOpen @+3
.equ fsGetB @+3 .equ fsGetB @+3
.equ cpHLDE @+3
.equ parseArgs @+3 .equ parseArgs @+3
.equ _blkGetB @+3 .equ _blkGetB @+3
.equ _blkPutB @+3 .equ _blkPutB @+3