aboutsummaryrefslogtreecommitdiff
path: root/asm/lexer.c
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2023-11-03 19:01:31 +0000
committerAryadev Chavali <aryadev@aryadevchavali.com>2023-11-03 19:01:31 +0000
commitb5a1582976c721dbb9ece622226be0e5ea575fd8 (patch)
tree36e2f70ba6beb73ac66564e820c64876574ea4a9 /asm/lexer.c
parent32d50a9342c46d00062f6fe69f817560f1938884 (diff)
downloadovm-b5a1582976c721dbb9ece622226be0e5ea575fd8.tar.gz
ovm-b5a1582976c721dbb9ece622226be0e5ea575fd8.tar.bz2
ovm-b5a1582976c721dbb9ece622226be0e5ea575fd8.zip
Added a start address (equivalent to `main`) to assembler
Creates a jump address to the label delegated by "global" so program starts at that point.
Diffstat (limited to 'asm/lexer.c')
-rw-r--r--asm/lexer.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/asm/lexer.c b/asm/lexer.c
index 525deb2..7f37ce7 100644
--- a/asm/lexer.c
+++ b/asm/lexer.c
@@ -24,6 +24,8 @@ const char *token_type_as_cstr(token_type_t type)
{
switch (type)
{
+ case TOKEN_GLOBAL:
+ return "GLOBAL";
case TOKEN_STAR:
return "STAR";
case TOKEN_LITERAL_NUMBER:
@@ -331,6 +333,11 @@ token_t tokenise_symbol(buffer_t *buffer, size_t *column)
offset = 3;
type = TOKEN_RET;
}
+ else if (sym_size == 6 && strncmp(opcode, "GLOBAL", 6) == 0)
+ {
+ offset = 6;
+ type = TOKEN_GLOBAL;
+ }
else
is_opcode = false;