From b5a1582976c721dbb9ece622226be0e5ea575fd8 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Fri, 3 Nov 2023 19:01:31 +0000 Subject: 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. --- asm/parser.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'asm/parser.h') diff --git a/asm/parser.h b/asm/parser.h index 0a65310..b0091d2 100644 --- a/asm/parser.h +++ b/asm/parser.h @@ -25,9 +25,10 @@ typedef enum PERR_EXPECTED_UTYPE, PERR_EXPECTED_TYPE, PERR_EXPECTED_SYMBOL, + PERR_EXPECTED_LABEL, PERR_EXPECTED_OPERAND, - PERR_UNKNOWN_OPERATOR, PERR_INVALID_RELATIVE_ADDRESS, + PERR_UNKNOWN_OPERATOR, PERR_UNKNOWN_LABEL, } perr_t; @@ -37,16 +38,26 @@ typedef struct { inst_t instruction; char *label; - s_word relative_address; + s_word address; enum PResult_Type { PRES_LABEL = 0, PRES_LABEL_ADDRESS, + PRES_GLOBAL_LABEL, PRES_RELATIVE_ADDRESS, PRES_COMPLETE_RESULT, } type; } presult_t; +typedef struct +{ + char *name; + size_t name_size; + word addr; +} label_t; + +label_t search_labels(label_t *, size_t, char *); + perr_t parse_next(token_stream_t *, presult_t *); perr_t process_presults(presult_t *, size_t, inst_t **, size_t *); perr_t parse_stream(token_stream_t *, inst_t **, size_t *); -- cgit v1.2.3-13-gbd6f