diff options
author | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-05-29 08:15:09 -0500 |
---|---|---|
committer | Jacques Comeaux <jacquesrcomeaux@protonmail.com> | 2024-05-29 08:15:09 -0500 |
commit | 86b72b11d6abcc602a93aa480f27644cc0b34373 (patch) | |
tree | 5c1c7875e9ae3cc72248d5e7dab9af083de98d6d /assembler/register.s | |
parent | e8bc3587cce27b25ba07469964828a327471e5ed (diff) |
Use absolute branches for subroutine calls
Diffstat (limited to 'assembler/register.s')
-rw-r--r-- | assembler/register.s | 73 |
1 files changed, 33 insertions, 40 deletions
diff --git a/assembler/register.s b/assembler/register.s index f8197fd..6728643 100644 --- a/assembler/register.s +++ b/assembler/register.s @@ -5,43 +5,36 @@ .type register, %function .global register -register: - PUSH {LR} - MOV R4, R0 - LSLS R4, 1 - ADDS R4, ('0 + 1) -10: - BL get_char - CMP R0, 'R - BNE 10b - BL uart_send -20: - BL get_char - CMP R0, '0 - BLO 20b - CMP R0, R4 - BHI 20b - BL uart_send - CMP R0, '1 - BNE 30f - CMP R4, '7 - BEQ 30f -50: - BL get_char - BEQ 60f - CMP R0, '0 - BLO 50b - CMP R0, '5 - BHI 50b - BL uart_send - ADDS R0, 10 -30: - SUBS R0, '0 - MOV R4, R0 -40: - BL get_char - BNE 40b - POP {PC} -60: - MOVS R4, 1 - POP {PC} +register: PUSH {LR} + MOV R4, R0 + LSLS R4, 1 + ADDS R4, ('0 + 1) +10: BLX R10 + CMP R0, 'R + BNE 10b + BLX R9 +20: BLX R10 + CMP R0, '0 + BLO 20b + CMP R0, R4 + BHI 20b + BLX R9 + CMP R0, '1 + BNE 30f + CMP R4, '7 + BEQ 30f +50: BLX R10 + BEQ 60f + CMP R0, '0 + BLO 50b + CMP R0, '5 + BHI 50b + BLX R9 + ADDS R0, 10 +30: SUBS R0, '0 + MOV R4, R0 +40: BLX R10 + BNE 40b + POP {PC} +60: MOVS R4, 1 + POP {PC} |