summaryrefslogtreecommitdiff
path: root/masm/parse.h
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2024-09-09 20:48:08 -0400
committerFreya Murphy <freya@freyacat.org>2024-09-09 20:48:08 -0400
commit0ff948af3d65150f44c9fe801ada806ce0637fe1 (patch)
treeba766d33d12bf1063660c2144af2d5f5c36b4c87 /masm/parse.h
parenti forgor syscall (diff)
downloadmips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.gz
mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.tar.bz2
mips-0ff948af3d65150f44c9fe801ada806ce0637fe1.zip
relocation table hell
Diffstat (limited to 'masm/parse.h')
-rw-r--r--masm/parse.h38
1 files changed, 31 insertions, 7 deletions
diff --git a/masm/parse.h b/masm/parse.h
index 2aea0be..5f37052 100644
--- a/masm/parse.h
+++ b/masm/parse.h
@@ -18,7 +18,6 @@ enum expr_type {
EXPR_INS,
EXPR_DIRECTIVE,
EXPR_CONSTANT,
- EXPR_SEGMENT,
EXPR_LABEL,
};
@@ -44,7 +43,8 @@ enum symbol_flag {
struct symbol {
char name[MAX_LEX_LENGTH];
- uint32_t position;
+ uint32_t index;
+ struct section *sec;
enum symbol_flag flag;
};
@@ -62,13 +62,37 @@ int symtbl_push(struct symbol_table *sym_tbl, struct symbol sym);
int symtbl_find(struct symbol_table *sym_tbl, struct symbol **sym,
const char name[MAX_LEX_LENGTH]);
+enum section_entry_type {
+ ENT_INS,
+ ENT_WORD,
+ ENT_HALF,
+ ENT_BYTE,
+ ENT_NO_DATA,
+};
+
+struct section_entry {
+ enum section_entry_type type;
+ size_t size;
+
+ union {
+ char data; // to get memory address
+ union mips_instruction ins;
+ int32_t word;
+ int16_t half;
+ int8_t byte;
+ };
+};
+
struct section {
uint32_t count;
uint32_t len;
- uint32_t start;
uint32_t alignment;
- union mips_instruction *ins;
+ uint32_t index; // what index is my section
char name[MAX_LEX_LENGTH];
+ bool read;
+ bool write;
+ bool execute;
+ struct section_entry *entries;
};
struct section_table {
@@ -77,7 +101,6 @@ struct section_table {
struct section *sections;
struct section *current;
char name[MAX_LEX_LENGTH];
- uint32_t total_ins;
};
int sectbl_init(struct section_table *sec_tbl);
@@ -85,10 +108,11 @@ void sectbl_free(struct section_table *sec_tbl);
int sectbl_alloc(struct section_table *sec_tbl, struct section **sec,
const char name[MAX_LEX_LENGTH]);
-int sectbl_push(struct section_table *sec_tbl, struct section *section,
- union mips_instruction ins);
int sectbl_get(struct section_table *sec_tbl, struct section **sec,
const char name[MAX_LEX_LENGTH]);
+int sec_push(struct section *section, struct section_entry entry);
+size_t sec_size(struct section *section);
+size_t sec_index(struct section *section, uint32_t index);
enum reference_type {
REF_OFFESET,