Overhaul the template.

- DATA and RODATA segments added to computer.cfg
 - RAM memory configuration now starts at  to not overwrite the cpu stack
 - hardware.inc added to handle hardware related constants
 - constants removed from via.s
 - constants removed from serial.s
 - serial_delay from serial.s is now dynamic, dependant on CPU_HZ and baud rate
 - serial_baud_* functions added to setup 19200 and 9600 baud
 - mem_copy.s added. data copy functions are to be implemented here
 - copy_data (mem_copy.s) implemented to copy the DATA segment from ROM to RAM
 - propper system setup in main.s
 - Makefile now generates a .map file with the memory map information
This commit is contained in:
RuiFPB committed 2026-09-29 12:14:05 +01:00
1 parent a8caf9db75
commit 3801459e1e
8 files changed
+203 -74

No files matched your search

+56 -24
View File
@@ -1,40 +1,72 @@
.import serial_setup
.import serial_print_char
.import serial_setup, serial_print_char, serial_recv_char
.import copy_data
.segment "ZEROPAGE"
; ---------------
; ZP
; ---------------
.zeropage
; Zero-page variables ($0000 - $00ff)
.segment "BSS"
; RAM variables ($0100 - $7fff)
; ---------------
; BSS
; ---------------
.bss
; RAM variables ($0200 - $7fff)
.segment "CODE"
; ---------------
; DATA
; ---------------
.data
; Initialized RAM variables ($0200 - $7fff)
; ---------------
; CODE
; ---------------
.code
; Actual program code ($c000 - $fff9)
reset: ; Program starts here
; System setup
sei ; disable interrupts while setting things up
cld ; clear BCD mode flag (undefined on NMOS 6502, auto cleared on 65C02)
ldx #$ff
txs ; Reset stack pointer
reset: ; Program starts here
jsr serial_setup
jsr copy_data ; copy data variables from ROM to RAM
jsr serial_setup ; setup serial interface (65C51N). 19200 baud set as default
print_hello_world:
ldx #0
hello_world_loop:
lda str_hello_world,x ; get char
beq hello_world_end ; IF char is 0, done
jsr serial_print_char ; send char to console
inx ; increment x (next char)
jmp hello_world_loop
hello_world_end:
jmp hello_world_end
@loop:
lda str_hello_world,x ; get char
beq @end ; IF char is 0, done
jsr serial_print_char ; send char to console
inx ; increment x (next char)
jmp @loop
@end:
jmp @end
irq: ; IRQ Handler
rti ; Do nothing
irq_handler: ; IRQ Handler
rti ; Do nothing
nmi: ; NMI handler
rti ; Do nothing
nmi_handler: ; NMI handler
rti ; Do nothing
str_hello_world:
.asciiz "Hello, World!"
; ---------------
; RODATA
; ---------------
.rodata
; Constants
str_hello_world: .asciiz "Hello, World!"
; ---------------
; VECTORS
; ---------------
.segment "VECTORS"
; NMI, RESET and IRQ vectors
.word nmi
.word nmi_handler
.word reset
.word irq
.word irq_handler