From 89972ca2109ff030247ce4ae98c5c7d862cc8a62 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Sat, 20 Apr 2019 22:56:22 -0400 Subject: [PATCH] zasm: add a bunch of instructions --- apps/zasm/tests/geninstrs.py | 4 ++++ apps/zasm/zasm.asm | 21 ++++++++++++++++++--- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/apps/zasm/tests/geninstrs.py b/apps/zasm/tests/geninstrs.py index 27294d8..9ef12ff 100755 --- a/apps/zasm/tests/geninstrs.py +++ b/apps/zasm/tests/geninstrs.py @@ -20,7 +20,9 @@ argspecTbl = { 'c': "(BC)", 'a': "AF", 'f': "AF'", + 'X': "IX", 'x': "(IX)", + 'Y': "IY", 'y': "(IY)", 's': "SP", 'p': "(SP)", @@ -37,6 +39,8 @@ argGrpTbl = { chr(0x01): "bdha", chr(0x02): "ZzC=", chr(0x03): "bdhs", + chr(0x04): "bdXs", + chr(0x05): "bdYs", chr(0x0a): "ZzC=+-12", chr(0x0b): "BCDEHLA", } diff --git a/apps/zasm/zasm.asm b/apps/zasm/zasm.asm index 7420fcc..cea8198 100644 --- a/apps/zasm/zasm.asm +++ b/apps/zasm/zasm.asm @@ -2,9 +2,9 @@ ; *** Consts *** ; Number of rows in the argspec table -ARGSPEC_TBL_CNT .equ 27 +ARGSPEC_TBL_CNT .equ 28 ; Number of rows in the primary instructions table -INSTR_TBL_CNT .equ 75 +INSTR_TBL_CNT .equ 77 ; size in bytes of each row in the primary instructions table INSTR_TBL_ROWSIZE .equ 9 @@ -447,10 +447,19 @@ findInGroup: ; For constant args, it's easy: if A == (HL), it's a success. ; If it's not this, then we check if it's a numerical arg. ; If A is a group ID, we do something else: we check that (HL) exists in the -; groupspec (argGrpTbl) +; groupspec (argGrpTbl). +; Set Z according to whether we match or not. matchArg: cp a, (hl) ret z + ; not an exact match. Before we continue: is A zero? Because if it is, + ; we have to stop right here: no match possible. + cp 0 + jr nz, .checkIfNumber ; not a zero, we can continue + ; zero, stop here + call unsetZ + ret +.checkIfNumber: ; not an exact match, let's check for numerical constants. call JUMP_UPCASE call checkNOrM @@ -713,6 +722,8 @@ argspecTbl: .db 'c', "(BC)" .db 'a', "AF", 0, 0 .db 'f', "AF'", 0 + .db 'X', "IX", 0, 0 + .db 'Y', "IY", 0, 0 .db 'x', "(IX)" ; always come with displacement .db 'y', "(IY)" ; with JP .db 's', "SP", 0, 0 @@ -745,6 +756,8 @@ argGrpTbl: .db "bdha" ; 0x01 .db "ZzC=" ; 0x02 .db "bdhs" ; 0x03 + .db "bdXs" ; 0x04 + .db "bdYs" ; 0x05 argGrpCC: .db "zZ=C12+-" ; 0xa @@ -775,6 +788,8 @@ instrTBl: .db "ADD", 0, 'A', 0xb, 0, 0b10000000 , 0 ; ADD A, r .db "ADD", 0, 'A', 'n', 0, 0xc6 , 0 ; ADD A, n .db "ADD", 0, 'h', 0x3, 4, 0b00001001 , 0 ; ADD HL, ss + .db "ADD", 0,'X',0x4,0x44, 0xdd, 0b00001001 ; ADD IX, pp + .db "ADD", 0,'Y',0x5,0x44, 0xfd, 0b00001001 ; ADD IY, rr .db "AND", 0, 'l', 0, 0, 0xa6 , 0 ; AND (HL) .db "AND", 0, 0xb, 0, 0, 0b10100000 , 0 ; AND r .db "AND", 0, 'n', 0, 0, 0xe6 , 0 ; AND n