Compare commits
3 Commits
8c12c2106f
...
6544321450
Author | SHA1 | Date | |
---|---|---|---|
6544321450
|
|||
98ed74f10d
|
|||
15872f93b9
|
38
bbhashtool.c
Normal file
38
bbhashtool.c
Normal file
@@ -0,0 +1,38 @@
|
||||
/* 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;
|
||||
}
|
@@ -28,6 +28,6 @@ sed -e "s/<TAG>/$TAG/g" -e "s/<DATE>/$DATE/g" <<EOF > "$OUTFILE"
|
||||
|
||||
VERMSG
|
||||
fcc "CHIBI PC-09 BOOT ROM <TAG>"
|
||||
fcb \$0A
|
||||
fcb \$0D,\$0A
|
||||
fcn "BUILT <DATE>"
|
||||
EOF
|
||||
|
@@ -12,15 +12,9 @@ BUZBEE IMPORT
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
BBIN_BASE EQU $0200
|
||||
BBIN_DEPTH EQU $7F
|
||||
BBIN_BASE EQU $0200
|
||||
BBIN_DEPTH EQU $7F
|
||||
BBTOKENS_BASE EQU $0280
|
||||
BBTOKENS_DEPTH EQU $3F
|
||||
BBTOKENS_CCH EQU $02C0
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;
|
||||
;; BUZBEE Structures
|
||||
;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
BBVARS STRUCT
|
||||
INPUT rmb BBIN_DEPTH
|
||||
ENDSTRUCT
|
||||
|
15
src/buzbee.s
15
src/buzbee.s
@@ -95,6 +95,21 @@ FULLBUF@
|
||||
jsr POUTCHAR
|
||||
bra INPLOOP
|
||||
|
||||
; Makes a hash of four chars in BBIN starting at offset X.
|
||||
; @param X: offset in BBIN to read the four chars from
|
||||
; @return A: resulting hash
|
||||
MKCMDSUM
|
||||
pshs b
|
||||
ldb #4 ; Loop over four chars
|
||||
clra ; Initialize accumulator
|
||||
NEXTC@
|
||||
suba BBIN_BASE,x ; Subtract current char from accumulator
|
||||
leax 1,x ; Next char
|
||||
decb ; Reduce count
|
||||
cmpb #0 ; Are we at the end?
|
||||
bne NEXTC@ ; No? loop
|
||||
rts
|
||||
|
||||
PROMPTLINE
|
||||
fcb $0D,$0A,$25,$00 ; CR LF '%' NUL
|
||||
|
||||
|
@@ -23,7 +23,7 @@ RESET
|
||||
|
||||
CLRSTACK
|
||||
; Initialize the system stack
|
||||
lda #$00 ; Initialize A & X to zero out the stack
|
||||
clra ; Init A & X to zero out the stack
|
||||
ldx #$0000
|
||||
NEXT@
|
||||
sta STACK_BOTTOM,x ; Write a zero and progress to the next byte
|
||||
|
Reference in New Issue
Block a user