From eea04e3327972f052dcfb8ae0854b77f87d3d52f Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Fri, 18 Sep 2020 14:49:07 -0400 Subject: - Added support for structs, and unions to the emulator's assembler. - Make the symbol table a doublely linked list, in both ways. - Optimized the memcopy() function. - Changed the benchmark timing, to now use a timer, and stops once the timer reaches zero. When the timer hits zero, it sends SIGALRM to the main function, which tells the emulator that the benchmark is done. --- asmmon.h | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) (limited to 'asmmon.h') diff --git a/asmmon.h b/asmmon.h index 633ed38..7db9b4c 100644 --- a/asmmon.h +++ b/asmmon.h @@ -55,9 +55,12 @@ struct fix { struct sym { symbol *next; - symbol *local; + symbol *prev; + symbol *down; + symbol *up; uint16_t count; uint64_t val; + uint8_t isstruct; uint8_t def; char *name; uint16_t id; @@ -93,7 +96,11 @@ enum dir { DIR_DWORD, DIR_QWORD, DIR_INCLUDE, - DIR_RES + DIR_RES, + DIR_STRUCT, + DIR_UNION, + DIR_ENDSTRUCT, + DIR_ENDUNION }; enum token { @@ -115,7 +122,11 @@ enum token { TOK_HEX, TOK_DEC, TOK_BIN, - TOK_INCLUDE + TOK_INCLUDE, + TOK_STRUCT, + TOK_UNION, + TOK_MEMBER + }; enum pre_token { @@ -297,14 +308,18 @@ static const instruction inst[OPNUM] = { [XOR] = {(AM_IMM|AM_ZM|AM_ABS|AM_BREG), 0x81} }; -static const char *dir_t[7] = { - [0] = "org", - [1] = "byte", - [2] = "word", - [3] = "dword", - [4] = "qword", - [5] = "include", - [6] = "res" +static const char *dir_t[11] = { + [ 0] = "org", + [ 1] = "byte", + [ 2] = "word", + [ 3] = "dword", + [ 4] = "qword", + [ 5] = "include", + [ 6] = "res", + [ 7] = "struct", + [ 8] = "union", + [ 9] = "endstruct", + [10] = "endunion" }; static const char *rs_t[4] = { @@ -314,7 +329,7 @@ static const char *rs_t[4] = { [3] = ".q" }; -static const char *lex_tok[19] = { +static const char *lex_tok[22] = { [TOK_DIR ] = "TOK_DIR", [TOK_LOCAL ] = "TOK_LOCAL", [TOK_LABEL ] = "TOK_LABEL", @@ -333,7 +348,10 @@ static const char *lex_tok[19] = { [TOK_HEX ] = "TOK_HEX", [TOK_DEC ] = "TOK_DEC", [TOK_BIN ] = "TOK_BIN", - [TOK_INCLUDE] = "TOK_INCLUDE" + [TOK_INCLUDE] = "TOK_INCLUDE", + [TOK_STRUCT ] = "TOK_STRUCT", + [TOK_UNION ] = "TOK_UNION", + [TOK_MEMBER ] = "TOK_MEMBER" }; static const char *adrmode[11] = { @@ -545,7 +563,7 @@ extern uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg); extern uint64_t get_val(token *t, uint64_t addr, uint8_t size, uint8_t dbg); extern token *skip_expr(token *t, uint8_t dbg); -extern uint64_t parse_tokens(token *tm, bytecount *bc, uint8_t isasm, uint64_t address, uint8_t dbg); +extern uint64_t parse_tokens(token *tm, line **l, bytecount *bc, uint8_t isasm, uint64_t address, uint8_t dbg); extern token *make_token(uint8_t id, uint8_t type, uint8_t space, uint8_t tab, uint64_t value, char *str, symbol *s); extern void assemble(line *ln, bytecount *bc, uint8_t dbg); extern void cleanup(); -- cgit v1.2.3-13-gbd6f