summaryrefslogtreecommitdiff
path: root/usr.bin/oasm/parse.c
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2025-07-23 18:38:09 -0400
committerIan Moffett <ian@osmora.org>2025-07-23 18:47:57 -0400
commit729a19a6b7e636a8af3a15f7fe5204cc0d59dbf7 (patch)
tree9dc5dbacd0576f1aa369e9442f442e6a117865bc /usr.bin/oasm/parse.c
parentf9a78caefd6f254e854fd6cdf64a8642ccddc34e (diff)
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 <ian@osmora.org>
Diffstat (limited to 'usr.bin/oasm/parse.c')
-rw-r--r--usr.bin/oasm/parse.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.bin/oasm/parse.c b/usr.bin/oasm/parse.c
index 673fbcd..113671f 100644
--- a/usr.bin/oasm/parse.c
+++ b/usr.bin/oasm/parse.c
@@ -49,6 +49,8 @@ static const char *tokstr[] = {
[ TT_DEC ] = "dec",
[ TT_MOV ] = "mov",
[ TT_IMM ] = "<imm>",
+ [ TT_LABEL] = "<label>",
+
/* X<n> registers */
[ TT_X0 ] = "x0",
@@ -150,6 +152,9 @@ parse_tok(struct oasm_state *state, struct oasm_token *tok)
state->last = tok->type;
emit_osmx64(&emit_state, tok);
break;
+ case TT_LABEL:
+ state->last = tok->type;
+ break;
case TT_HLT:
state->last = tok->type;
emit_osmx64(&emit_state, tok);