aboutsummaryrefslogtreecommitdiff
path: root/newasm/optable.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-24 01:14:04 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-24 01:14:04 -0500
commitee01f1a7f1e10be78bcceb4f0f42aa352a6a588f (patch)
tree271e7034ee94e4447784db5b31bf8e332b30fbba /newasm/optable.s
parent80d8f3ae48255f786bd4d52a1819ea0c339f6946 (diff)
Add parsers for basic instruction typesHEADmaster
Diffstat (limited to 'newasm/optable.s')
-rw-r--r--newasm/optable.s9
1 files changed, 3 insertions, 6 deletions
diff --git a/newasm/optable.s b/newasm/optable.s
index a063f02..fb80ab4 100644
--- a/newasm/optable.s
+++ b/newasm/optable.s
@@ -5,9 +5,6 @@
.type lookup, %function
.global lookup
-// 1 unexpected char
-// 2 unexpected end of input
-
// input:
// R0 input string (unboxed)
@@ -25,7 +22,7 @@ loop: CMP R5, R6 // if begin == end then range = 0
BEQ error
ADDS R2, R5, R6 // get sum
LSRS R2, 1 // divide by two
-no_jiggle:LSLS R3, R2, 3 // times 8 (index to offset)
+ LSLS R3, R2, 3 // times 8 (index to offset)
LDR R1, [R4, R3]// read opcode from optable
CMP R0, R1 // compare opcode to input
BLO lower // if lower
@@ -42,7 +39,7 @@ lower: MOVS R6, R2 // update end pointer
B loop
higher: ADDS R5, R2, 1 // update begin pointer
B loop
-error: MOVS R0, 1 // return code 1 (not found)
+error: MOVS R0, 4 // return code 4 (opcode not found)
POP {R4, R5, R6}
BX LR
@@ -53,5 +50,5 @@ op_table:
.ascii "ASPI"; .hword 0xB000; .byte 0x04, 0x07 // instr type 4, special code 7
.ascii "ASRI"; .hword 0x1000; .byte 0x01, 0x05 // instr type 1, special code 5 (imm width)
.ascii "ADCS"; .hword 0x4140; .byte 0x00, 0x00 // instr type 0, special code 0
- .ascii "ADDS"; .hword 0x1400; .byte 0x03, 0x00 // instr type 3, special code 0
+ .ascii "ADDS"; .hword 0x1800; .byte 0x03, 0x00 // instr type 3, special code 0
.ascii "BKPT"; .hword 0xBE00; .byte 0x04, 0x08 // instr type 4, special code 8