Migration to LWTOOLS #2
3
code/boot/linkscript
Normal file
3
code/boot/linkscript
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
section CODE load 8000
|
||||||
|
|
||||||
|
section VECTORS high 100000
|
@@ -8,26 +8,45 @@
|
|||||||
# Project Defaults & Folders
|
# Project Defaults & Folders
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
TARGET := boot.bin
|
TARGET := boot
|
||||||
|
TARGROM := $(TARGET).bin
|
||||||
SRCDIR := src/
|
SRCDIR := src/
|
||||||
MAINSRC := $(SRCDIR)boot.s
|
BUILDDIR := build/
|
||||||
SRCS := $(wildcard $(SRCDIR)*.s)
|
SRCS := $(wildcard $(SRCDIR)*.s)
|
||||||
|
OBJS := $(patsubst $(SRCDIR)%.s,$(BUILDDIR)%.o,$(SRCS))
|
||||||
INCS := $(wildcard $(SRCDIR)*.inc)
|
INCS := $(wildcard $(SRCDIR)*.inc)
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Toolchain Definitions
|
# Toolchain Definitions
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
AS := asm6809
|
AS := lwasm
|
||||||
|
LD := lwlink
|
||||||
|
FIX := mot2bin
|
||||||
|
|
||||||
|
ASFLAGS := -f obj
|
||||||
|
LDFLAGS := -f srec -m map.txt -s linkscript
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Rules and Phony Targets
|
# Rules and Phony Targets
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
all: $(TARGET)
|
all: $(TARGROM)
|
||||||
|
|
||||||
$(TARGET): $(SRCS) $(INCS)
|
# Fix srec into flashable bin file
|
||||||
$(AS) -o $(TARGET) $(MAINSRC)
|
$(TARGROM): $(TARGET).s19
|
||||||
|
$(FIX) -out $@ $<
|
||||||
|
|
||||||
|
# Link objects
|
||||||
|
$(TARGET).s19: $(OBJS)
|
||||||
|
$(LD) $(LDFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
# Assemble objects
|
||||||
|
$(OBJS): $(BUILDDIR)%.o : $(SRCDIR)%.s
|
||||||
|
-@mkdir -p $(BUILDDIR)
|
||||||
|
$(AS) $(ASFLAGS) -o $@ $<
|
||||||
|
|
||||||
|
.IGNORE: clean
|
||||||
clean:
|
clean:
|
||||||
rm -v $(TARGET)
|
@echo 'Cleaning up intermediary files...'
|
||||||
|
@rm -rv $(TARGROM) $(TARGET).s19 $(BUILDDIR)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
; Copyright (c) 2024 Amber Zeller, Gale Faraday
|
; Copyright (c) 2024 Amber Zeller, Gale Faraday
|
||||||
; Licensed under MIT
|
; Licensed under MIT
|
||||||
|
|
||||||
INCLUDE "src/hardware.inc"
|
INCLUDE "hardware.inc"
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
;;
|
;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
SECTION "Reset"
|
SECTION CODE
|
||||||
ORG ROM_BASE
|
;ORG ROM_BASE
|
||||||
|
|
||||||
RESET
|
RESET
|
||||||
; 8n1 Serial Enable DLAB
|
; 8n1 Serial Enable DLAB
|
||||||
lda #(UARTF_LCR_WLS | UARTF_LCR_DLAB)
|
lda #UARTF_LCR_WLS | UARTF_LCR_DLAB
|
||||||
sta UART_LCR
|
sta UART_LCR
|
||||||
|
|
||||||
; REVIEW: Potential endianness hiccough here
|
; REVIEW: Potential endianness hiccough here
|
||||||
@@ -29,7 +29,7 @@ RESET
|
|||||||
lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
|
lda #(UARTF_MCR_RTS) ; Enable Request-to-Send
|
||||||
sta UART_MCR
|
sta UART_MCR
|
||||||
|
|
||||||
lda 'H ; send 'H'
|
lda #'H ; send 'H'
|
||||||
sta UART_BUFR
|
sta UART_BUFR
|
||||||
|
|
||||||
WAIT
|
WAIT
|
||||||
@@ -37,16 +37,16 @@ WAIT
|
|||||||
nop
|
nop
|
||||||
bra WAIT
|
bra WAIT
|
||||||
|
|
||||||
SECTION "Serial"
|
;SECTION "Serial"
|
||||||
|
|
||||||
; Writes a char to the UART in non FIFO mode, preserves A.
|
; Writes a char to the UART in non FIFO mode, preserves A.
|
||||||
; @param b: char to write
|
; @param b: char to write
|
||||||
OUTCHAR
|
OUTCHAR
|
||||||
pshs a ; Preserve A
|
pshs a ; Preserve A
|
||||||
1
|
NOTREADY@
|
||||||
lda UART_LSR ; if LSR.THRE == 1 then write
|
lda UART_LSR ; if LSR.THRE == 1 then write
|
||||||
anda UARTF_LSR_THRE
|
anda UARTF_LSR_THRE
|
||||||
bne 1B ; Loop if UART not ready yet
|
bne NOTREADY@ ; Loop if UART not ready yet
|
||||||
stb UART_BUFR ; Write char
|
stb UART_BUFR ; Write char
|
||||||
puls a ; Restore A
|
puls a ; Restore A
|
||||||
rts
|
rts
|
||||||
@@ -55,45 +55,45 @@ OUTCHAR
|
|||||||
; B.
|
; B.
|
||||||
; @param x: null terminated string start address.
|
; @param x: null terminated string start address.
|
||||||
OUTSTR
|
OUTSTR
|
||||||
ldb x ; Get the next value from X
|
ldb 0,x ; Get the next value from X
|
||||||
cmpb #$00 ; Make sure that mother is non-null
|
cmpb #$00 ; Make sure that we aren't at a terminator
|
||||||
beq 2F
|
beq END@
|
||||||
leax 1,x ; Increment X for our next char
|
leax 1,x ; Increment X for our next char
|
||||||
1 ; Loop point for UART waiting
|
NOTREADY@ ; Loop point for UART waiting
|
||||||
lda UART_LSR ; Wait for UART to be ready
|
lda UART_LSR ; Wait for UART to be ready
|
||||||
anda UARTF_LSR_THRE
|
anda UARTF_LSR_THRE
|
||||||
bne 1B
|
bne NOTREADY@
|
||||||
stb UART_BUFR ; Actually do our write
|
stb UART_BUFR ; Actually do our write
|
||||||
bra OUTSTR ; Reset for the next char
|
bra OUTSTR ; Reset for the next char
|
||||||
2 ; Jump point for end of routine
|
END@ ; Jump point for end of routine
|
||||||
rts
|
rts
|
||||||
|
|
||||||
SECTION "Memtest"
|
;SECTION "Memtest"
|
||||||
|
|
||||||
; RAM testing routine. Ported to 6809 from 6800, based on source for ROBIT-2 for
|
; RAM testing routine. Ported to 6809 from 6800, based on source for ROBIT-2 for
|
||||||
; MIKBUG.
|
; MIKBUG.
|
||||||
RAMTEST
|
RAMTEST
|
||||||
ldx #SRAM_BASE
|
ldx #SRAM_BASE
|
||||||
1 ; Store 1 in memory
|
AGAIN@ ; Store 1 in memory
|
||||||
lda #1 ; Set [X] to 1
|
lda #1 ; Set [X] to 1
|
||||||
sta 0,x
|
sta 0,x
|
||||||
cmpa 0,x ; If failed print out an error indicator
|
cmpa 0,x ; If failed print out an error indicator
|
||||||
bne 3F
|
bne ERR@
|
||||||
2 ; Loop point for next address
|
NEXT@ ; Loop point for next address
|
||||||
asla ; Shift A and [X] left
|
asla ; Shift A and [X] left
|
||||||
asl 0,x
|
asl 0,x
|
||||||
cmpa 0,x ; Compare A and [X]
|
cmpa 0,x ; Compare A and [X]
|
||||||
bne 3F
|
bne ERR@
|
||||||
cmpa #$80 ; Only test up to $80
|
cmpa #$80 ; Only test up to $80
|
||||||
bne 2B ; Loop if not $80
|
bne NEXT@ ; Loop if not $80
|
||||||
cmpx #$60FF ; Compare X to end of RAM
|
cmpx #$60FF ; Compare X to end of RAM
|
||||||
beq 4F ; Finish if we're at the end
|
beq PASS@ ; Finish if we're at the end
|
||||||
leax 1,x ; Increment X
|
leax 1,x ; Increment X
|
||||||
bra 1B
|
bra AGAIN@
|
||||||
3 ; Write out error indicator
|
ERR@ ; Write out error indicator
|
||||||
ldb #'X
|
ldb #'X
|
||||||
jsr OUTCHAR
|
jsr OUTCHAR
|
||||||
4 ; Pass test
|
PASS@ ; Pass test
|
||||||
ldb #'P
|
ldb #'P
|
||||||
jsr OUTCHAR
|
jsr OUTCHAR
|
||||||
rts
|
rts
|
||||||
@@ -104,8 +104,8 @@ RAMTEST
|
|||||||
;;
|
;;
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
SECTION "Vectors"
|
SECTION VECTORS
|
||||||
ORG VECS_BASE
|
;ORG VECS_BASE
|
||||||
|
|
||||||
VECTORS
|
VECTORS
|
||||||
fdb $0000 ; Reserved
|
fdb $0000 ; Reserved
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
; CHIBI PC-09 Hardware Definitions
|
; CHIBI PC-09 Hardware Definitions
|
||||||
; Copyright (c) 2024 Amber Zeller, Gale Faraday
|
; Copyright (c) 2024-2025 Amber Zeller, Gale Faraday
|
||||||
; Licensed under MIT
|
; Licensed under MIT
|
||||||
|
|
||||||
|
; vim: ft=asm
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;;
|
;;
|
||||||
;; Hardware Base Addresses
|
;; Hardware Base Addresses
|
||||||
@@ -93,4 +95,3 @@ UARTF_MSR_DSR EQU %00000100 ; Data Set Ready
|
|||||||
UARTF_MSR_RI EQU %00000010 ; Ring Indicator
|
UARTF_MSR_RI EQU %00000010 ; Ring Indicator
|
||||||
UARTF_MSR_DCD EQU %00000001 ; Data Carrier Detect
|
UARTF_MSR_DCD EQU %00000001 ; Data Carrier Detect
|
||||||
|
|
||||||
; vim: ft=asm
|
|
||||||
|
Reference in New Issue
Block a user