fix(buzbee): cleaned up hashtable generation

This commit is contained in:
2025-10-03 14:40:07 -05:00
parent eafc0ce98e
commit eda7b3ac1f
5 changed files with 31 additions and 20 deletions

4
.gitignore vendored
View File

@@ -6,8 +6,8 @@
*.s19 *.s19
build/ build/
map.txt map.txt
bbmkcmds bbmkhash
# Build system generated files # Build system generated files
src/version.s src/version.s
src/bbcmds.s src/bbhash.s

View File

@@ -1,4 +1,4 @@
/* Generates BUZBEE command data table asm file */ /* Generates BUZBEE command hash data table asm file */
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
@@ -7,7 +7,7 @@
const int s_cchCmd = 4; const int s_cchCmd = 4;
/* Add your commands here to be hashed. Imprtant that they all be CCH_CMD /* 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[] = { const char *s_ppszCmds[] = {
"CALL", "CALL",
"EXEC", "EXEC",
@@ -22,7 +22,7 @@ int mkHash(const char pszCmd[]);
int main(void) { int main(void) {
/* Emit file header */ /* 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\ ; Copyright (c) 2025 Gale Faraday\n\
; Licensed under MIT\n\ ; Licensed under MIT\n\
\n\ \n\
@@ -30,25 +30,27 @@ int main(void) {
\n\ \n\
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\
;;\n\ ;;\n\
;; BUZBEE Command Data\n\ ;; BUZBEE Command Hash Table\n\
;;\n\ ;;\n\
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\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++) { /* Command count.
const char *pszLabel = s_ppszCmds[iCmd]; * NOTE: This is a u16 because it gets emitted into the output assembly. */
printf(" EXPORT BBC%s\n", pszLabel); uint16_t cCmds = sizeof(s_ppszCmds) / sizeof(char *);
}
/* Extra newline */ /* Emit command count */
printf("\n"); printf("BBHASHLEN\n fdb $%.4X\n", cCmds);
/* Emit table data */ /* Emit table data */
for (int iCmd = 0; iCmd < sizeof(s_ppszCmds) / sizeof(char *); iCmd++) { puts("\nBBHASHES");
const char *pszLabel = s_ppszCmds[iCmd]; for (int iCmd = 0; iCmd < cCmds; iCmd++) {
uint8_t uHash = mkHash(s_ppszCmds[iCmd]); uint8_t uHash = mkHash(s_ppszCmds[iCmd]);
printf("BBC%s\n fcb $%.2X\n", pszLabel, uHash); printf(" fcb $%.2X\n", uHash);
} }
return 0; return 0;

View File

@@ -3,6 +3,7 @@ section SERIAL
section MEMTEST section MEMTEST
section BUZBEE section BUZBEE
section BBHASHES
section VECTORS high 100000 section VECTORS high 100000
section VERSION high section VERSION high

View File

@@ -13,7 +13,7 @@ TARGREC := $(TARGET).s19
TARGROM := $(TARGET).bin TARGROM := $(TARGET).bin
SRCDIR := src/ SRCDIR := src/
BUILDDIR := build/ BUILDDIR := build/
GENS := $(SRCDIR)version.s $(SRCDIR)bbcmds.s GENS := $(SRCDIR)version.s $(SRCDIR)bbhash.s
SRCS := $(wildcard $(SRCDIR)*.s) SRCS := $(wildcard $(SRCDIR)*.s)
OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS)) OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS))
INCS := $(wildcard $(SRCDIR)*.inc) INCS := $(wildcard $(SRCDIR)*.inc)
@@ -52,12 +52,12 @@ $(OBJS): $(BUILDDIR)%.o : $(SRCDIR)%.s
generate: $(GENS) generate: $(GENS)
# Run generation scripts # Run generation scripts
$(GENS): bbmkcmds $(GENS): bbmkhash
./bbmkcmds > src/bbcmds.s ./bbmkhash > src/bbhash.s
./genver.sh ./genver.sh
# Build bbmkcmds, used to generate src/cmds.s # Build bbmkcmds, used to generate src/cmds.s
bbmkcmds: bbmkcmds.c bbmkhash: bbmkhash.c
cc -o $@ $< cc -o $@ $<
clean: clean:

8
src/bbhash.inc Normal file
View File

@@ -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