Memory map and interrupts - Building and programming a 16-bit Intel x86 breadboard computer [part 3]
HTML-код
- Опубликовано: 11 сен 2024
- Intel 8088 16-bit computer on a breadboard.
In this video I:
- talk about the memory map of our computer
- build an address decoder using logic gates, to activate two different memory chips depending on the address the CPU wishes to access
- add a RAM memory chip and connect both memories to the address decoder
- talk about interrupts in 8086 and explain the Interrupt Vector Table at the bottom of the RAM
- introduce the Programmable Interrupt Controller (8259) and its role in interrupt handling
- explain the concept of the processor's stack and its importance in the context of interrupt handling
- go into details of the programme used to initialise the processor and the handler of the Non-Maskable Interrupt
- raise the MNI interrupt (using a wire) and analyse the CPUs behaviour in details
Visit my webpage slador.uk/ to find the list of all my videos and all the supporting materials.
You can find there schematics of this computer at every stage of building it during the videos as well as the source code of all the programmes I write for this computer.
slador.uk/ Наука
Google's algorithm pointed me in the direction of your videos. The ones I've watched so far are brilliant, keep up the good work.
@DaveThompson1 thank you very much! I'm getting back to work after my holiday :-)
Looking forward to your 74* series! What I'd like to see is an 8088 interfacing with DRAM instead of SRAM. As an x86 veteran, I don't mind your assembly digressions because I think they might be good for beginners.
Thank you for your comments!
The 74 series should be available next week.
I was thinking about attaching DRAM to my 8088 as well, but in this series this would not add much value, only complicating the whole design. Effectively I'd need to add a bunch of 74s or use some programmable logic.
I think I will do it at some point, but probably as a side video rather than during this series.
The target of this video series, as stated by the author, is "beginners". Giving the xor discussion the label of "digression" implies that the intended audience is veterans such as yourself. Such a "digression" is very informative and much appreciated by this beginner and I definitely would like to see more like it.
Oh my god!
I’ve been waiting for this, and I am so happy! So great series!
Glad you enjoy it! Thank you
Oh, no comments yet! Keep it up. It is super interesting.
Thanks, will do!
Excellent! Happy to see the series continuing!
Thanks a lot! More is coming. I already started working on the new video ;-)
Can’t stop binge watching this. It’s like watching Bens videos all over again lol. I’ve build own version of ttl computer from his videos…..so you know now I will build 8088 based lol.
I really enjoyed this video, so many memories. I remember making a simple TDM multitasking TSR using a timer interrupt. I think i still have the peter norton book on 486 assembly somewhere.
Thank you! I know exactly what you mean. Memories... ;-)
This is amazing content. please continue.
I will, promise! Thanks!
Your tangents are done perfectly. "Just enough info to understand"!!
Awesome. Please continue this series. My first computer was an 8088-based PC, a long time ago... Your videos made me want to build one.
Thanks, I will. The next video is in post production. By all means - build one! :-)
Your series is phenomenally well presented. Clear, clean and concise! Amazing!
Wow, I'm really grateful for your kind words. They encourage me to carry on with the videos. Thank you!
@@SladorSoft please, please carry on! They're going to be very useful now and to many others in the future!
This is a brilliant series! Thank you so much for posting this
I'm really glad you are enjoying it. Thank you for watching.
Really informative, there's a lot of content on z80, 6502, and too little on x86. Thank you.
Cool! You continued the series
That's the plan! Thanks!
Instant subscribe... This is exactly what I'm looking for. Great project!
Awesome, thank you!
Keep going.. Looking forward to see more videos
I am working on next videos, but holiday period slows me down a little bit. Thank you for your patience.
One of the few times *(int*) (void*) 0 = xxx; is a valid C instruction (instead of a null pointer access), is when you set the divide by zero interrupt vector IP value ;)
Excellent video! Can't wait for the next one!
When done with this series, it would be nice to watch you write a C/C++ hardware emulator of this entire breadboard build in a step by step manner, starting with the intel's 16-bit x86 chip that you are using and expanding it from there. What would be nice to see at the end of that series would be the ability to install MS-DOS 6.0 and Windows 3.11 within the x86 emulator and to have a virtualized running operating system running as a modern Windows desktop console application. To account for graphics within the "Viewer" side of the emulator (additional software that isn't a part of the breadboard build otherwise you would have to build a GPU on breadboards...) we could use either OpenGL or Vulkan and their shader modules to do all of the drawing of the font's and images that Dos & Windows of that era would require. If this works well, then one could install DOOM into the emulator! However, we might have to add an addition piece of emulated hardware in software such as a sound blaster 16... What good is a "Game" without "Sound"? Again, could be done just in software instead of having to build an audio or sound card on a breadboard, unless if you want to go down that road...
This would make for a great series...
It would cover 4-5 major fields within computing covering both levels of abstraction starting with the hardware and its logical design along with its assembler/disassembler to middle or high level language such as a C/C++ compiler with Operating System support. It would also cover Graphics and Image Processing as well as Audio Processing as they cover multiple programming paradigms from low level assembly to mid level C to high level C++ and maybe even some Python Scripts...
As another side project to this main project we could try designing the breadboard computer as well as the hardware emulator to be able to run an older version of linux... This way, the finished project would be both compatible and able to support either Dos 6.0/Win 3.1 or an older version of Linux...
Then as a final set of videos as an addition choice of candy for the viewers; you could design your own operating system and installer that will be able to be installed on both of your 16-bit x86 breadboard build as well as the hardware emulator that is written in C/C++. Let me know of your thoughts on this...
As a side note if you were to start doing the software side of things could easily upload that to github... could even possibly get a discord channel going too so that the community could fork from your main branch work on it and add their own versions... Then we could possibly see dozens or even hundreds of 16-bit x86 emulators out there!
Wow! Thanks for your extensive comment including lots of ideas!
Writing an emulator would be a massive project. Personally, I'm not sure if coding on screen would be that interesting for most of the viewers(?) Anyway, it would take a looong time. Let's say that when this channel gets 1M subscribers, I'll quit my job and start the emulator series ;-)
As a side note, the emulator would need to be able to implement not only 8086, but at least 80286 for Windows 3.1 (and Doom, I believe, requires at least 80486?). As much as this idea is really cool, the required effort is huge, especially considering that there are already good emulators which do exactly what you described ("Bochs" for example).
As for github, I'm planning to publish all the code I'll write for this series -probably on github. Because the time I can spend on this is quite limited, I need to carefully balance between preparing new videos for this series, putting together a website and planning new stuff for the future.
As to the idea of the own OS - it would be even bigger thing. Rewriting MS-DOS, or anything else running in real mode wouldn't be fun, so we are looking at - at least - 80386 - definitely impossible to stick it on a breadboard :-)
To realise your ideas I'd need several lives more and to quit my job (in all of them), probably :-) If you have some time on your hands, why not to try yourself? I'd be the first person to subscribe, when you have done it - promise.
Again, thanks a lot for watching and your pretty good ideas.
@@SladorSoft This is why I'd make the suggestion of getting the community involved... Others who would be interested in such a project could work on their own parts, and collectively it wouldn't be too much of a burden, and then you could focus on the video part with the explanations and demonstrations... I know it wouldn't be an easy task, years ago I've written a minimal 3D Graphics/Game engine in C++ using Legacy OpenGL 1.0 and that project was close to 100k lines of code where a good 10% of that was in the parser for creating or generating the Scene Graph dynamically from a custom built language text file... and it took me about a year to write and debug it. I understand where you are coming from. I wouldn't expect you to do everything. That's why I had mentioned Github in conjunction with a Discord channel. Who knows where it would lead to and what may come of it.
Now, I do understand that there are already existing tools out there such as Bochs... but to see a series where one would build such a thing from the ground up in a step by step manner explaining what they are doing and why they are doing things in a specific why while still also being open to suggestions from others to improve the quality and efficiency of the code would make for a great series for others to follow. It wouldn't be so much as a lesson to teach them how to write code or program... it would be more on the lines of teaching them how to model algorithms that will be implemented into some source code and how to build sophisticated software from beginning production to end production. There are tons of tutorials to teach the "languages", there are tons of tutorials that teach various datasets, structures and algorithms yes, but there are very few that teach how to combine the two together in a seamless manner allowing others to develop the skills to be productive software developers / engineers. With your knowledge of the underlying hardware and knowing how the software meets the hardware is on the spectrums that is limited or lacking as resource for general public knowledge. And your videos although are focused on the integrated circuits, instruction sets, binary codes and assembly.... your demonstration and explanation is very solid and easy to follow. I hunted for years to fill that gap... I've understood the circuity side of things to a degree and the software side of things, but always found the middle ground lacking, well at least until I came across Ben Eater's channel and now you are presenting this series on the x86 architecture! Who knows maybe one day someone will do something similar with the Risc-V architect!
Thank you skilz8098 for your reply. I must say that your ideas overlap my ideas in some respects. Honestly, I started thinking about any future subjects only recently. I created this channel without any serious thoughts that it would get any traction. It was just like: I'll have some fun with a breadboard and my 8088 and I'll record it. I didn't believe that many people would like to watch a video like thousands of other similar videos on YT where a guy talks a lot and with some foreign accent (that's why I add subtitles for those who may struggle to understand). The missing middle ground you talk about really resonates with me. I do programming (not electronics) for living, but electronics has been my hobby for most of my life and in fact I really like to marry both and I have always been interested in this middle ground. So that's definitely what I'd like to cover at some point. I'll have a think of how to do it properly, but definitely I'd like to include C++ (as the programming I've been doing most for living) and probably 32-bit Intel assembly including at some point protected mode of the 386+.
Anyway - thanks a lot for your ideas (and nice words on my work). We'll see how it goes :-)
Oh, and I don't intend to talk about Risc-V as I've never really played with it (not that I wouldn't like to see someone else doing it).
@@SladorSoft Well, I'm more familiar with x86 than most other architectures... but after watching a few videos about Risc-V and their philosophy... I kind of like the direction they are going... It's an "open source" version of hardware well not so much hardware itself but as for the ISA. Here's our core ISA that you must implement to be considered a "Risc-V" brand. Then after that you can include any or all other extensions or possibly even roll your own to suit your own needs. There are pros and cons to both proprietary and open source variants... but the modularity part of the "Risc-V" has gotten my attention... The way things are going within the industry today... x86 won't go away right away, but I have a feeling that it's towards the end of its lifespan as it is slowly become less and less significant. Don't know which direction Intel is going to go from here, but it's going to be interesting to wait and see!
Word salad shredders
Excellent series 👍
I have done asm programming for MS dos.
I believe that NMI was used in the original IBM pc for a memory parity error.
Thank you. Yes, I think you are right about the NMI in IBM PC.
crazy informative... thank you! keep going
Thanks a lot! I will try to keep going ;-)
i know i am a bit late to the party, but i would love to see a full video series about ASM x86. its really interesting, and i am currently in the process to build my own intel 8088 based computer.
Thanks for that. Lenny Kravitz sang: "It ain't over 'til it's over" ;-) You're not too late as the series is still running. I was considering making the x86 ASM video. I promise I'll think about it and try to put it together in a slower time. Good luck with your own computer!
@@SladorSoft yeah, and if you need/want a bit of help, i myself run a little youtube channel about nerdy things, and i would love to cooperate with amazing people to make amazing content. (i dont wanna dadvertise anything here, but if you wanna take a look at my crappy content the name of the channel would be "Curious Computer")
Thanks for the video. Its down to earth.. you didn't state how you got the Program into the memory. I was thinking you write the EPROM or something.
Hi! Thanks for watching and commenting. Yes, well, at the moment I assumed it would be obvious how the programme got onto the breadboard and didn't mention that. Apologies for that. I used the same flash memory which I introduced in the previous video. So you are quite right, but instead of using an EPROM I used a flash chip (29C010). But yes, I do remember using EPROMs and waiting until they got erased by a UV bulb many years ago. I used to have a few EPROMs, which I used in turns, so I could have a few empty ones while the rest was being erased. Good old days ;-)
@@SladorSoft Much appreciate your reply. So the flash chip is an EEPROM ? I WANT TO start breadboarding alongside you as I enjoyed your content
@engineerchika3204 - sorry for late response - I had somehow missed your comment.
Yes, I'm using the 29C010 which is a 128kB NOR Flash, so technically something very close to EEPROM.
8086 assembly serious would be great!
I'm thinking about it seriously. You're not the first one to ask for such series.
This series brings me so many good memories... I have two questions about the assembly you used (which might also be tips for viewers):
1. Why are you using a "NOP" followed by a "JMP -2" (EBFD)? Wouldn't a "JMP -1" suffice (EBFE) and save a byte (plus some clock cycles - i.e. four button presses :)?
2. Was there any reason to not use "CLI/STI" to disable interrupts while setting up the interrupt table?
Hi there! Thanks for your questions. They are great, because - as you said - they may be valuable for others. Let me answer them:
1. No particular reason - I just wanted to make sure that the CPU has something to do in the loop and that it will still fetch the instructions giving us feedback on the LEDs. I thought that if the loop was made only from a single 2-byte JMP it may not re-fetch it and use the prefetch queue instead.
2. The reason was that both CLI and STI were completely redundant in this case. The interrupts are disabled after reset by default, so I didn't need CLI there and since I were not using the INTR line in this video at all, we didn't need to enable them at any point.
Please note that neither NMI nor CPU interrupts (like divide-by-zero for example) are NOT controlled by the IF flag at all - they are always active.
I have several Siemens 8086 MPU’s, I have yet to get some 8088’s in my inventory which would be a little easier to interface with as it only has an 8bit bus vs the 8086’s 16bit which was a substantial reason for IBM to use the 8088 in their 1981 debut of the IBM PC.
I always thought it is so weird that Ben Eater did not use a ZIF socket, prying out the ROM always with a Metal tool. Sometimes even with power on :)
Or maybe I'm just more lazy than him and used a ZIF socket rather than keep wrestling with the chip ;-)
x86 XOR evolved so that in modern CPUs, the XOR with the same register does not even enter any execution engine, it gets detected and effectively gets executed during the register renaming with it being set to 0.
Yes, I can imagine that. Modern CPUs have almost nothing to do with these first processors. They have this microcode, kind of internal machine code to run the machine code ;-) I remember being amazed when first heard about "jump prediction" in the first Pentiums in the 1990s. It's been a long way from the 8088 to the current "Intel Cores" :-)
Hello Slador,
I like the format of the instructions documentation.
Where can I get a copy of this? for operation, flags affected and description. Would really appreciate it
Hi David,
I used scans from this book:
"iAPX 86/88, 186/188 User's Manual. Programmer's Reference" by Intel.
ISBN 0-8359-3035-1
and connect a DOM/DOC or Disk On Chip I have a bunch of M-Systems 8MB DOC's can i do this? i want to get a DOS loading on Breadboard PC lol
How to handle time? Let's say I want to print out the result of each Fibonacci sequence every 1 second, how do I do that? I've read there's a chip called Programmable Interval Timer 8253 but it's just that, papers, nobody has made a video wiring the IC and demostrating its behavior.
There's a project called SDLPOP which is a reverse engineer port of Prince Of Persia to SDL, I'm reading the disassembly code to see how they managed to keep framerate the same regardless CPU speed but for me to understand that will take a decade.
That is a great question and you answered it yourself ;-) Yes, you need a timer like 8253 (or its newer version 8254).
Funny that you mentioned it, because I have planned to cover 8254 in my series. It will appear in episode 6 according to my current plan.
good evening,excellent. I would like to know what are the components he used in the clock circuit he uses in the small breadboard with the 2 buttons. Thanks in advance for your reply. I'm italian
Hello, thank you very much. You can see the schematic of the small breadboard in my first video - the "First Run" - around the time 12:13. This link should direct you there:
ruclips.net/video/VvyUAaRTsww/видео.html
The small breadboard is on the left bottom side of the schematic. The resistors can be around 10k and capacitors around 10uF. The inverters are 74HCT14 and the flip-flop is 74HCT74.
I hope that helps!
Sir will you please tell me the software name, that you are using for software simulation of circuits
Yes, of course. I'm using KiCad to draw schematics of my circuits. It's free and open source.
Hi I'm noob, how do you write the program on the memory?
Hi! The flash memory is written using a universal programmer. My own programmer is very old, but if you would like to buy one, search for "XGecu T48 Universal Programmer" for example as it is one of the most popular budget programmers.
The compiler creates a binary image of the flash which you then load into the programmer.
I'm planning to release a short instruction video of how to setup the compiler toolset to build all the example code from my GitHub.
How do you programmed memory?
Hi Muzaffar. I replied to a very similar question from Gautham a few days ago. Please have a look here:
ruclips.net/video/FC1Pchr4ngg/видео.html&lc=UgyU-uORPcDVRO0GlJl4AaABAg.9YEnA37koo_9YJEsn983HV
Thanks!