• entries
222
606
• views
593031

# Running BBC BASIC on a home-built computer

1791 views

This computer needs a name - I'd welcome any suggestions!

I have built a circuit on another piece of stripboard that will handle memory, clock signal generation and the Z80 itself.

A few posts ago I was wondering about how I'd partition memory. To date I've been using a very simple circuit where the lower 32KB of addressable memory is mapped to ROM and the upper 32KB is mapped to RAM. As my ROM chip is 128KB and I have two 32KB RAM chips, this seems a bit wasteful.

The memory layout I'm now using is quite simple: the upper 32KB is still mapped to RAM. However, only the first 16KB is mapped to ROM, and the three most significant bits of the ROM chip's address lines are connected to a device on the I/O board so that one of its eight 16KB "pages" can be swapped in. The next 16KB will be mapped to RAM, and the most significant bit of the RAM chip's address is connected to the same device on the I/O board so one of its two 16KB "pages" can be swapped in.

For more information, see the Wikipedia article on bank switching. There is a potential problem here; the Z80 uses particular fixed addresses for certain operations. The three most obvious ones are $0000 (jumped to on reset),$0038 (address of maskable interrupt handler) and \$0066 (address of non-maskable interrupt handler). As which 16KB bank switched in at power-on is effectively random, the easy way around this problem is to ensure that the first 256 bytes or so of every ROM page has the same code assembled on it. This means that whichever page is swapped in on boot doesn't matter, as the same common boot code is available on each page.

The assembled memory board looks like this:

Click to toggle labels

I have only attached one of the 32KB RAM chips. The wiring was becoming a bit of a nightmare (I think I'll need to solder to the track side of the stripboard to fit in that other RAM chip) so for the moment the system can only access the fixed 32KB RAM. I haven't yet added the device on the I/O board to handle bank switching, so for the moment the ROM is permanently configured to access the first 16KB page by pulling the its three externally controllable address lines low.

That said, this machine does genuinely run BBC BASIC (the last system only ran a mockup with a dummy header at the top of the screen). I've done quite a bit of work on the OS in the emulator and it works pretty well there, and with a minor adjustment to cram it onto a single 16KB page it works well on hardware too.

Click for video (664KB XviD MPEG-4 AVI)

The row of chips along the bottom of the memory board are responsible for generating the clock signals that drive the computer. If this looks needlessly complex, that's because it can run at either 10MHz or 2MHz and generates the E signal for LCD access. The CPU needs to drop to 2MHz when accessing the LCD (the LCD driver can't keep up, otherwise) so I'll probably end up connecting the input for this 2MHz/10MHz switch to the LCD chip enable pins so that normally the system runs at 10MHz but drops to 2MHz when accessing the LCD. Allowing the user to drop to 2MHz to save power is an appealing idea, however...

Looking at that picture brings a tear to my eye. It takes me back to my days with GW Basic (and later Qbasic) alone in my dark room with nothing but the white glow of the text of my Basic code for my Text RPG. Where I began on a path that led me.. here. ahem.

But yeah I am mightily impressed - you built your own computer and OS and language environment for it from scratchish. To me its nothing short of wizardry.

that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.

that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.

Quote:
 Original post by Daerax Looking at that picture brings a tear to my eye. It takes me back to my days with GW Basic (and later Qbasic) alone in my dark room with nothing but the white glow of the text of my Basic code for my Text RPG. Where I began on a path that led me.. here. ahem. But yeah I am mightily impressed - you built your own computer and OS and language environment for it from scratchish. To me its nothing short of wizardry.
Most of the hard work on the software side is done by BBC BASIC; all I've had to do is cobble together a few routines to sit between it and the hardware. The choice of BBC BASIC is partially nostalgia, as that was the first proper programming language I learned myself!

Thanks for the comment and kind words! [smile]

I cant wait to see more progress.
I felt cool earlier today when I finally got my pong for my ti 84 somewhat working and now I see this!

You should definately write a tutorial on how to build your own Benryves Machine from start to finish!

Cheers :)

Quote:
 Original post by moose517 that is some amazing work you are doing there, cant wait to see your finished product, its gonna kick some major booty.
Cheers, though I wouldn't exactly describe 70s-era computing as "kicking major booty". [wink] (The Z80 was originally released in 1976).
Quote:
 Original post by Falling Sky I cant wait to see more progress. I felt cool earlier today when I finally got my pong for my ti 84 somewhat working and now I see this! You should definately write a tutorial on how to build your own Benryves Machine from start to finish! Cheers :)
I'm glad to hear you've got your pong game working (even if only "somewhat") - getting started with assembly is the hardest part! Hopefully things will be easier from now on. [smile] If you haven't seen it, the Z80 User Manual is a good reference on the workings of the CPU at a hardware and software level. Thomas Scherrer's Z80 page is extremely useful and has some bare-bones Z80 system designs if you wanted to give yourself an idea of how a Z80 computer may be constructed.

I'm not sure that a tutorial on building a computer from parts would really be much fun to read; it really is a case of connecting the dots ("where it says A0, A1, A2 &c on the CPU, connect them to A0, A1, A2 &c on the RAM and ROM chips") with a few bits of glue logic to hold the thing together. If I get this system working well enough I may design a PCB for it that could be much smaller, more robust and easier to solder than the existing system and get that professionally made up, and publish that online for anyone who really wanted to put it together themselves, but the real fun is in designing and building the hardware yourself, not copying someone else's plans.

Christ, last time I read your journal you were programming a calculator or something - when the hell did this start? Just been scrolling down your journal and it seems to have been going on for ages.

Just remember what happened in Terminator. That must have started out something like this.

Well, we have a name then - 'Terminator' :D

Pretty cool

Quote:
 Original post by EasilyConfused Christ, last time I read your journal you were programming a calculator or something - when the hell did this start?

I see someone hasn't been reading Weekend Reading often or closely enough [smile]

## Create an account

Register a new account