Operating system works
Let's talk about the tool we use.
Since it is necessary to write an operating system, it is essential to compile the language compiler. If you can't find Tasm, MASM, you can try NASM (NASMBLER), this is an open source software, you can download it at http://sourceforge.net/projects/nasm.
Also, if you don't want to reboot again and again to debug your program, you may need a simulator to simulate the X86 environment, at http://bochs.sourceforge.net/getcurrent.html, you can download to Bochs . It can simulate a computer, including CPU, memory, basic I / O device, and more.
After downloading and extracting Bochs, you can find a program named bxImage.exe in its directory, which can create a disk image file for us, we can try our operating system on these disk mirror files without having to Really change our hard drive or the data on the floppy disk, after all, before we don't actually grasp, we don't want to give our computer what non-recoverable harm.
The following table shows the run of a bxImage.exe (the program will wait for the user to enter). It created a file called boot.img, which is a mirror of a floppy disk having a capacity of 1.44m.
============================================================================================================================================================================================================= ======================
BxImage
Disk Image Creation Tool for Bochs
$ ID: BXIMAGE.C, V 1.17 2002/11/26
11:21:31
CBOTHAMY EXP $
============================================================================================================================================================================================================= ======================
Do you want to create a floppy disk image or a hard disk image?
Please type hd or fd. [Hd] fd
Choose the size of floppy disk image to create, in megabytes.
Please Type 0.36, 0.72, 1.2, 1.44, or 2.88. [1.44]
I Will Create a Floppy Image withcyl = 80
HEADS = 2
Sectors Per TRACK = 18
Total Sectors = 2880
Total Bytes = 1474560
What should i name the image?
[a.img] boot.img
Writing: [] DONE.
I wrote 1474560 bytes to (null).
The Following Line Should Appear in Your Bochsrc:
FLOPPYA: 1_44 = "Boot.img", status = inserted
Press any key to continche
You may have anxious to see what Bochs is like, then you can find some operating system's image files, download, download, unzip to BOCHS, and then run Bochs. You can see that various operating systems are running on your Windows.
Then, you can download a file called Lesson5.asm here, and compile it with NASM, as follows:
NASM Lesson5.asm -o boot.bin
After that, you will get a pure binary file called boot.bin, the size is just 512 bytes. Open this file with an editor that edits 16 credit, you can see more than half of the bytes in this file are 0, and the last two bytes are 55 and AA.
Then, open Boot.img with your editor, copy all of the contents of boot.bin to it. It is worth noting that you should copy the content to the beginning of Boot.img. That is, the copying content takes up the 0x000 to 0x1FF bytes of Boot.img.
If you have decompressed the mirror file in the Bochs directory, then there should be a file called .bochsrc in your bochs directory, open it with a general file compiler, you will find it
File = C.IMG
This way, change the c.img to boot.img, or other file names that have just been built and copy the byte of the byte, saved. In this file, you may also see some strange characters and ignore them.
Start Bochs, you will see programs compiled by Lesson5.asm can run. Take a little time, then you can truly embark on the way of operating the system. Remember this moment, this start, only once in your life.