G-Pascal for Ben Eater’s 6502 board

Author: Nick Gammon

Date written: February 2022

On-board assembler, tiny Pascal, and text editor for Ben Eater’s board

Demonstration video here on Vimeo.

Includes:

Both the Pascal compiler and assembler are quite fast. Any program that will fit into memory will compile in a few seconds. For example, using a 1 MHz clock:


How much does it cost?


Hardware modifications suggested/required


More VIA pins are available

I rewrote the LCD code to use 4-bit mode on the HD44780U LCD display. This frees up 4 fairly valuable pins on the VIA (versatile interface adapter) chip for other uses, such as developing an SPI interface.

Pins PA0 and PA1 on the VIA are used for the serial interface, as well as CB2 to detect the start bit for incoming serial data.

That leaves 7 pins for your own use (PA2, PA3, PA4, PB0, PB1, PB2, PB3).


Example programs

As an example of what can be done, there is a (roughly) 700-line “Adventure” program available here for compiling. That demonstrates a lot of the features of the compiler and is a fun game to try out. Note that running this requires a small hardware modification to Ben’s board to make more of the RAM available, as described here. This program was originally written in 1982 for the Apple II version of G-Pascal, and has been modified slightly to conform to the syntax of this compiler.

Other example programs are prime number generation, square roots calculation, and a guessing game.

Or, you can play with assembler coding and make LEDs blink. :)

Example code here.

The code is released under an extremely liberal license (MIT License), which basically means you can do anything at all you like with it, except claiming you wrote it yourself. ;)


Ben Eater’s 6502 board

Ben does a fabulous series of YouTube videos about wiring together this 6502 breadboard computer. The first in the series is here.

It really is extremely interesting and educational. I strongly recommend you watch the video series and consider supporting Ben’s Patreon.

You can buy a kit from Ben. Ben has put a lot of work into making these educational videos — I suggest you support him and his future endeavours by buying his kits from him.


Support for other 6502 boards

There is no particular reason this code wouldn’t run on other 6502 set-ups. You would need to be aware of the hardware addresses of things like your RAM (which presumably starts at 0x0000 because you need access to the 6502 hardware stack at 0x0100) and your ROM (which presumably covers 0xF000 to 0xFFFF because of the need to have NMI/Reset/IRQ vectors).

You may need to modify the way the code interfaces with the hardware, depending on your personal setup.


Construction notes

My board was made from a genuine kit from Ben Eater’s website, however I largely connected the pins using wire-wrapping rather than breadboard wires.

There were several reasons for this:

Wire wrapping is not much slower than putting in breadboard wires. You still have to cut the wires to length and strip them, so that part is much the same, except when the supplied breadboard wires happen to be exactly the right length. The only extra step is to insert the wire into the tool and twirl it around to bind it to the post.

The extra things you need to do wire-wrapping are:

There are various tutorials around for how to wire-wrap including this one from Sparkfun.


Hardware theory and notes

A considerable amount of detail about the 6502 and suggested schematics are at Garth Wilson’s 6502 primer: Building your own 6502 computer. There is a schematic on his site which looks similar to the one Ben used. There is also a lot of background detail there and suggestions for alternatives.


Questions or comments

Questions or comments may be posted by joining my forum.


This site

Source code and documentation on GitHub

Other sites


License

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

Source code licensed under the MIT License.