aboutsummaryrefslogtreecommitdiff
path: root/newasm/main.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 03:18:35 -0500
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2024-08-21 03:18:35 -0500
commitccc04526f14764d856ad37b1f517308fccf886a6 (patch)
tree7c25442967b071a485a44c1da73b16ba84adc9af /newasm/main.s
parented6f1106322f8ca4a6e26d08365bb9558ffa9d09 (diff)
Add label and opcode parsers
Diffstat (limited to 'newasm/main.s')
-rw-r--r--newasm/main.s47
1 files changed, 36 insertions, 11 deletions
diff --git a/newasm/main.s b/newasm/main.s
index 7f3c038..57a1b98 100644
--- a/newasm/main.s
+++ b/newasm/main.s
@@ -5,30 +5,55 @@
.type main, %function
.global main, strbuf
-main: LDR R6, =0x20002000
+main: LDR R4, =0x20002000
BL uart_recv
loop: BL prompt
- LDR R0, strbuf
+ LDR R0, inpbuf
BL getline
+ LDR R0, inpbuf
+ BL putstrln
+ LDR R1, inpbuf
+ LDR R2, strbuf
+ MOVS R0, 0
+ STRB R0, [R2]
+ BL statement
+ BNE bad
+good: ADR R0, success
+ PUSH {R1}
+ BL putstrln
+ POP {R0}
+ BL putstrln
LDR R0, strbuf
- BL putstr
- LDR R0, =crlf
- BL putstr
+ BL putstrln
B loop
- BL uart_recv
+bad: ADR R0, fail
+ PUSH {R1}
+ BL putstrln
+ POP {R0}
+ BL putstrln
+ LDR R0, strbuf
+ BL putstrln
+ B loop
+never: BL uart_recv
LDR R0, =0x20000001
BX R0
- .align 4
-strbuf: .word 0x20001F00
-
prompt: PUSH {LR}
- MOVS R0, R6
+ MOVS R0, R4
BL send_hex
MOVS R0, '
BL uart_send
- LDR R0, [R6]
+ LDR R0, [R4]
BL send_hex
MOVS R0, '
BL uart_send
POP {PC}
+
+ .align 4
+inpbuf: .word 0x20001F00 // TODO getline buffer overflow
+strbuf: .word 0x20001F80
+
+ .align 4
+success: .asciz "The parser suceeded"
+ .align 4
+fail: .asciz "The parser failed"