From b5cfd501c5eb6762e6510eb2209450e4a022143e Mon Sep 17 00:00:00 2001 From: Gale Faraday Date: Sun, 12 Oct 2025 17:15:05 -0500 Subject: [PATCH] fix(buzbee): formatting, typos, unrolling, and stack fixes --- src/buzbee.s | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/buzbee.s b/src/buzbee.s index 7967feb..a3423f2 100644 --- a/src/buzbee.s +++ b/src/buzbee.s @@ -143,24 +143,22 @@ PBYTE asra asra asra - bsr NYB2HEX ; Print A - jsr POUTCHAR - tfr b,a ; Print B next - bsr NYB2HEX ; Print B - jsr POUTCHAR - puls b - rts - -; Converts a nybble into a valid hex digit -; @param A: nybble to convert to a char -; @return A: resulting char -NYB2HEX anda #$0F - ora #'0 ; Add "0" - cmpa #$3A ; ":" "9"+1 - blo SKIP@ - adca #6 ; Add offset to "A" in ascii -SKIP@ + ora #'0 ; Add '0' to offset to digits + cmpa #$3A ; Hex? ':' '9'+1 + blo SKIPA@ + adca #6 ; Hex offset +SKIPA@ + jsr POUTCHAR ; Print char in A + andb #$0F + orb #'0 ; Add '0' to offset to digits + cmpb #$3A ; Hex? ':' '9'+1 + blo SKIPB@ + adcb #6 ; Hex offset +SKIPB@ + tfr b,a ; Print char in B + jsr POUTCHAR + puls b ; Restore B rts ; Converts a hexadecimal sequence into a byte value @@ -204,18 +202,20 @@ BADHEX@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Makes a hash of four chars in BBIN starting at offset X -; @param X: offset in BBIN to read the four chars from +; @param Y: offset in BBIN to read the four chars from ; @return A: resulting hash +; @return Y: offset after hash processing MKCMDSUM pshs b ldb #4 ; Loop over four chars clra ; Initialize accumulator NEXTC@ - suba BBVAR.input,x ; Subtract current char from accumulator - leax 1,x ; Next char + suba BBVAR.input,y ; Subtract current char from accumulator + leax 1,y ; Next char decb ; Reduce count cmpb #0 ; Are we at the end? bne NEXTC@ ; No? loop + puls b rts ; Skips "whitespace" to the next semantic char @@ -257,12 +257,12 @@ CALCPTR@ tfr x,d ; Swap into d to do a cheap multiply asld ; Cheaply << to get *2, pointer size tfr d,x ; Restore x from d and jump to function at index - jmp [BBCMDPTRTBL,x] + jmp [IFPTRTBL,x] NOTOK@ rts ; IF pointer table -BBCMDPTRTBL +IFPTRTBL fdb IFCALL fdb IFHELP fdb IFPEEK @@ -388,5 +388,8 @@ EM_TOKFAIL fcc "!!! Tokenization Failure !!!" fcb $0D,$0A,$00 EM_BADHEX - fcc "!!! Maleformed Hex Value !!!" + fcc "!!! Malformed Hex Value !!!" + fcb $0D,$0A,$00 +EM_FULLTOKBUF + fcc "!!! Token Buffer Overrun !!!" fcb $0D,$0A,$00