From 80d8f3ae48255f786bd4d52a1819ea0c339f6946 Mon Sep 17 00:00:00 2001 From: Jacques Comeaux Date: Fri, 23 Aug 2024 19:46:17 -0500 Subject: Add register parser and binary search for opcodes --- newasm/parsers/label.s | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 newasm/parsers/label.s (limited to 'newasm/parsers/label.s') diff --git a/newasm/parsers/label.s b/newasm/parsers/label.s new file mode 100644 index 0000000..4770e6c --- /dev/null +++ b/newasm/parsers/label.s @@ -0,0 +1,30 @@ +.syntax unified +.cpu cortex-m0plus +.thumb + +.type label, %function +.global label + +// 1 unexpected begin char +// 2 doesn't end with colon + +// R4 input buffer +// R2 output buffer + +label: PUSH {LR} + LDRB R0, [R4] // get a char + CMP R0, 0x61 // a + BLO 1f + CMP R0, 0x7A // z + BLS 2f +1: MOVS R0, #1 // return code 1 (expected lowercase) + POP {PC} +2: BL symbol + LDRB R0, [R4] // get a char + CMP R0, ': // colon + BEQ 3f + MOVS R0, #2 // return code 2 (expected colon) + POP {PC} +3: ADDS R4, 1 // consume the colon + MOVS R0, #0 // return code 0 (success) + POP {PC} -- cgit v1.2.3