beholder, fine-grained address decoding takes more logic and more propagation delays. For slow systems, you can stop wasting and save less than a quarter of the memory map, but turning up the speed requires the simpler logic, and the truth is that 64K of assembly language is an awful lot for a single hobbyist to fill. My first big commercial software project (big considering I was the only one working on it) was in 65c02 assembly language and IIRC it took about 24K. The list file printed out to about an inch of paper. I learned later how to do the same things more efficiently anyway. If you need more memory, it will most likely be for either a lot of data, or an inefficient C compiler. (See my C-versus-assembly example of an empty count-to-100 loop just over half way down the page in my article on the relevance of assembly language today, at
http://wilsonminesco.com/AssyDefense/ .
On your code there, note that you can use [co
de] 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 [co
de] 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:
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.------
When writing on the forum, the box we have to write in does not show the vertical alignment right, so you'll probably want to copy out of a text editor.
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:
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.
These and many more basic programming tips are in the
programming tips page of the 6502 primer.