Electronics > Projects, Designs, and Technical Stuff
Snake! on my TTL breadboard CPU with 256 bytes (video and source code)
(1/2) > >>
visrealm:
I recently added a character LCD to my Ben Eater-inspired breadboard CPU, and started writing programs for it.

This is the best I've managed so far in the 256 bytes of program memory it has:



Note: Despite being a C++ programmer for decades, my asm skills are quite sub-standard.  As are my electronics skills.  :D

I have also written an emulator for my CPU. So you can check out the source ASM and run it in your browser here: https://cpu.visualrealmsoftware.com/asm/?e=Snake%20(LCD)&s=500 (Just hit Emulate)

All source code is available for my CPU, my emulator and my character LCD emulator (which I've split out to a seperate repo)

Enjoy !:)

Troy
excitedbox:
Nice. I got up to 30 but then I got myself stuck in a corner. Also took me forever to find one of them cause it was up against an edge. That is some really cool work though. Any plans of building his VGA board and getting it to run on a TV?
MK14:
Thanks.
I really enjoyed your very life-like, emulator.
I managed to modify, and then eventually write program(s), on it. Which ran well.

It is really cool, seeing the LEDs (and displays), flash on and off, in real time, on the emulator.

I heard about his (Ben Eater) custom TTL computer (cpu), a somewhat long time ago. But assumed, it was too limited, to be interesting.
But now I've played with it, the instruction set was actually a fair bit better, than I was expecting. For such a relatively simple computer.

EDIT:
PROs:
I didn't realise. But yours seems to have (improvements over the original one) more and better instructions, with 256 bytes of ram, rather than 16 bytes. I.e. much better. The LCD 16x2 is a nice addition as well.

Slight CONs:
The clra ...Clear all registers (Ra -> Rd), was confusing to me.

As I took 'CLRA', to mean clear register/accumulator A, rather than clear all 4 registers/accumulators.
Since some assemblers, would use CLRA to mean 'Clear only the A accumulator'.
I hadn't read your manual, at the time of playing with it. I got errors when I tried to clrb, clrc etc in my code, as I'd misunderstood its functionality.

Overall, it's amazing and brilliant!  :)
T3sl4co1l:
Cool!  Lot of work, not just the build but the assembler too, but the emulator too!


--- Quote from: MK14 on April 24, 2020, 10:07:03 am ---The clra ...Clear all registers (Ra -> Rd), was confusing to me.

As I took 'CLRA', to mean clear register/accumulator A, rather than clear all 4 registers/accumulators.
Since some assemblers, would use CLRA to mean 'Clear only the A accumulator'.
I hadn't read your manual, at the time of playing with it. I got errors when I tried to clrb, clrc etc in my code, as I'd misunderstood its functionality.

--- End quote ---

Poking asm without reading the manual?  Brave! ...or dumb? :P (Just kidding)

Yeah, becomes clear when contrasted with CLR Rx.  Although it's interesting that MVx src are listed at all.  Are these not just assembly aliases of MOV Rx, src?  (Impossible to tell without encoding given alongside it.)  Or, why enumerate them but not others?

Interesting choice to make Rb the... well, it's not the accumulator as such I guess, but the default (implicit) source.  I'm not sure offhand if this is actually much (or any?) worse than the usual way (accumulator default destination).

And one register is named Acc, though it's not obvious that "ALU output" necessarily works the same as all the other registers?  And if arithmetic and logic instructions return data to a selected register (not just Acc), is it really accumulating anything..?

Well, nevermind.  Again, cool stuff, great work!

Tim
MK14:

--- Quote from: T3sl4co1l on April 24, 2020, 04:53:12 pm ---Cool!  Lot of work, not just the build but the assembler too, but the emulator too!

Poking asm without reading the manual?  Brave! ...or dumb? :P (Just kidding)

Yeah, becomes clear when contrasted with CLR Rx.  Although it's interesting that MVx src are listed at all.  Are these not just assembly aliases of MOV Rx, src?  (Impossible to tell without encoding given alongside it.)  Or, why enumerate them but not others?

Interesting choice to make Rb the... well, it's not the accumulator as such I guess, but the default (implicit) source.  I'm not sure offhand if this is actually much (or any?) worse than the usual way (accumulator default destination).

And one register is named Acc, though it's not obvious that "ALU output" necessarily works the same as all the other registers?  And if arithmetic and logic instructions return data to a selected register (not just Acc), is it really accumulating anything..?

Well, nevermind.  Again, cool stuff, great work!

Tim

--- End quote ---

I know you were joking, but...
When I was seeing it for the first time, I didn't know of the existence of the assembly language manual, or where it was. Also, I was NOT expecting to write any programs for the unit. So, no need to read it anyway.

But, I was then fascinated, and playing with the prime number programs. But, they were taking ages, just to count from 1, to 2. Then eventually 3, Then some time later 4 etc etc. But I wanted to see much bigger (potentially) prime numbers.
Also, at the time, I didn't initially realise the buttons and controls/potentiometers, are actually user adjustable in real time (Wow, just wow!   :-+ :-+). So, the (at max speed), worlds slowest computer not the fastest computer, was defaulting, to a really slow clock speed setting.

So, I adjusted the assembly listing, (I didn't realise there was an alternative prime number program, which already lets you choose the selected number, via a constant near the top), to make it start at a much bigger number.
Then the bug (excitement, not fault) caught me, and I modified more and more stuff. Until I ended up writing complete programs.

My latest program (unfortunately NOT saved), calculated to 32 bits!
Using all 4, 8 bit registers.
By setting the clock speed to maximum (apparently around 6,500 instructions per second), I was (eventually, after much patience), able to count to 2^24 + 1, and beyond!.
At some point, I cheated, optimised it, by putting in a huge bunch of increment instructions, set to be a binary multiple (e.g. exactly 16 Incs), so that the carry flag would still be set correctly, and only one (to make a loop) jnc instruction was needed for every 16 (later 32 or even 64) increment instructions.

It worked out very well. The 256 bytes is much more practicable, than its (I believe) original 16 bytes. Which wasn't very useful, beyond some early learning experiences for people.
The extra instructions, really helps as well.
I've NOT been able to find out much about the original spec "Ben Eater" computer anyway. I've just taken educated guesses, from watching one or more of his videos about how to make it, and what it does.

Another way of naming it, would be to have a register name, which means all of registers, A, B, C and D, such as K, E, Z (EDIT: Z is no good, as could get confused with a zero flag) or something.
Then when you say CLRK, it doesn't get confused with register/Accumulator RA.

E.g. Some processors (if I remember correctly), have Accumulators A and B. But when they are used together (combined), they are called D.

I.e. like the 6809 (and others).
https://en.wikipedia.org/wiki/Motorola_6809


--- Quote ---in the 6809 are the use of two 8-bit accumulators (A and B, which can be combined into a single 16-bit register, D)
--- End quote ---

EDIT: Don't worry too much about it (like me). There are only 26 letters of the alphabet, and many/most instruction sets, end of with some confusing mnemonics in them. (E.g. Motorola (old company name) has a Sign Extend B into A instruction!, with a funny name).
I.e. the (please don't laugh), 'SEX instruction'. (Ignore the PUN, PLEASE!).
https://atjs.mbnet.fi/mc6809/Information/6809.htm
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod