Ben Eater 6502 Kit — Day 19

avatar

2.jpeg

Up until now the computer was run either by a fairly slow 555 timer or even slower single stepping. This was possible because the WDC-65C02, unlike the R-65C02, can be run by any clock from 0 … 14MHz. It's time to speed things up. Not to the full 14MHz — that might cause problems on a breadboard. Because of this only a 1 MHz oscillator is used.

4.jpeg
Insert a 1MHz crystal oscillator

Unlike Ben Eater I permanently attached the clock module to the system so it's always ready if some debugging is needed. I also added a helpful jumper cable to quickly change between the crystal oscillator and the clock module:

3.jpeg
Jumper cable

I have ordered a switch to be places where the jumper cable is currently for even more convenient switching. Next an update of the software is needed as the computer is now a lot faster than the display clear operation. And for all other operation it's right at the border. Best to add a busy check to all display operations:

;;
;   Wait for instruction to finish
;
.proc       Wait
        PHA
        VIA_Set_B   #%00000000      ; Set Port B to all input

Busy:       VIA_Out_A   #LCD::RW        ; Start LCD read operation.
        VIA_Out_A   #(LCD::RW | LCD::E) ; Enable Output if LCD status
        BIT     VIA::IRB
        BMI     Busy

        VIA_Out_A   #LCD::RW        ; End LCD read operation
        VIA_Set_B   #%11111111      ; Set Port B to all output
        PLA
        RTS             
.endproc

Using .proc and .endproc makes the Busy label local so it won't conflict with any future subroutine. Ben Eater also uses LDA and AND to check the busy flag. But that's not needed.

  • When you load a value with LDA with the the negative flag is set when bit 7 is set. So the AND instruction isn't needed as you could also do a BMI (branch on minus)
  • The 65C02 also as a special instructions for checking bits in memory which is called BIT. The BIT operation performs and AND between the accumulator and the address given and sets the negative, overflow and zero flag. As I'm only interested in negative flag I don't load the accumulator with any value.


You find the source code for the LCD macro on GitLab: 6502Tutorial — Kit/Library



0
0
0.000
1 comments