r/beneater • • Jan 30 '23

is it possible to just feed binary code (translated from python) into a breadboard computer with no prior programming and it to work?

i am thinking about trying to make a gameboy with a custom printed pcb

2 Upvotes

17 comments sorted by

5

u/[deleted] Jan 30 '23

When you say 'no prior programming' it sounds like you mean with no programming experience of your own. If that's the case I suspect you may be being a little ambitious. That is likely more something you will do a year or two down the line. There are maybe diy handheld kits out there that you could try first? There will be a kit somewhere powerful enough to run existing emulators. Understand how those systems connect together would be fun.

Also if you were to learn how to reverse engineer such things yourself then you'd find that the gameboy had a lot of very specific hardware in it that likely wouldn't be covered in your breadboard cpu. And depending on what you mean by a breadboard computer maybe it would never be quite good enough. Even the original gameboy ran on some fairly sophisticated silicon. If you mean making it out of basic logic gate chips then you might struggle to make something powerful enough because of the limits of through hole components. Though if you mean something similar to the 6502 project then maybe you could manage it with more modern parts. You could certainly make a game boy or if equivalent though hole components.

That said maybe you'd get more out of leaning less ambitious circuits!

1

u/GalacticJunk23 Jan 30 '23

i think i might have worded my question wrong, because i more meant making something on a breadboard (or custom pcb) that looks like a gameboy and that can run maybe pong at most. i also meant that it would work without coding an OS or something like that onto the thing

6

u/[deleted] Jan 30 '23

Yeah that's a pretty sophisticated project to make from scratch. Certainly possible with a little experience but when you're ready then you'll know.

Maybe a neat project would be to look in to some kind of DIY handheld kit. Adafruit has a few different ones based on the raspberry pi, pico, and arduino.

https://www.adafruit.com/search?q=Console

Raspberry pis are difficult to get hold of at the moment. But using one of the systems on a board kits would mean you could run any software designed for it and there is quite a large community using them to run emulators. A common benchmark is running gamecube and ps2 games

20

u/ToThePetercopter Jan 30 '23

Python is an interpreted language, so unless you wrote your own python interpreter for the breadboard computer (incredibly challenging / impossible) or write some sort of python to breadboard compiler, its not a great language to use.

Some people have made compilers for other languages though so maybe have a look at them.

3

u/rolf-electronics Jan 30 '23

The short answer is NO.

A computer is a physical device which only understand +5 volt en - volt. The most basic way to program a computer is with switches, this has been done in the past. See pictures of the ENIAC. This level is called machine language, and it's typical for a certain machine [computer]. Next up is using, like Ben examples, things like STA 05H. Which means store 05H in register A. But you cannot feed this into a computer. An assembler makes the translation to f.i. 01h05h. 01 is the instruction STA and 05h the data. So the computer gets 0000 0001 0000 0101. One step higher is using instructions like if() then{} else{] or while() etc etc. A compiler makes the translation from if,then,else to STA MOV etc. Now making an assembler is one thing which is largely a translation job, but making a compiler suitable for C++ or Python is very very complicated. For breadboard computers there are assemblers. That's if seen one usable, customasm were you can define your own CPU. But compilers, it can be done but it's a looooooooooooooooot of work and complex. Breadboard computers are basic devices more a learn experience than practically useable and most of them have low clockspeed, which makes large complex programs basically impossible to run. A solution could be to use a subset from C++.

-1

u/istarian Jan 31 '23

You really aren't contributing much there to be honest.

Programming a computer with switches generally implies you have a front panel that allows you to directly control the address lines, data lines, cpu state, etc as well as observe the state of the bus.

The general idea being that you load an address, load the data, and then store the data at the address. And you're essentially single-stepping the system as needed.

1

u/rolf-electronics Feb 01 '23

ok, I was just trying to help and try to explain that what that guy wants is not so simple. But apparantly I failed

1

u/JimHeaney Jan 30 '23

If you have the proper compiler, then yes.

2

u/rolf-electronics Jan 30 '23

Does compilers don't exist.

2

u/hetremis Jan 30 '23

They do but I think they’re only for making executables

1

u/rolf-electronics Jan 31 '23

Than name me a few, suitable for breadboard

1

u/hetremis Jan 31 '23

I just said they were only for executables.

0

u/istarian Jan 31 '23

In principle, it is technically possible, albeit difficult to do from scratch.

The real snag is going to be translating from a python program to a roughly equivalent program in assembly/machine language and then getting the desired results.

Normally your Python environment is an additional layer that sits on top of a pre-existing operating system or libraries that are capable of controlling the computer in question.

With a breadboard computer, you don't necessarily even have regular input/output devices or any code to drive them. So something as simple as print("Hello World! may not even be possible.

0

u/Peiple Jan 30 '23

Well yeah, that’s how microprocessors like the 6502 work. The question is more how you’ll get the bytecode to the processor itself. It’s going to read one byte per clock cycle off the data pins, and based on that value either read or write values to the address pins and data pins on subsequent clock cycles. You could theoretically bit bang it from python, but your timing is going to have to be really exact if you want it to work properly. Using something like python is going to make it even more challenging since python is pretty slow.

Is there a particular reason you want be interpreting on the fly rather than just compile your code in advance? Just write the bytecode to rom/ram and then have the mpu handle the nitty gritty

-1

u/DaddioSkidoo Jan 30 '23

Sounds like what you're looking for is something called a ROM emulator. You have a host system downloading into a a card which connects in place of a ROM.

Back in the old days, I recall someone doing that kind of thing with a parallel port and a few discrete components. Today, it's a zif socket and a cheap programmer.