diff options
author | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-07-07 17:13:53 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-07-07 17:13:53 -0500 |
commit | 17d59ac15b87588de2228aa768e99b5bbca4561c (patch) | |
tree | c0e1f52fed4e77620fd3f8599b6ba9870e310143 /assembler/main.s | |
parent | 420bc15ae16b736fbce1a4846126cd983dd3b75b (diff) |
Add assembler (stage 2) top-level
Diffstat (limited to 'assembler/main.s')
-rw-r--r-- | assembler/main.s | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/assembler/main.s b/assembler/main.s index 9a7fd89..1795823 100644 --- a/assembler/main.s +++ b/assembler/main.s @@ -10,8 +10,37 @@ main: bl setup_clocks bl setup_gpio bl setup_uart -1: - bl assemble - movs r0, r6 - bl send_hex - b 1b + b assembler + +assembler: LDR R0, =0x20001000 // SRAM_BASE + MOV R11, R0 + ADDS R1, R0, 1 // JUMP ADDRESS + MOV R12, R1 +1: BL PROMPT // SHOW PROMPT + BL assemble + B 2f // TODO condition + BX R12 +2: MOV R7, R11 // STORE INSTRUCTION WORD + STRH R6, [R7] + MOVS R0, '\r // NEW LINE + BL uart_send + BL PROMPT // REWRITE PROMPT + ADDS R7, 2 // INCREMENT POINTER + MOV R11, R7 + MOVS R0, '\r + BL uart_send + MOVS R0, '\n + BL uart_send + B 1b + +PROMPT: PUSH {LR} + MOV R0, R11 // CURRENT ADDRESS + BL send_hex + MOVS R0, ' // SPACE + BL uart_send + MOV R1, R11 // CURRENT CONTENTS + LDRH R0, [R1] + BL send_hex + MOVS R0, ' // SPACE + BL uart_send + POP {PC} // RETURN |