Compare commits

...

10 Commits

8 changed files with 149 additions and 67 deletions

View File

@@ -25,7 +25,7 @@ int main(void) {
; Copyright (c) 2025 Gale Faraday\n\ ; Copyright (c) 2025 Gale Faraday\n\
; Licensed under MIT\n\ ; Licensed under MIT\n\
\n\ \n\
; This file generated by bbmkcmds.c\n\ ; This file generated by bbmkhash.c\n\
\n\ \n\
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\
;;\n\ ;;\n\
@@ -40,10 +40,10 @@ int main(void) {
/* Command count. /* Command count.
* NOTE: This is a u16 because it gets emitted into the output assembly. */ * NOTE: This is a u16 because it gets emitted into the output assembly. */
uint16_t cCmds = sizeof(s_ppszCmds) / sizeof(char *); uint16_t cCmds = sizeof(s_ppszCmds) / sizeof(char *);
/* Emit command count */ /* Emit command count */
printf("BBCHTC\n fdb $%.4X\n", cCmds); printf("BBCHTC\n fdb $%.4X\n", cCmds);
/* Emit table data */ /* Emit table data */
puts("\nBBCHT"); puts("\nBBCHT");

View File

@@ -1,9 +1,17 @@
; BIOS
section RESET load 8000 section RESET load 8000
section SERIAL section SERIAL
; BIOS Interface and Utilities
section BIOSINT load 8800
section MEMTEST section MEMTEST
; BUZBEE Monitor
section BUZBEE section BUZBEE
section BBHASHES section BBHASHES
; Static Data
section VECTORS high 100000 section VECTORS high 100000
section VERSION high section VERSION high
entry 8000

View File

@@ -40,13 +40,14 @@ BBVAR tagbbvar
EXPORT BUZBEE EXPORT BUZBEE
BUZBEE BUZBEE
lbsr NEWLINE ; Setup the new input line and handle display. lbsr NEWLINE ; Setup the new input line and handle display.
bsr INPLOOP ; Fill input buffer. bsr INPLOOP ; Fill input buffer.
cmpy #0 ; No data? cmpy #0 ; No data?
beq BUZBEE ; Try again... beq BUZBEE ; Try again...
lbsr TOKENIZE ; Try to tokenize the input buffer lbsr MKINSENSITIVE ; Make the input buffer case insensitive
lbsr RUNIF ; Execute token buffer, handling any errors lbsr TOKENIZE ; Try to tokenize the input buffer
bra BUZBEE ; Repeat lbsr RUNIF ; Execute token buffer, handling any errors
bra BUZBEE ; Repeat
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
@@ -127,6 +128,21 @@ NEXT@
ldy #0 ; Reset buffer fill pointer ldy #0 ; Reset buffer fill pointer
rts rts
; Makes the input buffer case insensitive
MKINSENSITIVE
NEXTC@
lda BBVAR.input,x
cmpa #'z ; Is the char outside the lowercase range?
bhi NOTLCASE@ ; Yes? Skip offset part
cmpa #'a ; Again on the other side of the range
blo NOTLCASE@
anda #$DF ; -32
NOTLCASE@
leax 1,x ; Ready next char
cmpx BBVAR.cchinput ; Are we at the end?
bne NEXTC@ ; No? Loop
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; Hex Conversion and Printing Routines ;; Hex Conversion and Printing Routines
@@ -301,7 +317,8 @@ RUNIF
beq NOTOK@ beq NOTOK@
ldx #0 ; Counting up from zero ldx #0 ; Counting up from zero
lda BBVAR.tokens ; Load token lda BBVAR.tokens ; Load token
tfr a,b ; Get the index in D tfr a,d ; Get the index in D
clra
asld ; Cheaply << to get *2, pointer size asld ; Cheaply << to get *2, pointer size
tfr d,x ; Move to X so we can use indexed mode with the offset tfr d,x ; Move to X so we can use indexed mode with the offset
jmp [IFPTRTBL,x] ; Select IF jmp [IFPTRTBL,x] ; Select IF

View File

@@ -1,44 +0,0 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- Memory Testing Routines
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Memory Testing Routines
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION MEMTEST
EXPORT RAMTEST
; RAM testing routine. Ported to 6809 from 6800, based on source for ROBIT-2 for
; MIKBUG.
RAMTEST
ldx #STACK_TOP+1 ; bottom of testable SRAM, $0200
AGAIN@ ; Store 1 in memory
lda #1 ; Set [X] to 1
sta 0,x
cmpa 0,x ; If failed print out an error indicator
bne ERR@
NEXT@ ; Loop point for next address
asla ; Shift A and [X] left
asl 0,x
cmpa 0,x ; Compare A and [X]
bne ERR@
cmpa #$80 ; Only test up to $80
bne NEXT@ ; Loop if not $80
cmpx #$60FF ; Compare X to end of RAM
beq PASS@ ; Finish if we're at the end
leax 1,x ; Increment X
bra AGAIN@
ERR@ ; Write out error indicator
ldb #'X
jsr POUTCHAR
PASS@ ; Pass test
ldb #'P
jsr POUTCHAR
rts

View File

@@ -4,7 +4,6 @@
INCLUDE "buzbee.inc" INCLUDE "buzbee.inc"
INCLUDE "hardware.inc" INCLUDE "hardware.inc"
INCLUDE "memtest.inc"
INCLUDE "serial.inc" INCLUDE "serial.inc"
INCLUDE "version.inc" INCLUDE "version.inc"
@@ -51,4 +50,5 @@ ENTERMON
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
TXTRUN TXTRUN
fcn "<3RUN<3" fcc "<3RUN<3"
fcb $0D,$0A,$00

View File

@@ -1,7 +1,8 @@
; CHIBI PC-09 Prototype #1 -- Memory Testing Routines Header ; CHIBI PC-09 Prototype #1 -- BIOS Utilities Header
; Copyright (c) 2025 Amber Zeller, Gale Faraday ; Copyright (c) 2025 Amber Zeller, Gale Faraday
; Licensed under MIT ; Licensed under MIT
; vim: ft=asm ; vim: ft=asm
RAMTEST IMPORT ROBIT IMPORT
PRINTVER IMPORT

99
src/utils.s Normal file
View File

@@ -0,0 +1,99 @@
; CHIBI PC-09 Prototype #1 Boot ROM -- BIOS Utilities
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
; Licensed under MIT
INCLUDE "hardware.inc"
INCLUDE "serial.inc"
INCLUDE "version.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; CHIBI/O Stable BIOS Interface
;;
;; Called through SWI3
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION BIOSINT
EXPORT CHIBIO
; CHIBI/O Entrypoint -- Stable, but defined by linkerscript $8800
; @param A: Function ID
CHIBIO
tfr a,d ; 8-to-16 tfr, fill both a and b
clra ; Clear MSB
asld ; Convert to word offset
tfr d,x ; Put in X for indexing mode
jmp [CHIBIOPTRTBL,x] ; Jump!
; Jump table TODO: Document function IDs and pointers
CHIBIOPTRTBL
fdb IOPRINTVER ; Print the firmware version string
fdb $0000 ; TODO: Interactive BIOS setup utilitiy call
fdb ROBIT ; Access the ROBIT memory test
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; CHIBI/O Function Implementations
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Prints the firmware's version information
IOPRINTVER
PZSTR VERMSG
rti
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;
;; Memory Testing Routines
;;
;; This family of BIOS routines does not return, upon completion the CHIBI must
;; be reset.
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
SECTION MEMTEST
EXPORT ROBIT
; RAM testing routine. Ported to 6809 from 6800, based on source for ROBIT-2 for
; MIKBUG.
ROBIT
ldx #STACK_TOP+1 ; bottom of testable SRAM, $0200
AGAIN@ ; Store 1 in memory
lda #1 ; Set [X] to 1
sta 0,x
cmpa 0,x ; If failed print out an error indicator
bne ERR@
NEXT@ ; Loop point for next address
asla ; Shift A and [X] left
asl 0,x
cmpa 0,x ; Compare A and [X]
bne ERR@
cmpa #$80 ; Only test up to $80
bne NEXT@ ; Loop if not $80
cmpx #$60FF ; Compare X to end of RAM
beq PASS@ ; Finish if we're at the end
leax 1,x ; Increment X
bra AGAIN@
ERR@ ; Write out error indicator
ldb #'X
jsr POUTCHAR
PASS@ ; Pass test
ldb #'P
jsr POUTCHAR
bra HALT
; Prints a message about completing a memory test prompting the user to reset
; then puts the MPU in a loop where it only responds to interrupts, effectively
; halting the CHIBI
HALT
PZSTR MSG_FINISH
LOOP@
sync
bra LOOP@
MSG_FINISH
fcc "Memory test finished! Please reset"
fcb $0D,$0A,$00

View File

@@ -3,6 +3,7 @@
; Licensed under MIT ; Licensed under MIT
INCLUDE "reset.inc" INCLUDE "reset.inc"
INCLUDE "utils.inc"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
@@ -13,11 +14,11 @@
SECTION VECTORS SECTION VECTORS
VECTORS VECTORS
fdb $0000 ; Exception fdb $0000 ; Exception
fdb $0000 ; SWI3 fdb CHIBIO ; SWI3
fdb $0000 ; SWI2 fdb $0000 ; SWI2
fdb $0000 ; FIRQ fdb $0000 ; FIRQ
fdb $0000 ; IRQ fdb $0000 ; IRQ
fdb $0000 ; SWI fdb $0000 ; SWI
fdb $0000 ; NMI fdb $0000 ; NMI
fdb RESET ; Reset fdb RESET ; Reset