feat(buzbee): using BSS sections for variables

This commit is contained in:
2025-10-07 14:21:12 -05:00
parent 6cbb038b42
commit 88fcc86e72
2 changed files with 31 additions and 23 deletions

View File

@@ -5,16 +5,3 @@
; vim: ft=asm
BUZBEE IMPORT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BUZBEE Variables
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BBIN_BASE EQU $0200
BBIN_DEPTH EQU $7F
BBTOKENS_BASE EQU $0280
BBTOKENS_DEPTH EQU $3F
BBTOKENS_CCH EQU $02C0

View File

@@ -7,6 +7,26 @@
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BUZBEE Variables
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
BBIN_DEPTH EQU $7F
BBTOKENS_DEPTH EQU $3F
SECTION BBVARS,bss
tagbbvar STRUCT
input rmb BBIN_DEPTH ; Input buffer
tokens rmb BBTOKENS_DEPTH ; Token buffer
cbtokens rmb 2
ENDSTRUCT
ORG $0200
BBVAR tagbbvar
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; BUZBEE Machine Language Monitor for CHIBI PC-09
@@ -39,7 +59,7 @@ CLRIN ; Label to just clear input buffer without newline
clra ; Init A and X
ldx #$0000
NEXT@
sta BBIN_BASE,x ; Clear input buffer
sta BBVAR.input,x ; Clear input buffer
leax 1,x
cmpx #BBIN_DEPTH
blo NEXT@
@@ -64,7 +84,7 @@ INPLOOP
beq FULLBUF@ ; Handle the buffer being full
ECHO@
jsr POUTCHAR ; Echo char back, this includes BS chars
sta BBIN_BASE,y ; Add it to the input buffer
sta BBVAR.input,y ; Add it to the input buffer
leay 1,y
NOCHAR@
; Check for error condition, work based on The Serial Port release 19
@@ -96,7 +116,7 @@ HESC@
HBACKSPC@
clrb ; Clear last char
leay -1,y
stb BBIN_BASE
stb BBVAR.input
bra ECHO@ ; Echo the char in A
FULLBUF@
lda #$07 ; ASCII BEL
@@ -114,14 +134,14 @@ FULLBUF@
; @return A: resulting hash
MKCMDSUM
pshs b
ldb #4 ; Loop over four chars
clra ; Initialize accumulator
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
suba BBVAR.input,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
; Maps a command hash to a command index, and executes it
@@ -184,6 +204,7 @@ HELP_MSG
fcc "POKE <ADDR> <BYTES> - Overwrite memory with <BYTES> starting at <BASE>."
fcb $0D,$0A
fcc "SREC - Enter Motorola S-Record entry mode."
fcb $0D,$0A
fcb $00
BBCMDPTRTBL