Files
chibi-firmware/bbhashtool.c

39 lines
845 B
C

/* Generates "hashes" from ASCII strings to be used in BUZBEE */
#include <stdint.h>
#include <stdio.h>
const int CCH_CMD = 4;
int mkhash(const char pszCmd[]);
int main(void) {
/* Add your commands here to be hashed. Imprtant that they all be CCH_CMD
* chars long EXCLUDING the NUL terminator. */
char *ppszCmds[] = {
"CALL",
"EXEC",
"HELP",
"PEEK",
"POKE",
"SREC",
/* "BOOT", */
};
for (int iCmd = 0; iCmd < (sizeof(ppszCmds) / sizeof(char *)); iCmd++)
printf("BBC%s\n fcb $%.2X\n", ppszCmds[iCmd], mkhash(ppszCmds[iCmd]));
return 0;
}
int mkhash(const char pszCmd[]) {
uint8_t nhash = 0;
/* NOTE: Very important that condition is the length of the string MINUS the
* NUL terminator, in this case iChar < 4 */
for (int iChar = 0; iChar < CCH_CMD; iChar++)
nhash = nhash - pszCmd[iChar];
return nhash;
}