diff options
Diffstat (limited to 'newasm/main.s')
-rw-r--r-- | newasm/main.s | 45 |
1 files changed, 19 insertions, 26 deletions
diff --git a/newasm/main.s b/newasm/main.s index a27fec9..f1d3c0d 100644 --- a/newasm/main.s +++ b/newasm/main.s @@ -6,38 +6,31 @@ .global main, strbuf main: LDR R5, =0x20002000 - BL uart_recv -loop: BL prompt - LDR R0, inpbuf + BL uart_recv // wait for keypress +loop: BL prompt // display address and data + LDR R0, inpbuf // get a line of input BL getline - LDR R0, inpbuf - BL putstrln - LDR R4, inpbuf - LDR R2, strbuf - MOVS R0, 0 + LDR R4, inpbuf // prepare input buffer + LDR R2, strbuf // prepare output buffer + MOVS R0, 0 // clear output buffer STRB R0, [R2] - BL statement - BNE bad - -good: ADR R0, success - PUSH {R1} - BL putstrln - MOVS R0, R4 - BL putstrln - POP {R0} + BL statement // call statement parser + BNE bad // print message if failure + MOVS R0, R1 // show assembled instruction BL send_hex LDR R0, =crlf BL putstr - B loop - -bad: ADR R0, fail - BL putstrln - MOVS R0, R4 + B loop // repeat +bad: PUSH {R0} + ADR R0, fail + BL putstr + POP {R0} + BL send_hex + LDR R0, =crlf + BL putstr + MOVS R0, R4 BL putstrln B loop -never: BL uart_recv - LDR R0, =0x20000001 - BX R0 prompt: PUSH {LR} MOVS R0, R5 @@ -57,4 +50,4 @@ strbuf: .word 0x20001F80 .align 4 success: .asciz "The parser suceeded" .align 4 -fail: .asciz "The parser failed" +fail: .asciz "The parser failed: " |