mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 01:18:06 +11:00
zasm: add a bunch of instructions
This commit is contained in:
parent
76caf944dd
commit
8ce528c752
@ -4,7 +4,7 @@
|
|||||||
; Number of rows in the argspec table
|
; Number of rows in the argspec table
|
||||||
ARGSPEC_TBL_CNT .equ 27
|
ARGSPEC_TBL_CNT .equ 27
|
||||||
; Number of rows in the primary instructions table
|
; Number of rows in the primary instructions table
|
||||||
INSTR_TBLP_CNT .equ 64
|
INSTR_TBLP_CNT .equ 74
|
||||||
; size in bytes of each row in the primary instructions table
|
; size in bytes of each row in the primary instructions table
|
||||||
INSTR_TBLP_ROWSIZE .equ 8
|
INSTR_TBLP_ROWSIZE .equ 8
|
||||||
|
|
||||||
@ -167,11 +167,12 @@ isSepOrLineEnd:
|
|||||||
call isLineEnd
|
call isLineEnd
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; read word in (HL) and put it in (DE), null terminated. A is the read
|
; read word in (HL) and put it in (DE), null terminated, for a maximum of A
|
||||||
; length. HL is advanced to the next separator char.
|
; characters. As a result, A is the read length. HL is advanced to the next
|
||||||
|
; separator char.
|
||||||
readWord:
|
readWord:
|
||||||
push bc
|
push bc
|
||||||
ld b, 4
|
ld b, a
|
||||||
.loop:
|
.loop:
|
||||||
ld a, (hl)
|
ld a, (hl)
|
||||||
call isSepOrLineEnd
|
call isSepOrLineEnd
|
||||||
@ -222,6 +223,7 @@ toWord:
|
|||||||
readArg:
|
readArg:
|
||||||
push de
|
push de
|
||||||
ld de, tmpBuf
|
ld de, tmpBuf
|
||||||
|
ld a, 6
|
||||||
call readWord
|
call readWord
|
||||||
push hl
|
push hl
|
||||||
ld hl, tmpBuf
|
ld hl, tmpBuf
|
||||||
@ -250,6 +252,7 @@ readLine:
|
|||||||
ld (curArg1), a
|
ld (curArg1), a
|
||||||
ld (curArg2), a
|
ld (curArg2), a
|
||||||
ld de, curWord
|
ld de, curWord
|
||||||
|
ld a, 4
|
||||||
call readWord
|
call readWord
|
||||||
call toWord
|
call toWord
|
||||||
jr nz, .end
|
jr nz, .end
|
||||||
@ -426,15 +429,15 @@ matchArg:
|
|||||||
ret z
|
ret z
|
||||||
; not an exact match, let's check for numerical constants.
|
; not an exact match, let's check for numerical constants.
|
||||||
call JUMP_UPCASE
|
call JUMP_UPCASE
|
||||||
cp 'N'
|
call checkNOrM
|
||||||
jr z, .expectsNumber
|
|
||||||
cp 'M'
|
|
||||||
jr z, .expectsNumber
|
jr z, .expectsNumber
|
||||||
jr .notNumber
|
jr .notNumber
|
||||||
.expectsNumber:
|
.expectsNumber:
|
||||||
ld a, (hl)
|
; Our argument is a number N or M. Never a lower-case version. At this
|
||||||
call checkNOrM ; In parsed arg, we don't have 'n' or 'm', only
|
; point in the processing, we don't care about whether N or M is upper,
|
||||||
; 'N' and 'M'
|
; we do truncation tests later. So, let's just perform the same == test
|
||||||
|
; but in a case-insensitive way instead
|
||||||
|
cp a, (hl)
|
||||||
ret ; whether we match or not, the result of Z is
|
ret ; whether we match or not, the result of Z is
|
||||||
; the good one.
|
; the good one.
|
||||||
.notNumber:
|
.notNumber:
|
||||||
@ -702,16 +705,22 @@ argGrpABCDEHL:
|
|||||||
; decreased by 2 (djnz, jr).
|
; decreased by 2 (djnz, jr).
|
||||||
|
|
||||||
instrTBlPrimary:
|
instrTBlPrimary:
|
||||||
|
.db "ADC", 0, 'A', 'h', 0, 0x8e ; ADC A, HL
|
||||||
|
.db "ADC", 0, 'A', 0xb, 0, 0b10001000 ; ADC A, r
|
||||||
|
.db "ADC", 0, 'A', 'n', 0, 0xce ; ADC A, n
|
||||||
.db "ADD", 0, 'A', 'h', 0, 0x86 ; ADD A, HL
|
.db "ADD", 0, 'A', 'h', 0, 0x86 ; ADD A, HL
|
||||||
.db "ADD", 0, 'A', 0xb, 0, 0b10000000 ; ADD A, r
|
.db "ADD", 0, 'A', 0xb, 0, 0b10000000 ; ADD A, r
|
||||||
.db "ADD", 0, 'A', 'n', 0, 0xc6 ; ADD A, n
|
.db "ADD", 0, 'A', 'n', 0, 0xc6 ; ADD A, n
|
||||||
.db "ADC", 0, 'A', 'h', 0, 0x8e ; ADC A, HL
|
.db "ADD", 0, 'h', 0x3, 4, 0b00001001 ; ADD HL, ss
|
||||||
.db "ADC", 0, 'A', 0xb, 0, 0b10001000 ; ADC A, r
|
|
||||||
.db "AND", 0, 'l', 0, 0, 0xa6 ; AND (HL)
|
.db "AND", 0, 'l', 0, 0, 0xa6 ; AND (HL)
|
||||||
.db "AND", 0, 0xa, 0, 0, 0b10100000 ; AND r
|
.db "AND", 0, 0xa, 0, 0, 0b10100000 ; AND r
|
||||||
|
.db "AND", 0, 'n', 0, 0, 0xe6 ; AND n
|
||||||
|
.db "CALL", 0xa, 'N', 3, 0b11000100 ; CALL cc, NN
|
||||||
|
.db "CALL", 'N', 0, 0, 0xcd ; CALL NN
|
||||||
.db "CCF", 0, 0, 0, 0, 0x3f ; CCF
|
.db "CCF", 0, 0, 0, 0, 0x3f ; CCF
|
||||||
.db "CP",0,0, 'l', 0, 0, 0xbe ; CP (HL)
|
.db "CP",0,0, 'l', 0, 0, 0xbe ; CP (HL)
|
||||||
.db "CP",0,0, 0xb, 0, 0, 0b10111000 ; CP r
|
.db "CP",0,0, 0xb, 0, 0, 0b10111000 ; CP r
|
||||||
|
.db "CP",0,0, 'n', 0, 0, 0xfe ; CP n
|
||||||
.db "CPL", 0, 0, 0, 0, 0x2f ; CPL
|
.db "CPL", 0, 0, 0, 0, 0x2f ; CPL
|
||||||
.db "DAA", 0, 0, 0, 0, 0x27 ; DAA
|
.db "DAA", 0, 0, 0, 0, 0x27 ; DAA
|
||||||
.db "DI",0,0, 0, 0, 0, 0xf3 ; DI
|
.db "DI",0,0, 0, 0, 0, 0xf3 ; DI
|
||||||
@ -746,6 +755,10 @@ instrTBlPrimary:
|
|||||||
.db "LD",0,0, 'l', 'n', 0, 0x36 ; LD (HL), n
|
.db "LD",0,0, 'l', 'n', 0, 0x36 ; LD (HL), n
|
||||||
.db "LD",0,0, 0xb, 'n', 3, 0b00000110 ; LD r, (HL)
|
.db "LD",0,0, 0xb, 'n', 3, 0b00000110 ; LD r, (HL)
|
||||||
.db "LD",0,0, 0x3, 'N', 4, 0b00000001 ; LD dd, n
|
.db "LD",0,0, 0x3, 'N', 4, 0b00000001 ; LD dd, n
|
||||||
|
.db "LD",0,0, 'M', 'A', 0, 0x32 ; LD (NN), A
|
||||||
|
.db "LD",0,0, 'A', 'M', 0, 0x3a ; LD A, (NN)
|
||||||
|
.db "LD",0,0, 'M', 'h', 0, 0x22 ; LD (NN), HL
|
||||||
|
.db "LD",0,0, 'h', 'M', 0, 0x2a ; LD HL, (NN)
|
||||||
.db "NOP", 0, 0, 0, 0, 0x00 ; NOP
|
.db "NOP", 0, 0, 0, 0, 0x00 ; NOP
|
||||||
.db "OR",0,0, 'l', 0, 0, 0xb6 ; OR (HL)
|
.db "OR",0,0, 'l', 0, 0, 0xb6 ; OR (HL)
|
||||||
.db "OR",0,0, 0xb, 0, 0, 0b10110000 ; OR r
|
.db "OR",0,0, 0xb, 0, 0, 0b10110000 ; OR r
|
||||||
|
Loading…
Reference in New Issue
Block a user