diff options
author | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-08-23 19:46:17 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-08-23 19:46:17 -0500 |
commit | 80d8f3ae48255f786bd4d52a1819ea0c339f6946 (patch) | |
tree | 70126a16181caf459cfcf79fce983655a7a704e5 /newasm/statement.s | |
parent | b08def431c09449b5ad2ff4379fb403b2e1bf67b (diff) |
Add register parser and binary search for opcodes
Diffstat (limited to 'newasm/statement.s')
-rw-r--r-- | newasm/statement.s | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/newasm/statement.s b/newasm/statement.s index 83f8d8d..4a199a6 100644 --- a/newasm/statement.s +++ b/newasm/statement.s @@ -7,24 +7,31 @@ // 1 reported an error -// R1 input buffer +// R4 input buffer // R2 output buffer statement:PUSH {LR} BL whitespace + PUSH {R2} BL label + POP {R2} CMP R0, #2 // check for error code 2 (no colon) BNE 1f ADR R0, no_colon B err_exit 1: BL whitespace + PUSH {R2} BL opcode + POP {R2} BEQ 2f ADR R0, no_opcode B err_exit -2: MOVS R0, #0 - POP {PC} - +2: LDR R0, [R2] + BL lookup + BEQ 3f + ADR R0, not_found + B err_exit +3: POP {PC} // success code already in R0 err_exit: BL putstrln MOVS R0, #1 // return code 1 (there was an error) POP {PC} @@ -33,3 +40,5 @@ err_exit: BL putstrln no_colon: .asciz "Error: Expected colon at end of label" .align 4 no_opcode: .asciz "Error: Expected an opcode" + .align 4 +not_found: .asciz "Error: Opcode not found" |