On your code there, note that you can use [code] and [/code] around it to make it come out monospaced (as all source code should be) and with the spaces all there, instead of it reducing six spaces for example down to one. It's like the <pre>...</pre> (preformated) tags in html. (I did another trick here to keep [code] and [/code] from doing their job.)
Also, the registers should be specified by name to make them much more intelligible to humans, to make you more productive, and to get fewer bugs, and to make the code more maintainable. Then the assembler converts the names to numbers, according to the EQUates you put earlier in the code. So before referring to the registers in the I/O ICs, you'll have something like:
Code: Select all
VIA1: EQU $6000 ; Base address of first 6522 VIA on SBC.
VIA1PB: EQU VIA1 + 0 ; Addresses of various registers in 6522. First, Port B.
VIA1PA: EQU VIA1 + 1 ; Port A
VIA1DDRB: EQU VIA1 + 2 ; Data Direction Register for Port B
VIA1DDRA: EQU VIA1 + 3 ; Data Direction Register for Port A
VIA1T1CL: EQU VIA1 + 4 ; Timer 1 Counter Low byte
VIA1T1CH: EQU VIA1 + 5 ; Timer 1 Counter High byte
VIA1T1LL: EQU VIA1 + 6 ; Timer 1 Latch Low byte
VIA1T1LH: EQU VIA1 + 7 ; Timer 1 Latch High byte
VIA1T2CL: EQU VIA1 + 8 ; Timer 2 Counter Low byte
VIA1T2CH: EQU VIA1 + 9 ; Timer 2 Counter High byte
VIA1SR: EQU VIA1 + $A ; Shift Register
VIA1ACR: EQU VIA1 + $B ; Auxixiary Control Register
VIA1PCR: EQU VIA1 + $C ; Peripheral Control Register
VIA1IFR: EQU VIA1 + $D ; Interrupt Flag Register
VIA1IER: EQU VIA1 + $E ; Interrupt Enable Register
VIA1PANOHS: EQU VIA1 + $F ; Port A, but with No Handshaking
VIA2: EQU $5000 ; Base address of second 6522 VIA on SBC.
VIA2PB: EQU VIA2 + 0 ; Addresses of various registers in 6522. First, Port B.
VIA2PA: EQU VIA2 + 1 ; Port A
VIA2DDRB: EQU VIA2 + 2 ; Data Direction Register for Port B
VIA2DDRA: EQU VIA2 + 3 ; Data Direction Register for Port A
-----etc.------If you only have one VIA, you can drop the VIA1, VIA2, etc. and just use the register names, then your piece of code above will be something like:
Code: Select all
LDA #$FF
STA DDRB ; Make both PA and
STA DDRA ; PB to be all outputs.
LDA $00 ; Load the value (3) from ZP RAM
STA PB ; and cause both PA and
STA PA ; PB to reflect that value.