From 729a19a6b7e636a8af3a15f7fe5204cc0d59dbf7 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Wed, 23 Jul 2025 18:38:09 -0400 Subject: oasm: Add initial support for labels A label is like a pin on a map with a number attached to it. OASM keeps track of a number referred to as the psuedo instruction pointer (PIP). This value is initially zero by default and is incremented every instruction. The purpose of this value is to pin a location in the code and mark it to be at a specific address so that further references to that label would be translated to the previous PIP value at the time of encountering the label. Signed-off-by: Ian Moffett --- etc/oemu/test-00.s | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'etc/oemu') diff --git a/etc/oemu/test-00.s b/etc/oemu/test-00.s index b34c099..1fa7ff1 100644 --- a/etc/oemu/test-00.s +++ b/etc/oemu/test-00.s @@ -1,13 +1,14 @@ -mov x0, #1 ! ~ 0x00000000 -mov x1, #2 ! ~ 0x00000004 -mov x2, #3 ! ~ 0x00000008 - ! X -mov x2, #20 ! ~ 0x0000000C -br x2 ! ~ 0x00000010 -----+ -!!!!!!!!!!!!!! X | -!!!!!!!!!!!!!! X | - ! X | -dec x0 ! ~ 0x00000014 <----+ -inc x1 ! ~ 0x00000018 -add x2, #3 ! ~ 0x0000001C -hlt ! ~ 0x00000020 +mov x0, #1 ! ~ 0x00000000 +mov x1, #2 ! ~ 0x00000004 +mov x2, #3 ! ~ 0x00000008 + ! X +some_label: ! X + mov x2, #20 ! ~ 0x0000000C + br x2 ! ~ 0x00000010 -----+ + !!!!!!!!!!!!!! X | + !!!!!!!!!!!!!! X | + ! X | + dec x0 ! ~ 0x00000014 <----+ + inc x1 ! ~ 0x00000018 + add x2, #3 ! ~ 0x0000001C + hlt ! ~ 0x00000020 -- cgit v1.2.3