fix(buzbee): cleaned up hashtable generation
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -6,8 +6,8 @@
|
||||
*.s19
|
||||
build/
|
||||
map.txt
|
||||
bbmkcmds
|
||||
bbmkhash
|
||||
|
||||
# Build system generated files
|
||||
src/version.s
|
||||
src/bbcmds.s
|
||||
src/bbhash.s
|
||||
|
@@ -1,4 +1,4 @@
|
||||
/* Generates BUZBEE command data table asm file */
|
||||
/* Generates BUZBEE command hash data table asm file */
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -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;
|
@@ -3,6 +3,7 @@ section SERIAL
|
||||
section MEMTEST
|
||||
|
||||
section BUZBEE
|
||||
section BBHASHES
|
||||
|
||||
section VECTORS high 100000
|
||||
section VERSION high
|
||||
|
8
makefile
8
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:
|
||||
|
8
src/bbhash.inc
Normal file
8
src/bbhash.inc
Normal 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
|
Reference in New Issue
Block a user