Making up my mind

After some research I understood that x86 CPUs have generally different modes of operation: real, extended and protected to list some of them. In real mode, the x86 CPUs behaves like the 8086 ones. This mode is also called 16bit real mode. In this mode, you have only 1 MB of address space (20 bits bus) and no more. To access the rest of the hardware you have to switch the CPU from real to extended mode and finally to protected mode. Indeed when every PC boots, it is like a bit playing again the history of computers. The same is in biology: every embryo during its development follows the same evolutionary steps of its species. In a way, you can look at the booting of a PC the same as the embryo from conception to life. Since this picture came to my mind, I look at the booting of PC in this way. Once I realized it, I felt relieved since, at the beginning of all of this, when making this journey through informatics was less than an idea, I was regretting having got rid of my very old 8086 PC. I thought that having it now would have been a good learning tool to start with. Luckily for me, any CPU behaves like the 8086 when it starts so the first problem was solved. But a new one was coming in: how to solve the problem that I miss a floppy drive? Well, I will use the hard drive instead of it, by setting up things in the proper way.
Before I move on, I better explain why I do the things I do, which strategy I want to adopt to reach my target and what is my target. So let us go step by step:

  1. When CPU wakes-up (or after reset) it behaves as an 8086 CPU, (for the moment this is an assumption, co-validated by much documentation on the internet about the boot process, but eventually I will figure out how to verify it by myself). On Chapter 2 page 29 of the "INTEL – The 8086 family User's manual", it says that the CPU points to 0xFFFF:0000 = 0xFFFF0 and starts to execute whatever rubbish it finds from thereon.
  2. At address 0xFFFF0 there must be the BIOS software entry point (much documentation on internet confirm that, but again I will try to check it as soon as I will be able to do so). The BIOS software instructs the CPU to perform several Power On Self Tests (POST for short), and it may or may not interact with the user to select a device to load extra software from (boot device list).
  3. The BIOS software loads 512 bytes in memory starting at 0x0000:07C0 (this also need to be verified) from the boot sector of a device (floppy, HDD, CD/DVD, USB).

If this is all true1, then I "just" have to write a piece of software and put it in the boot sector of a device, and by starting my PC the BIOS will load it at 0x007C0 and start execution. That quoted "just" really implies a lot. So I read chapter 1 and 2 of the "INTEL – The 8086 family User's manual" completely plus some other documents from the internet to get to know how to do just a little bit of assembly. Now my purpose here is not to teach you some assembly or anything else that one can find on the internet, but here I want to take some time to make some points. I read a lot on the internet about "assembly syntax" and "Little-Endian/Big-Endian" issue and, in my previous post, I explained my opinion about that (Assembly syntax: INTEL vs. AT&T; Little Endian). The truth is that you have to learn assembly if you want to learn how the PC works and, according to me, the better book about it is just the "INTEL – The 8086 family User's manual".

And now let's go back to the point where we were before starting this discussion about assembly. Now I looked at the options I had at point 3. As I said, I don't have a floppy drive to boot from, so I looked to the next option. I preferred not to mess up with Hard Disk because every mistake would cost me a lot of time reinstalling OS from zero (when learning you have to plan to make a lot of experiments and mistakes) so I looked at the next option. Write boot sectors of CD/DVD means that I had to burn a CD for every test and it isn't a practicable way. The last option was the most promising one. I could use a USB stick almost as if it was a floppy disk. I could write my software on the USB stick and then restart and boot from it doing as many tests as I wanted with no risk for the Hard Disk. It seemed to be the best choice, so I started to document myself with the USB specification and tried to learn. Soon I realized that, unfortunately, I wasn't ready yet to handle it all by myself so I reviewed my strategy and I went back to the Hard Disk option being ready now to take some risks (indeed I did mess up things once and I had to reinstall from scratch). So I started again to search for the documentation but this time about Hard Disk and I found the following good ones:

I studied them and then I moved to the next step. In conclusion, I will prepare my Hard Disk with a separate partition to be used as my sandbox. What do you think about this plan? Let me know in the comments.



  1. Some times later, I improved to the point that I could manage an experiment and I did verify that the code at 0xFFFF:0000 is indeed the power-on program and that the boot sector gets loaded in RAM at address 0x07C00. You will read it in the post "AP-PROBE". [click back]

<PREV.  -  ALL  -  NEXT>

Comments