Snake! on my TTL breadboard CPU with 256 bytes (video and source code) - Page 1
Forum section: electronics / projects

author: visrealm
author_rank: Contributor
timestamp: April 20, 2020, 06:12:42 am
content: 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.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)Allsource codeis available for my CPU, my emulator and my character LCD emulator (which I've split out to aseperate repo)Enjoy !:)Troy

author: excitedbox
author_rank: Regular Contributor
timestamp: April 24, 2020, 02:55:25 am
content: 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?

author: MK14
author_rank: Super Contributor
timestamp: April 24, 2020, 10:07:03 am
content: 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!

author: T3sl4co1l
author_rank: Super Contributor
timestamp: April 24, 2020, 04:53:12 pm
content: 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 amPoking asm without reading the manual? Brave! ...or dumb?(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

author: MK14
author_rank: Super Contributor
timestamp: April 24, 2020, 05:32:11 pm
content: Quote from: T3sl4co1l on April 24, 2020, 04:53:12 pmI 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 computernot 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, Icheated, 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_6809QuoteEDIT: 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

author: visrealm
author_rank: Contributor
timestamp: April 30, 2020, 07:18:25 am
content: Wow! Sorry, I missed these replies. Must have notifications turned off.Thanks for the feedback, all. I definitely have some work to do on the intruction set (and mnemonics). I was completely winging-it. It's missing a few instructions I'd like to add, some mnemonics suck, etc. Previous to this, my assembly experience was very limited.@MK14 - Awesome work, man! I didn't expect anyone to spend more that a minute or two playing with it. That's fantasticThere's some undocumented features. One being, you can set a URL parameter s=<speed> to set the starting speed of the emulator (1 -> 500). If you use that when loading the assembler, it also passes on to the emulator. eg.https://cpu.visualrealmsoftware.com/asm?s=300I have planned to have a #directive in the assembler to tell it to run this program at a given speed, but, haven't yet.For anyone interested, I've recently uploaded a video showing how this works with the assembler, emulator, program loader, and the physical machine.You can check it out here:My 8-bit breadboard computer, assembler, emulator and esp8266 program loader. An overview.CheersTroy

author: visrealm
author_rank: Contributor
timestamp: April 30, 2020, 07:26:39 am
content: Quote from: excitedbox on April 24, 2020, 02:55:25 amNaa. Not without first giving it a larger address space anyway. 256 bytes is much more useful that 16 (can fit a game in 256), but not nearly enough do do anything useful with VGA. It has a 32KB SRAM on board, but I'm only using 8/9 of the 15 address bits. That's my next immediate plan.