From 8e8865940a7d4d4787db5f038dc6d477c1a236f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Thu, 4 Jan 2018 01:25:37 +0000 Subject: [PATCH] Join list of keywords of locallex.c and globlex.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It made sense to have them in different files when the toolchain targeted systems other than the GB. Now, there are no generic and system-specific keywords because there is only one supported system. Signed-off-by: Antonio Niño Díaz --- Makefile | 1 - include/asm/localasm.h | 6 --- src/asm/globlex.c | 117 +++++++++++++++++++++++++++++++++-------- src/asm/locallex.c | 89 ------------------------------- 4 files changed, 96 insertions(+), 117 deletions(-) delete mode 100644 src/asm/locallex.c diff --git a/Makefile b/Makefile index 187fd341..66e1b0a5 100644 --- a/Makefile +++ b/Makefile @@ -48,7 +48,6 @@ rgbasm_obj := \ src/asm/output.o \ src/asm/rpn.o \ src/asm/symbol.o \ - src/asm/locallex.o \ src/extern/err.o \ src/extern/reallocarray.o \ src/extern/strlcpy.o \ diff --git a/include/asm/localasm.h b/include/asm/localasm.h index 6a78c17e..c3d59c99 100644 --- a/include/asm/localasm.h +++ b/include/asm/localasm.h @@ -83,12 +83,6 @@ * XOR A,r : 0xA8|r */ -#define NAME_DB "db" -#define NAME_DW "dw" -#define NAME_DL "dl" -#define NAME_RB "rb" -#define NAME_RW "rw" - /* "r" defs */ enum { REG_B = 0, diff --git a/src/asm/globlex.c b/src/asm/globlex.c index b3940cc7..95eedf6a 100644 --- a/src/asm/globlex.c +++ b/src/asm/globlex.c @@ -1,19 +1,19 @@ -#include "asm/asm.h" -#include "asm/symbol.h" -#include "asm/rpn.h" -#include "asm/symbol.h" -#include "asm/main.h" -#include "asm/lexer.h" - -#include "asmy.h" - +#include #include #include #include #include -#include #include +#include "asm/asm.h" +#include "asm/lexer.h" +#include "asm/main.h" +#include "asm/rpn.h" +#include "asm/symbol.h" +#include "asm/symbol.h" + +#include "asmy.h" + bool oDontExpandStrings; int32_t nGBGfxID = -1; int32_t nBinaryID = -1; @@ -229,9 +229,85 @@ enum { T_LEX_MACROUNIQUE }; -extern const struct sLexInitString localstrings[]; +const struct sLexInitString lexer_strings[] = { + {"adc", T_Z80_ADC}, + {"add", T_Z80_ADD}, + {"and", T_Z80_AND}, + {"bit", T_Z80_BIT}, + {"call", T_Z80_CALL}, + {"ccf", T_Z80_CCF}, + {"cpl", T_Z80_CPL}, + {"cp", T_Z80_CP}, + {"daa", T_Z80_DAA}, + {"dec", T_Z80_DEC}, + {"di", T_Z80_DI}, + {"ei", T_Z80_EI}, + {"halt", T_Z80_HALT}, + {"inc", T_Z80_INC}, + {"jp", T_Z80_JP}, + {"jr", T_Z80_JR}, + {"ld", T_Z80_LD}, + {"ldi", T_Z80_LDI}, + {"ldd", T_Z80_LDD}, + {"ldio", T_Z80_LDIO}, + {"ldh", T_Z80_LDIO}, + {"nop", T_Z80_NOP}, + {"or", T_Z80_OR}, + {"pop", T_Z80_POP}, + {"push", T_Z80_PUSH}, + {"res", T_Z80_RES}, + {"reti", T_Z80_RETI}, + {"ret", T_Z80_RET}, + {"rlca", T_Z80_RLCA}, + {"rlc", T_Z80_RLC}, + {"rla", T_Z80_RLA}, + {"rl", T_Z80_RL}, + {"rrc", T_Z80_RRC}, + {"rrca", T_Z80_RRCA}, + {"rra", T_Z80_RRA}, + {"rr", T_Z80_RR}, + {"rst", T_Z80_RST}, + {"sbc", T_Z80_SBC}, + {"scf", T_Z80_SCF}, + {"set", T_POP_SET}, + {"sla", T_Z80_SLA}, + {"sra", T_Z80_SRA}, + {"srl", T_Z80_SRL}, + {"stop", T_Z80_STOP}, + {"sub", T_Z80_SUB}, + {"swap", T_Z80_SWAP}, + {"xor", T_Z80_XOR}, + + {"nz", T_CC_NZ}, + {"z", T_CC_Z}, + {"nc", T_CC_NC}, + /* Handled in list of registers */ + /* { "c", T_TOKEN_C }, */ + + {"[bc]", T_MODE_BC_IND}, + {"[de]", T_MODE_DE_IND}, + {"[hl]", T_MODE_HL_IND}, + {"[hl+]", T_MODE_HL_INDINC}, + {"[hl-]", T_MODE_HL_INDDEC}, + {"[hli]", T_MODE_HL_INDINC}, + {"[hld]", T_MODE_HL_INDDEC}, + {"[sp]", T_MODE_SP_IND}, + {"af", T_MODE_AF}, + {"bc", T_MODE_BC}, + {"de", T_MODE_DE}, + {"hl", T_MODE_HL}, + {"sp", T_MODE_SP}, + {"[c]", T_MODE_C_IND}, + {"[$ff00+c]", T_MODE_C_IND}, + + {"a", T_TOKEN_A}, + {"b", T_TOKEN_B}, + {"c", T_TOKEN_C}, + {"d", T_TOKEN_D}, + {"e", T_TOKEN_E}, + {"h", T_TOKEN_H}, + {"l", T_TOKEN_L}, -const struct sLexInitString staticstrings[] = { {"||", T_OP_LOGICOR}, {"&&", T_OP_LOGICAND}, {"==", T_OP_LOGICEQU}, @@ -292,9 +368,9 @@ const struct sLexInitString staticstrings[] = { {"xref", T_POP_IMPORT}, {"global", T_POP_GLOBAL}, {"ds", T_POP_DS}, - {NAME_DB, T_POP_DB}, - {NAME_DW, T_POP_DW}, - {NAME_DL, T_POP_DL}, + {"db", T_POP_DB}, + {"dw", T_POP_DW}, + {"dl", T_POP_DL}, {"section", T_POP_SECTION}, {"purge", T_POP_PURGE}, @@ -308,7 +384,6 @@ const struct sLexInitString staticstrings[] = { {"warn", T_POP_WARN}, {"macro", T_POP_MACRO}, - /* Not needed but we have it here just to protect the name */ {"endm", T_POP_ENDM}, {"shift", T_POP_SHIFT}, @@ -341,12 +416,13 @@ const struct sLexInitString staticstrings[] = { {"data", T_SECT_DATA}, {"bss", T_SECT_BSS}, - {NAME_RB, T_POP_RB}, - {NAME_RW, T_POP_RW}, + {"rb", T_POP_RB}, + {"rw", T_POP_RW}, {"equ", T_POP_EQU}, {"equs", T_POP_EQUS}, - {"set", T_POP_SET}, + /* Handled before in list of CPU instructions */ + /* {"set", T_POP_SET}, */ {"=", T_POP_SET}, {"pushs", T_POP_PUSHS}, @@ -390,8 +466,7 @@ setuplex(void) uint32_t id; lex_Init(); - lex_AddStrings(staticstrings); - lex_AddStrings(localstrings); + lex_AddStrings(lexer_strings); //Macro arguments diff --git a/src/asm/locallex.c b/src/asm/locallex.c deleted file mode 100644 index ba43a199..00000000 --- a/src/asm/locallex.c +++ /dev/null @@ -1,89 +0,0 @@ -#include "asm/symbol.h" -#include "asm/lexer.h" -#include "asm/rpn.h" - -#include "asmy.h" - -const struct sLexInitString localstrings[] = { - {"adc", T_Z80_ADC}, - {"add", T_Z80_ADD}, - {"and", T_Z80_AND}, - {"bit", T_Z80_BIT}, - {"call", T_Z80_CALL}, - {"ccf", T_Z80_CCF}, - {"cpl", T_Z80_CPL}, - {"cp", T_Z80_CP}, - {"daa", T_Z80_DAA}, - {"dec", T_Z80_DEC}, - {"di", T_Z80_DI}, - {"ei", T_Z80_EI}, - {"halt", T_Z80_HALT}, - {"inc", T_Z80_INC}, - {"jp", T_Z80_JP}, - {"jr", T_Z80_JR}, - {"ld", T_Z80_LD}, - {"ldi", T_Z80_LDI}, - {"ldd", T_Z80_LDD}, - {"ldio", T_Z80_LDIO}, - {"ldh", T_Z80_LDIO}, - {"nop", T_Z80_NOP}, - {"or", T_Z80_OR}, - {"pop", T_Z80_POP}, - {"push", T_Z80_PUSH}, - {"res", T_Z80_RES}, - {"reti", T_Z80_RETI}, - {"ret", T_Z80_RET}, - {"rlca", T_Z80_RLCA}, - {"rlc", T_Z80_RLC}, - {"rla", T_Z80_RLA}, - {"rl", T_Z80_RL}, - {"rrc", T_Z80_RRC}, - {"rrca", T_Z80_RRCA}, - {"rra", T_Z80_RRA}, - {"rr", T_Z80_RR}, - {"rst", T_Z80_RST}, - {"sbc", T_Z80_SBC}, - {"scf", T_Z80_SCF}, - - /* Handled by globallex.c */ - /* { "set", T_POP_SET }, */ - - {"sla", T_Z80_SLA}, - {"sra", T_Z80_SRA}, - {"srl", T_Z80_SRL}, - {"stop", T_Z80_STOP}, - {"sub", T_Z80_SUB}, - {"swap", T_Z80_SWAP}, - {"xor", T_Z80_XOR}, - - {"nz", T_CC_NZ}, - {"z", T_CC_Z}, - {"nc", T_CC_NC}, - /* { "c", T_TOKEN_C }, */ - - {"[bc]", T_MODE_BC_IND}, - {"[de]", T_MODE_DE_IND}, - {"[hl]", T_MODE_HL_IND}, - {"[hl+]", T_MODE_HL_INDINC}, - {"[hl-]", T_MODE_HL_INDDEC}, - {"[hli]", T_MODE_HL_INDINC}, - {"[hld]", T_MODE_HL_INDDEC}, - {"[sp]", T_MODE_SP_IND}, - {"af", T_MODE_AF}, - {"bc", T_MODE_BC}, - {"de", T_MODE_DE}, - {"hl", T_MODE_HL}, - {"sp", T_MODE_SP}, - {"[c]", T_MODE_C_IND}, - {"[$ff00+c]", T_MODE_C_IND}, - - {"a", T_TOKEN_A}, - {"b", T_TOKEN_B}, - {"c", T_TOKEN_C}, - {"d", T_TOKEN_D}, - {"e", T_TOKEN_E}, - {"h", T_TOKEN_H}, - {"l", T_TOKEN_L}, - - {NULL, 0} -};