I am translating the ehBasic program below into the assembler below that. The Basic program works and blinks an LED on the VIA's PB0 pin. So I typed the assembler into the SBC2.7 machine language monitor. The assembler program runs in about six second, but frustratingly the LED does not blink on the exact same machine!
This is embarrassing because I know assembler, and it's a nearly line by line translation. But I can't figure out what I am doing wrong with such a simple program. Can anyone help?
Code:
10 REM Toggle VIA2.PB0 LOW and HIGH
20 REM Set up common VIA2 constants
30 Via2PRB=$7f60
40 Via2DDRB=$7f62
50 FOR X = 0 TO 16
60 REM Set VIA2.PB0 as output
70 A = PEEK Via2DDRB
80 A = A AND $FE
90 POKE Via2DDRB, A
100 A = PEEK Via2PRB
110 A = A EOR $01
120 POKE Via2PRB, A
130 FOR Y = 1 TO 100
140 NEXT Y
150 NEXT X
Code:
1000- . A0 16 LDY #$16
1002- -b. AD 62 7F LDA $7F62
1005- )~ 29 FE AND #$FE
1007- .b. 8D 62 7F STA $7F62
100A- -`. AD 60 7F LDA $7F60
100D- I. 49 01 EOR #$01
100F- .`. 8D 60 7F STA $7F60
1012- .. 20 19 10 JSR $1019
1015- . 88 DEY
1016- Pj D0 EA BNE $1002
1018- ` 60 RTS
1019- Z 5A PHY
101A- . A0 00 LDY #$00
101C- Z DA PHX
101D- ". A2 00 LDX #$00
101F- J CA DEX
1020- P} D0 FD BNE $101F
1022- . 88 DEY
1023- Pz D0 FA BNE $101F
1025- z FA PLX
1026- z 7A PLY
1027- ` 60 RTS