Compare commits
No commits in common. "d5631307b0a8caa160d144a59acc23cb25691eb2" and "15865cab9c26105c86e597fe833b2e6350a09fbd" have entirely different histories.
d5631307b0
...
15865cab9c
@ -8,6 +8,9 @@ leading underscors `_` indicate a "private" label/variable, that is meant for in
|
||||
### Labels
|
||||
- `namespace_fname` for exported subroutines
|
||||
- `_namespace_fname` or `_namespace_fname_sub` for internal labels
|
||||
- `(_)namespace_Macroname`
|
||||
- `(_)NAMESPACE_SYMBOLNAME` for constant symbols
|
||||
- `(_)NAMESPACE_symbolname` for variables
|
||||
- `(_)namespace_LABELNAME` for labels to data sections
|
||||
|
||||
### Symbols/Macros
|
||||
- `(_)NAMESPACE_SYMBOLNAME` for symbols
|
||||
- `(_)NAMESPACE_macroname
|
||||
|
||||
|
@ -6,10 +6,8 @@ MEMORY {
|
||||
ROM: start = $8000, size = $8000, type = ro, file = %O, fill = yes;
|
||||
}
|
||||
SEGMENTS {
|
||||
VIA1: load = VIA1, type = bss;
|
||||
VIA2: load = VIA2, type = bss;
|
||||
ZEROPAGE: load = RAM_ZP, type = bss, start = $0;
|
||||
BSS: load = RAM, type = bss;
|
||||
ZP: load = RAM_ZP, type = bss, start = $0;
|
||||
RAM: load = RAM, type = bss;
|
||||
CODE: load = ROM, type = ro;
|
||||
RODATA: load = ROM, type = ro;
|
||||
RESET_VECTOR: load = ROM, type = ro, start = $FFFA;
|
||||
|
12
main.s65
12
main.s65
@ -1,5 +1,5 @@
|
||||
.include "system/system.s65"
|
||||
.code
|
||||
.segment "CODE"
|
||||
.include "system/system.h65"
|
||||
|
||||
.macro DEBUG_LED_OFF nr
|
||||
lda IO1 + IO::RA
|
||||
@ -44,7 +44,6 @@ SPI_IO = IO2
|
||||
;********************************************************************************
|
||||
; Interrupts
|
||||
;********************************************************************************
|
||||
.code
|
||||
nmi:
|
||||
lda #'%'
|
||||
jsr lcd_char
|
||||
@ -146,11 +145,11 @@ print_2:
|
||||
PrintSlow message_2,10
|
||||
jmp home
|
||||
|
||||
.rodata
|
||||
.segment "RODATA"
|
||||
message_1: .asciiz " Powered by ......6502...... **** www.quintern.xyz"
|
||||
message_2:
|
||||
.byte " Hello "
|
||||
.byte " there "
|
||||
.byte " Hallo "
|
||||
.byte " Clara "
|
||||
.byte " <3 "
|
||||
.asciiz "================"
|
||||
message_menu:
|
||||
@ -164,6 +163,7 @@ str_irq:
|
||||
str_irq_unknown:
|
||||
.asciiz "Unknown IRQ src!"
|
||||
|
||||
.segment "CODE"
|
||||
;********************************************************************************
|
||||
; reset vector
|
||||
;********************************************************************************
|
||||
|
@ -3,7 +3,7 @@
|
||||
;********************************************************************************
|
||||
.ifndef INCLUDE_PRINTER
|
||||
INCLUDE_PRINTER = 1
|
||||
.code
|
||||
|
||||
printer:
|
||||
jsr lcd_clear
|
||||
@printer_loop:
|
||||
|
@ -1,6 +1,5 @@
|
||||
.ifndef INCLUDE_SLEEP
|
||||
INCLUDE_SLEEP = 1
|
||||
.code
|
||||
;********************************************************************************
|
||||
; @macro Sleep
|
||||
; @param time_cs: Time to sleep in centiseconds (10^-2s = 10ms)
|
||||
@ -20,16 +19,15 @@ INCLUDE_SLEEP = 1
|
||||
; @details
|
||||
; Interrupts might change the actual time to finish
|
||||
; To be exact, time_cs is in units of 0.010244s
|
||||
; @modifies: ARG2
|
||||
;********************************************************************************
|
||||
.proc sleep
|
||||
_VAR_1 = ARG2
|
||||
stz _VAR_1
|
||||
VAR_1 = 0
|
||||
stz VAR_1
|
||||
@loop:
|
||||
.repeat 17
|
||||
nop ; 2 - i
|
||||
.endrepeat
|
||||
inc _VAR_1 ; 3 - zp
|
||||
inc VAR_1 ; 3 - zp
|
||||
bne @loop ; 2/3 - r (2 if not taken, but here most of the time its 3)
|
||||
; reaching this takes 256 * (X * 2(nop) + 3(inc) + 3(bne)) - 1(last bne) cycles
|
||||
; with X = 17: T1 = (256×(17×2 + 3 +3) − 1) × (1/1MHz) = 0,010 239 s
|
||||
|
@ -1,7 +1,7 @@
|
||||
# 8-bit Breadboard Computer with W65C02S Processor
|
||||
This repo contains the assembly code for my [6502-project](https://quintern.xyz/de/6502.html).
|
||||
|
||||
The assembler used for this project is the excellent [ca65](https://github.com/cc65/cc65).
|
||||
The assembler used for this project is [vasm](http://www.compilers.de/vasm.html).
|
||||
After assembling it, the binary is loaded onto the EEPROM using [my *eeprom.py* script](https://git.quintern.xyz/MatthiasQuintern/AT28C256-rpi-util) on a Raspberry Pi 4B.
|
||||
|
||||
## Operating System
|
||||
|
@ -7,11 +7,10 @@
|
||||
; The RBUF_NAME variable must be defined, the functions will then be exported
|
||||
; as rb_<RBUF_NAME>_<function> where <function> = init, read or write
|
||||
; @requires
|
||||
; RBUF_MEM_START: First address of ringbuffer memory space
|
||||
; RBUF_MEM_END: Last address of ringbuffer memory space
|
||||
; RBUF_MEM_START: Start address of ringbuffer memory space
|
||||
; RBUF_MEM_END: End address of ringbuffer memory space
|
||||
; RBUF_NAME: Name of the ringbuffer
|
||||
;********************************************************************************
|
||||
.code
|
||||
|
||||
.ifndef RBUF_MEM_START
|
||||
.fatal "RBUF_MEM_START not defined"
|
||||
|
@ -16,17 +16,14 @@ INCLUDE_KEYPAD = 1
|
||||
.fatal "KP_IO is not defined: set it to the base address of the IO chip of the Keypad"
|
||||
.endif
|
||||
|
||||
.zeropage
|
||||
_KP_COLUMN: .res 1 ; for storing stuff
|
||||
|
||||
.bss ; reserve space or ringbuffer
|
||||
KP_BUF_SIZE = 10
|
||||
RBUF_MEM_START: .res KP_BUF_SIZE
|
||||
RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
|
||||
RBUF_MEM_START = $200
|
||||
RBUF_MEM_END = $208
|
||||
.define RBUF_NAME "keypad"
|
||||
.include "buffer.s65"
|
||||
|
||||
.code
|
||||
KB_VAR = $05 ; any free zp address
|
||||
|
||||
.proc kp_init
|
||||
; todo remove later and test
|
||||
lda #$ff
|
||||
@ -77,23 +74,23 @@ RBUF_MEM_END = RBUF_MEM_START + KP_BUF_SIZE - 1
|
||||
@kp_read_column:
|
||||
sta KP_IO+IO::RB
|
||||
lda KP_IO+IO::RB
|
||||
sta _KP_COLUMN ; store result in zeropage so that bbr can be used
|
||||
bbr4 _KP_COLUMN,@kp_write
|
||||
sta KB_VAR ; store result in zeropage so that bbr can be used
|
||||
bbr4 KB_VAR,@kp_write
|
||||
inx
|
||||
bbr5 _KP_COLUMN,@kp_write
|
||||
bbr5 KB_VAR,@kp_write
|
||||
inx
|
||||
bbr6 _KP_COLUMN,@kp_write
|
||||
bbr6 KB_VAR,@kp_write
|
||||
inx
|
||||
bbr7 _KP_COLUMN,@kp_write
|
||||
bbr7 KB_VAR,@kp_write
|
||||
rts
|
||||
@kp_write:
|
||||
lda _KP_VALUES,x
|
||||
lda kp_VALUES,x
|
||||
jsr rb_keypad_write
|
||||
rts
|
||||
.endproc
|
||||
|
||||
.rodata
|
||||
_KP_VALUES:
|
||||
.segment "RODATA"
|
||||
kp_VALUES:
|
||||
; TODO change to literal
|
||||
.byte "123A", "456B", "789C", "*0#D"
|
||||
.endif
|
||||
|
@ -5,18 +5,17 @@
|
||||
; @depends IO-W65C22N
|
||||
;********************************************************************************
|
||||
|
||||
.include "system/system.s65"
|
||||
.include "system/system.h65"
|
||||
|
||||
.ifndef INCLUDE_SPI
|
||||
INCLUDE_SPI = 1
|
||||
.segment "CODE"
|
||||
|
||||
SPI_CODE_START = $3000
|
||||
SPI_PAGES_WRITTEN = $2fff
|
||||
SPI_BYTES_WRITTEN = $2ffe
|
||||
|
||||
|
||||
.bss
|
||||
SPI_PAGES_WRITTEN: .res 1
|
||||
SPI_BYTES_WRITTEN: .res 1
|
||||
SPI_CODE_START: .res $1000
|
||||
|
||||
.code
|
||||
.struct SPI_P_Pins
|
||||
; VIA addresses
|
||||
DDR_a .word ; address of the data direction register
|
||||
|
@ -19,38 +19,31 @@ INCLUDE_SYSTEM = 1
|
||||
; 0403 value offset
|
||||
; 0405-04a0 rh high/low, temp high/low, checksum
|
||||
|
||||
.include "io_W65C22.h65"
|
||||
.include "utility.h65"
|
||||
|
||||
; ARGUMENTS
|
||||
; a,x,y can also be used
|
||||
.segment "ZEROPAGE"
|
||||
ARG0: .res 1
|
||||
ARG1: .res 1
|
||||
ARG2: .res 1
|
||||
ARG3: .res 1
|
||||
ARG4: .res 1
|
||||
ARG5: .res 1
|
||||
ARG6: .res 1
|
||||
ARG7: .res 1
|
||||
ARG9: .res 1
|
||||
ARG10: .res 1
|
||||
ARG11: .res 1
|
||||
ARG12: .res 1
|
||||
ARG13: .res 1
|
||||
ARG14: .res 1
|
||||
ARG15: .res 1
|
||||
ARG0 = $10
|
||||
ARG1 = $11
|
||||
ARG2 = $12
|
||||
ARG3 = $13
|
||||
ARG4 = $14
|
||||
ARG5 = $15
|
||||
ARG6 = $16
|
||||
ARG7 = $17
|
||||
ARG9 = $19
|
||||
ARG10 = $1a
|
||||
ARG11 = $1b
|
||||
ARG12 = $1c
|
||||
ARG13 = $1d
|
||||
ARG14 = $1e
|
||||
ARG15 = $1f
|
||||
|
||||
.include "io_W65C22.h65"
|
||||
.include "utility.h65"
|
||||
|
||||
; RETURN VALUE
|
||||
; in a
|
||||
|
||||
.segment "VIA1"
|
||||
; IO1: .res 16
|
||||
IO1 = $6000
|
||||
|
||||
.segment "VIA2"
|
||||
; IO2: .res 16
|
||||
IO2 = $7000
|
||||
|
||||
; struct method
|
Loading…
Reference in New Issue
Block a user