Hi All.
It's been a while, but the 6502 bug bit me again.
Now, technically, this is not my first build but my second. I still haven't moved from breadboard and didn't want to strip down my first effort - which does work (and I wanted to keep it that way). This was a Ben Eater "clone".
This time I have used an ATF22V10C for address decoding. So, my 2nd build has the VIA in zero page ($F0 - $FF), has a larger ROM (which I only use 32K of - SST39SF010A) and a full 32K of RAM. I've also included a ZIF. It's sort of a deluxe version of my first build. My memory map is as follows...
Code:
RAM 0000 - 00EF
VIA 00F0 - 00FF
RAM 0100 - 7FFF
ROM 8000 - FFFF
When I build, I use an Arduino Mega like Ben does in his videos to monitor how the system is performing. However, I'm running into an issue I just can't wrap my head around and am reaching out for any assistance that can be offered.
The system has no yet output (like serial, for example) so I have to look at the Arduino Mega monitor output to establish what my WDC 65C02 is doing. I also have a WDC 6522 and have it wired up to 8 LEDS. I wrote a simple program to store 10101010b in PORTA and EOR it with 11111111b in a loop - this gave alternate LEDs blinking and worked as intended. When I "upgraded" this for a running LED (Knight Rider style!) it didn't work. I ended up rewriting some code to test why it didn't work. In essence, incrementing an 8-bit number and displaying it on the LEDs connected to the VIA.
Here's both the code and the monitor output. $00 is loaded into A and then stored in PORTA - but the monitor shows $FF is actually stored - and ALL the LEDs light up, which suggests that is the case. What is striking is that it NEVER gets to execute the INC instruction ($E6) at location $800A. Instead, for some reason I cannot fathom, it jumps over it and the code goes haywire after that. Resetting just results in the same output in the monitor. PHI2 is around 1Hz to facilitate reading what's going on.
So, why does it write $FF although we start with $00 and why doesn't it execute the INC - any ideas?
CODE:
Code:
Sections:
00: "org0001:8000" (8000-800F)
01: "org0002:fffc" (FFFC-FFFE)
02: "org0003:27ffe" (7FFE-8000)
Source: "via_test2.asm"
1: ; Test program for blinken lights on VIA.
2:
3: PORTB = $F0
4: PORTA = $F1
5: DDRB = $F2
6: DDRA = $F3
7: VAL = $80
8:
9: .org $8000
10:
11: reset:
12:
00:8000 A9FF 13: lda #%11111111 ; Set all pins on PORTA to outputs.
00:8002 85F3 14: sta DDRA ; Write to DDRA.
15:
00:8004 6480 16: stz VAL
17:
18: b0:
00:8006 A580 19: lda VAL
00:8008 85F1 20: sta PORTA
00:800A E680 21: inc VAL
22:
00:800C 4C0680 23: jmp b0
24:
25:
26:
27:
28: ; 6502 Reset Vector.
29: .org $FFFC
01:FFFC 0080 30: .word reset
31: ; Needed to correctly create a ROM image for the SST39SF010A 132Kb ROM.
32: .org $27FFE
02:7FFE 0000 33: .word $0000
34:
35:
36:
Symbols by name:
DDRA E:00F3
PORTA E:00F1
VAL E:0080
b0 A:8006
reset A:8000
Symbols by value:
0080 VAL
00F1 PORTA
00F3 DDRA
8000 reset
8006 b0
MONITOR OUTPUT: (running off into oblivion)
Code:
1111111111111100 00000000 fffc r 00
1111111111111101 10000000 fffd r 80
1000000000000000 10101001 8000 r a9
1000000000000001 11111111 8001 r ff
1000000000000010 10000101 8002 r 85
1000000000000011 11110011 8003 r f3
0000000011110011 11111111 00f3 W ff
1000000000000100 01100100 8004 r 64
1000000000000101 10000000 8005 r 80
0000000010000000 00000000 0080 W 00
1000000000000110 10100101 8006 r a5
1000000000000111 10000000 8007 r 80
0000000010000000 00000000 0080 r 00
1000000000001000 10000101 8008 r 85
1000000000001001 11110001 8009 r f1
0000000011110001 11111111 00f1 W ff
1000000000001011 10000000 800b r 80
1000000000001011 10000000 800b r 80
1000000111111111 00000000 81ff r 00
1000001000000000 00000000 8200 r 00
0000000111111110 10000010 01fe W 82
0000000111111101 00000001 01fd W 01
0000000111111100 00110110 01fc W 36
1111111111111110 00000000 fffe r 00
1111111111111111 00000000 ffff r 00
0000000000000000 00000000 0000 r 00
0000000000000001 00000000 0001 r 00
Thanks in advance for any ideas as to why or additional diagnostics to check other things.
Dave