Jump to content
LL Medico Diapers and More Bambino Diapers - ABDL Diaper Store

8-Bit Computer Programming


Recommended Posts

A while back, I designed an 8-bit computer based on the Z80 processor. I wrote up instructions on how I did it and included schematics (I posted it to a DIY website) and I also included a small program for it. The program takes numbers from the user and just adds them together. I later rewrote it to do a bit wise XOR operation on the numbers. Then I wired an LCD display to it (16x2 chars) and rewrote the program to convert the binary number to hex (in ascii format) to print to the display.

 

More recently, I removed the display and wrote a new program. I haven’t actually programmed the computer yet, but I am about to. This program is a little bit meta. Again, it takes numbers from the user. This time, the numbers are going to be pure op code. They get stored in RAM and I chose a non-existent op code to use as a stop code. As the user enters numbers, they get checked against the stop code. Without getting too specific/technical, the number stored in location C gets moved to RAM. The user enters a number which is then stored in location A. The number in location B gets moved to C and then A gets moved to B. B and C are used together to be checked against the stop code. If no match, the process repeats. If there is a match, some extra stuff gets thrown in RAM (a jump code that acts as a software reset), then the computer jumps into the beginning of RAM space and starts executing from there.

 

Essentially, the program I wrote makes the computer self-programming in a way. The user enters a series of op codes, which the computer stores in memory and executes. It may sound complex, but trust me, it is not. Literally “ask for a number, move numbers around, compare, repeat.” As for if it works, I’ll update in a little bit. I had to rebuild my EEPROM programming circuit and had just finished when I came here to post. I still need to do the actual programming, which may or may not be possible. I’m going to say it’s all good, but here’s why I’m not 100%.

 

When I went into the electrical program at my local community college, we were required to buy a learning kit that teaches soldering and wiring (we had to build it ourselves). The assembled kit is for teaching digital electronics, but is less than ideal for what I attempted with it today. I’m using it as the programmer, which is fine. It can also be set up to read from the chip, which I’ve done before. However, it cannot be set up to do <I>both</I> because of how the kit was designed. I tried to find a way to force it to do both and it eventually made the sound of an electrical component coming to its untimely end (I also got a scent of really stale pee). I didn’t see any smoke and I couldn’t find a faulty component (I did see a capacitor that looked like it was wanting to die, which coincides with the sound I heard). If I didn’t destroy anything major, I should be able to get the EEPROM programmed. If I did destroy something, I’ll need to rebuild the programmer circuit as well as redesign it to work on a different breadboard. Again, I’ll update when I make the attempt and test it.

 

*UPDATE*
idk if I programmed it (correctly), but it isn’t working. This is an issue I’ve had on the computer since I very first built it. It tends to not want to run correctly. Will have to do more tests at a later date.

 

*UPDATE 2*

Here’s the code because why not:

LD SP, 0EDBFH ;Stop code
LD IY, 00FEH ;IY keeps track of where in RAM to store inputted codes. Start in last two locations of ROM because two junk bytes are attempted to be written
IN A, (00H) ;Grab byte from user
LD (IY+00H), E ;E contains next byte to be written to RAM. This line writes that byte to RAM
INC IY ;Gets IY ready for the next write
LD E, D ;Move D to E
LD D, A ;Move A to D
LD H, E ;Copy E into H
LD L, D ;Copy D into L
OR A ;Clears the Carry flag
SBC HL, SP ;Subtract SP (stop code) from HL
JP NZ, 0007H ;If SP = HL, the following code is executed. Otherwise, jump back to the IN instruction
LD (IY+00H), 0C3H ;Insert the Jump op code at the end of what the user put in
LD (IY+01H), 00H ;Low Byte for the Jump instruction
LD (IY+02H), 00H ;High Byte. Jumping to 0000H causes the program to go through the initialization stages again. Useful for if user modified anything with their own code
JP 0100H ;Jump to the first address in RAM space. My circuit starts RAM space at 0100H (only the lower byte of addressing is wired)
.END
Edited by LonesomeLamp
Added code because i got enthusiastic
  • Like 1
Link to comment

I cannot believe they are still selling Z-80's. You, Techmoan and the 8-Bit Guy would get on famously.. Have you looked at any of the TRS-80 emulators they have out? I am thinking of getting one just to get my Model I Level II BASIC fix although I prefer compiled languages; they go like a bastard. But I would like to play around with an NUC,say, a hexacore with DisplayPort and bluetooth/Wi-fi. I think they are up to that now

Link to comment
2 hours ago, Little Christine said:

I cannot believe they are still selling Z-80's. You, Techmoan and the 8-Bit Guy would get on famously.. Have you looked at any of the TRS-80 emulators they have out? I am thinking of getting one just to get my Model I Level II BASIC fix although I prefer compiled languages; they go like a bastard. But I would like to play around with an NUC,say, a hexacore with DisplayPort and bluetooth/Wi-fi. I think they are up to that now

Not only are they still selling/manufacturing them, they even have new versions of them that support serial communications and have internal oscillators. Lemme look one up on Digi-Key.

Using the app doesn’t give a url I can share. The processor is Z180 (Z80180)

2 hours ago, Firefly 35 said:

@LonesomeLamp you may want to switch to an arduino for your programming concoctions.  It's open source and can do a lot more than the Z-80. 

I have a schematic drawn for it already and most of the coding is done. Just got some things I need help getting sorted out. That is if I didn’t lose any of it when I last formatted my hard drive (my C drive died on me very shortly after I bought an SSD and idk what I managed to get backed up before that happened).

Link to comment
2 hours ago, Firefly 35 said:

@LonesomeLamp you may want to switch to an arduino for your programming concoctions.  It's open source and can do a lot more than the Z-80. 

I think working with the restrictions and limitations might be part of the fun.

EDIT: Their reply just popped up for me as I sent this reply. /shrug.

Link to comment
16 minutes ago, kasarberang said:

I think working with the restrictions and limitations might be part of the fun.

EDIT: Their reply just popped up for me as I sent this reply. /shrug.

??

I don’t mind the limitations, but programming EEPROM is tedious when you’re using 16 switches to program it byte-by-byte. If I had to use the full address range, it would take 24 switches! Thankfully, my new program is only 39 bytes. I might program my Uno to put this specific code into it and see if I can figure out the page write function while I’m at it. The problem I’m facing with using the Uno in general is finding a breadboard big enough to hold the circuit but small enough to carry around.

Link to comment
20 minutes ago, LonesomeLamp said:


The problem I’m facing with using the Uno in general is finding a breadboard big enough to hold the circuit but small enough to carry around.

Maybe just get a bunch of average sized breadboards and stick them together with glue or doublesided tape. Some breadboards I've seen have little pieces that click together to make bigger breadboards.

Maybe not optimal but it's an idea.

Link to comment

That’s the thing though. One breadboard is part of the BASIC Stamp microcontroller (it’s the homework board and it’s smol and not possible to connect any other boards to it). I’ve another one floating around <I>somewhere</I> that honestly should barely be big enough. Hmm. If I can force one of my junk PCs to connect to my tv (I’ll need to set it up to account for overscan), I could use the remaining space on the board the computer is on. The last time I tried to get the Uno to communicate with Ubuntu, though, didn’t quite go so well. I got it to, but it was a process. What I’d really like to do is design a PCB that houses the major components of the computer. Namely the CPU, RAM and ROM and the glue logic that allows them to work together. I might add power management to it too (voltage regulator and caps). Stuff like I/O and clock would be on separate boards.

Link to comment

All I can say i feel like I've entered a time warp.   I was surprised anyone was still doing this type of thing.  The great part would be an understanding of what actually happens.  I go back to the 1960s and mainframes  and had almost forgot about all of this.

Link to comment

Ahhhh! Good old FORTRAN IV in Extended Binary Coded Decimal Interchange Code. and God help the poor bastard who dropped the box of Hollerith cards that had a full COBOL program on them and had them scatter all over hell and begone "Wanna play 520 pickup; And they have to be in ORDER'

I remember the announcement of the development of FORTRAN in  about 1956. And back further when a 'computer" was a person who did the work. The meachines were called "electronic brains"; all 4 of them

We call these things that we are using here "computers". Not really, they are computerized communications deviced. I wonder if that person who first put the phone handset on that acoustic coupler had any ideaof what that would lead to; 9600 baud was screamin' fast at that tiem. Have fun with this

 

They had light pens and CRT terminals in 1959

Link to comment
3 hours ago, Little Christine said:

and God help the poor bastard who dropped the box of Hollerith cards that had a full COBOL program on them and had them scatter all over hell and begone "Wanna play 520 pickup; And they have to be in ORDER'

 

Oh god, that would have been a nightmare. I don’t even want to imagine it lol.

 

As for my own project, I gutted my junk machines a short time back and had to perform computer surgery on one. I’m about to try to turn it on, but I may have to hunt down an adapter I’ve lost (the one that connects the psu to the 4-pin aux plug on the motherboard (now that I think about it, I may have had to use it for the graphics card in my gaming pc)). Will update when I get something figured out.

 

*UPDATE*

I plugged it in and it (psu) started screaming at me

 

*UPDATE 2*

I grabbed the wrong PSU smh. The one I grabbed was from a very old machine that was pretty much already dead when I got it. I grabbed another PSU and it’s the good one and even has the 4-pin plug built in. It should work this time.

 

*UPDATE 3*

*major facepalms*

I just realized I can’t use the machines anyway because they don’t have the software (Arduino IDE) installed. I can’t install it because the machines won’t have internet access. I realized this when I remembered that the machine’s Ethernet port quit working and I’d have to hunt down a USB-Ethernet adapter. At this rate, I’d be better off just to suck it up and carry this large breadboard around. Either case, I’m going to need to build a new circuit anyway.

Edited by LonesomeLamp
Updates
Link to comment

The TRS-80 had an interesting feature. Though it used ASCII characters, which meant a 129 size rather and 256,The CHR$ character set went to 2556, with the other 128 being spacing and "compression" variables

Link to comment
  • 5 weeks later...

I finally got the EEPROM programmed. I used the UNO as suggested, but I kept hitting an awkward wall. I added my program into an array, using the individual bytes as the values.

byte program[] = {0xc3, 0xed, 0xbf, .........};

To keep the wiring and programming as simple as I could, I used a 12-stage ripple counter for addressing the EEPROM and connected the IO directly to the UNO (as well as CE, OE, and WE). The UNO connects to the serial monitor in the Ardiuno IDE and waits for either a “D” or “W” (upper or lower case). “D” means “dump,” as in “dump the contents of the EEPROM into the monitor.” Obviously, “W” stands for “write the EEPROM.”

The awkward issue I ran into was that either the EEPROM was getting programmed incorrectly or the contents were getting dumped incorrectly, and I couldn’t figure out which one it was. I went over the code, went back over it, checked it yet again, etc, and still couldn’t figure it out. I added a couple of delays here and there, removed a couple, and that did something. It was still not working correctly, though. I changed variable names just in case and that did nothing. Then I had an idea: what if the (program) values were being misinterpreted by the UNO? So I made two small changes. First, I converted the first byte of the program to decimal and replaced the hex representation in the array with it. I changed the last value just to see what that would do. The EEPROM got programmed correctly this time. So I fixed the last value to what it was supposed to be and re-read it, and it was correct!

I still have no clue why changing the first byte’s representation worked, but I’m glad it did. The next things I should do are slow the computer’s clock down and test if it actually works. I’ll update once that is done.

 

*UPDATE*

It works excellently. I had trouble with it at first because it acted wildly. After a few power off/on cycles, it finally behaved as expected. I’ve ran a few test codes through it and it executed them flawlessly. I’m thinking about making a YT video to explain it all.

Edited by LonesomeLamp
Update
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Hello :)

×
×
  • Create New...