diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-03 19:01:31 +0000 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2023-11-03 19:01:31 +0000 |
commit | b5a1582976c721dbb9ece622226be0e5ea575fd8 (patch) | |
tree | 36e2f70ba6beb73ac66564e820c64876574ea4a9 /asm/parser.h | |
parent | 32d50a9342c46d00062f6fe69f817560f1938884 (diff) | |
download | ovm-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/parser.h')
-rw-r--r-- | asm/parser.h | 15 |
1 files changed, 13 insertions, 2 deletions
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 *); |