diff --git a/.gitignore b/.gitignore index 1c6fdaf..1873f4c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,8 +6,8 @@ *.s19 build/ map.txt -bbmkcmds +bbmkhash # Build system generated files src/version.s -src/bbcmds.s +src/bbhash.s diff --git a/bbmkcmds.c b/bbmkhash.c similarity index 63% rename from bbmkcmds.c rename to bbmkhash.c index 648435c..8b9c6e9 100644 --- a/bbmkcmds.c +++ b/bbmkhash.c @@ -1,4 +1,4 @@ -/* Generates BUZBEE command data table asm file */ +/* Generates BUZBEE command hash data table asm file */ #include #include @@ -7,7 +7,7 @@ const int s_cchCmd = 4; /* Add your commands here to be hashed. Imprtant that they all be CCH_CMD - * chars long EXCLUDING the NUL terminator. */ + * chars long EXCLUDING the NUL terminator. Order is important here. */ const char *s_ppszCmds[] = { "CALL", "EXEC", @@ -22,7 +22,7 @@ int mkHash(const char pszCmd[]); int main(void) { /* Emit file header */ - puts("; CHIBI PC-09 -- BUZBEE -- Command Data\n\ + puts("; CHIBI PC-09 -- BUZBEE -- Command Hash Table\n\ ; Copyright (c) 2025 Gale Faraday\n\ ; Licensed under MIT\n\ \n\ @@ -30,25 +30,27 @@ int main(void) { \n\ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\ ;;\n\ -;; BUZBEE Command Data\n\ +;; BUZBEE Command Hash Table\n\ ;;\n\ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\ \n\ - SECTION BBCMDS\n"); + SECTION BBHASHES\n\ +\n\ + EXPORT BBHASHLEN\n\ + EXPORT BBHASHES\n"); - for (int iCmd = 0; iCmd < sizeof(s_ppszCmds) / sizeof(char *); iCmd++) { - const char *pszLabel = s_ppszCmds[iCmd]; - printf(" EXPORT BBC%s\n", pszLabel); - } + /* Command count. + * NOTE: This is a u16 because it gets emitted into the output assembly. */ + uint16_t cCmds = sizeof(s_ppszCmds) / sizeof(char *); - /* Extra newline */ - printf("\n"); + /* Emit command count */ + printf("BBHASHLEN\n fdb $%.4X\n", cCmds); /* Emit table data */ - for (int iCmd = 0; iCmd < sizeof(s_ppszCmds) / sizeof(char *); iCmd++) { - const char *pszLabel = s_ppszCmds[iCmd]; + puts("\nBBHASHES"); + for (int iCmd = 0; iCmd < cCmds; iCmd++) { uint8_t uHash = mkHash(s_ppszCmds[iCmd]); - printf("BBC%s\n fcb $%.2X\n", pszLabel, uHash); + printf(" fcb $%.2X\n", uHash); } return 0; diff --git a/linkscript b/linkscript index fbd86f0..89fce96 100644 --- a/linkscript +++ b/linkscript @@ -3,6 +3,7 @@ section SERIAL section MEMTEST section BUZBEE +section BBHASHES section VECTORS high 100000 section VERSION high diff --git a/makefile b/makefile index 35dcb47..119fe66 100644 --- a/makefile +++ b/makefile @@ -13,7 +13,7 @@ TARGREC := $(TARGET).s19 TARGROM := $(TARGET).bin SRCDIR := src/ BUILDDIR := build/ -GENS := $(SRCDIR)version.s $(SRCDIR)bbcmds.s +GENS := $(SRCDIR)version.s $(SRCDIR)bbhash.s SRCS := $(wildcard $(SRCDIR)*.s) OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS)) INCS := $(wildcard $(SRCDIR)*.inc) @@ -52,12 +52,12 @@ $(OBJS): $(BUILDDIR)%.o : $(SRCDIR)%.s generate: $(GENS) # Run generation scripts -$(GENS): bbmkcmds - ./bbmkcmds > src/bbcmds.s +$(GENS): bbmkhash + ./bbmkhash > src/bbhash.s ./genver.sh # Build bbmkcmds, used to generate src/cmds.s -bbmkcmds: bbmkcmds.c +bbmkhash: bbmkhash.c cc -o $@ $< clean: diff --git a/src/bbhash.inc b/src/bbhash.inc new file mode 100644 index 0000000..f83382c --- /dev/null +++ b/src/bbhash.inc @@ -0,0 +1,8 @@ +; CHIBI PC-09 Machine Language Monitor -- BUZBEE Command Hash Table Symbols +; Copyright (c) 2025 Gale Faraday +; Licensed under MIT + +; vim: ft=asm + +BBHASHLEN IMPORT +BBHASHES IMPORT