From eb87035e06aa45a8b1150ec86f698453d3092340 Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Mon, 22 Jan 2024 15:01:38 -0600 Subject: Add octal and register name parsers --- assembler/octal.s | 25 +++++++++++++++++++++++++ assembler/register.s | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 assembler/octal.s create mode 100644 assembler/register.s (limited to 'assembler') diff --git a/assembler/octal.s b/assembler/octal.s new file mode 100644 index 0000000..7382ca4 --- /dev/null +++ b/assembler/octal.s @@ -0,0 +1,25 @@ +octal: + PUSH {LR} +10: + BL get_char + MOVS R1, '0 + CMP R0, R1 + BNE 10b + BL uart_send + MOVS R4, 0 +20: + BL get_char + BEQ 30f + MOVS R1, '0 + CMP R0, R1 + BLO 20b + MOVS R1, '7 + CMP R0, R1 + BHI 20b + BL uart_send + SUBS R0, '0 + LSLS R4, 3 + ADDS R4, R0 + B 20b +30: + POP {PC} diff --git a/assembler/register.s b/assembler/register.s new file mode 100644 index 0000000..9fbc76c --- /dev/null +++ b/assembler/register.s @@ -0,0 +1,39 @@ +register: + PUSH {LR} +10: + BL get_char + MOVS R1, 'R + CMPS R0, R1 + BNE 10b +20: + BL get_char + MOVS R1, '0 + CMPS R0, R1 + BLO 20b + MOVS R1, '9 + CMPS R0, R1 + BHI 20b + MOVS R1, '1 + CMPS R0, R1 + BNE 30f +50: + BL get_char + BEQ 60f + MOVS R1, '0 + CMPS R0, R1 + BLO 50b + MOVS R1, '5 + CMPS R0, R1 + BHI 50b + ADDS R0, 10 +30: + SUBS R0, '0 + MOVS R4, 0 + ORRS R4, R0 +40: + BL get_char + BNE 40b + POP {PC} +60: + MOVS R4, 1 + POP {PC} -- cgit v1.2.3