diff options
author | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-08-21 03:18:35 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-08-21 03:18:35 -0500 |
commit | ccc04526f14764d856ad37b1f517308fccf886a6 (patch) | |
tree | 7c25442967b071a485a44c1da73b16ba84adc9af /newasm/statement.s | |
parent | ed6f1106322f8ca4a6e26d08365bb9558ffa9d09 (diff) |
Add label and opcode parsers
Diffstat (limited to 'newasm/statement.s')
-rw-r--r-- | newasm/statement.s | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/newasm/statement.s b/newasm/statement.s new file mode 100644 index 0000000..83f8d8d --- /dev/null +++ b/newasm/statement.s @@ -0,0 +1,35 @@ +.syntax unified +.cpu cortex-m0plus +.thumb + +.type statement, %function +.global statement + +// 1 reported an error + +// R1 input buffer +// R2 output buffer + +statement:PUSH {LR} + BL whitespace + BL label + CMP R0, #2 // check for error code 2 (no colon) + BNE 1f + ADR R0, no_colon + B err_exit +1: BL whitespace + BL opcode + BEQ 2f + ADR R0, no_opcode + B err_exit +2: MOVS R0, #0 + POP {PC} + +err_exit: BL putstrln + MOVS R0, #1 // return code 1 (there was an error) + POP {PC} + + .align 4 +no_colon: .asciz "Error: Expected colon at end of label" + .align 4 +no_opcode: .asciz "Error: Expected an opcode" |