Skip to content

Commit 5629385

Browse files
authored
Add test for HB63C09M
test for HB63C09M This runs the same routines for the back end as the COCO, using 6309 optimizations, as well as 24bit FP maths
1 parent 13fb43d commit 5629385

File tree

5 files changed

+702
-0
lines changed

5 files changed

+702
-0
lines changed

hb63c09/68b50.asm

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; UART and control the routines are set up for the 6850
2+
; or 'like' such as the 6850 Wrapper in the HB63C09M.
3+
4+
USTAT EQU $A000 ; UART Status Register
5+
UDATA EQU $A001 ; UART Data Register
6+
7+
; Send CRLF to terminal
8+
CRLF: LDA #$0A ; Line feed
9+
BSR CHOUT
10+
LDA #$0D ; Carriage return
11+
BSR CHOUT
12+
RTS
13+
14+
; Map iterations to printable ASCII characters
15+
PLOT: LDA 6,S ; Load iteration count
16+
INCA ; Offset for gradient lookup
17+
LDY #PSUSHD ; Address of gradient table
18+
LDA A,Y ; Load corresponding ASCII shade
19+
; Fall through to `CHOUT`
20+
21+
CHOUT: PSHS A ; Save character in A
22+
WRWAIT: LDA USTAT ; Check UART status
23+
BITA #2 ; Ready to send?
24+
BEQ WRWAIT ; Wait until ready
25+
PULS A ; Restore character
26+
STA UDATA ; Send character
27+
RTS
28+
29+
30+
; 16 levels of pseudo-shades in 7-Bit ASCII (darkest to lightest)
31+
PSUSHD: FCB $23,$40,$25,$26,$58,$2A,$2B,$3D ; Darker characters
32+
FCB $2D,$7E,$3A,$2E,$2C,$60,$20,$20 ; Lighter characters

hb63c09/Makefile

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Define variables
2+
ASM = hb-mand.asm
3+
LIST = hb-mand.lst
4+
OUTPUT = hb-mand.s19
5+
6+
# Define the lwasm command
7+
LZASM = lwasm
8+
9+
# Compilation rule
10+
all: $(OUTPUT)
11+
12+
$(OUTPUT): $(ASM)
13+
$(LZASM) -l$(LIST) -fsrec -o$(OUTPUT) -3 $(ASM)
14+
15+
# Clean rule
16+
clean:
17+
rm -f $(LIST) $(OUTPUT)

hb63c09/hb-mand.asm

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
;; asembly battle royal for the HB63C09M
2+
;; This simply resets the comptuer at the end of exicution, and should
3+
;; technically work on any homebrew computer with a serial MLM as long as
4+
;; there is a supported UART -- You should check the addresses in your
5+
;; source file for the UART to make shure they align with your architecture
6+
7+
;; lets enable 6309 since the CPU is required for the architecture of the computer
8+
h6309 EQU 1
9+
10+
ORG $1000
11+
12+
ifdef h6309
13+
ldmd #1 ; h6309 native mode
14+
endif
15+
16+
;; main loop
17+
LEAS -5,S ; Allocate 5 bytes on the stack
18+
CLR ,S ; Clear X (temp low byte)
19+
CLR 1,S ; Clear X (temp high byte)
20+
CLR 2,S ; Clear Y (temp low byte)
21+
CLR 3,S ; Clear Y (temp high byte)
22+
; Dispite what mand_get says in mandelbrot.asm itterations is in 6,S
23+
24+
loop:
25+
LBSR mand_get ; Compute Mandelbrot for current position
26+
LBSR PLOT ; Map result to a gradient character and send it to UART
27+
28+
LDD ,S ; Load X register
29+
ADDD #1 ; Increment X
30+
STD ,S ; Save X back
31+
32+
CMPD #MAND_WIDTH ; Check if X reached the width
33+
BNE loop ; If not, continue
34+
35+
BSR CRLF ; Send CRLF to start a new line
36+
CLR ,S ; Reset X to 0
37+
CLR 1,S
38+
39+
LDD 2,S ; Load Y register
40+
ADDD #1 ; Increment Y
41+
STD 2,S ; Save Y back
42+
43+
CMPD #MAND_HEIGHT ; Check if Y reached the height
44+
BNE loop ; If not, continue
45+
LEAS 5,S ; Deallocate stack
46+
47+
48+
ifdef h6309
49+
ldmd #0 ; h6809 emulation mode
50+
endif
51+
52+
JMP [$FFFE] ; Jump to reset vector
53+
54+
;; includes
55+
INCLUDE "68b50.asm"
56+
57+
58+
INCLUDE "../6x09/mandelbrot24.asm" ; Include Mandelbrot and fixed-point routines

0 commit comments

Comments
 (0)