I thought Careless's author forgot to explain the long assembly code, leaving so much confusion!
The next day the author confessed: Later on, the next day we first talk about the core of the program content bar!
Well, just ready to wait for the author to explain, did not expect him to throw a bunch of code (what ghost?) )
; hello-OS; TAB=4ORG0x7c00To indicate the loading address of the program, which is the Nask compiler (pseudo-instruction) tells Nask to start execution by putting the code in 0X7C00 place.
Why is 0X7C00, because the 0X7C00-0X7DFF is the loading address of ScanDisk.; The following floppy disk for standard FAT12 format JMP entry DB0x90__; program Core Entry:mov AX,0; initialize register; at this time AX = 0 MOV ss,ax; The SS stack segment register is also equal to 0 MOV SP,0x7c00; SP Stack Register SP (stack pointer) storage stack offset address equals 0x7c00mov ds,ax;D s--data segment Register =0 mov es,ax; es--additional segment register =0 MOV si,msg; MSG is actually the address. Nask calculates that the MSG program starts with a few bytes and then the difference byte +0x7c00 is the address of the MSG. Putloop:mov Al,[si]; The value of the address represented by the register SI is assigned to the AL add SI,1and a CMP AL for S1.0. Compare al and 0JE fin; if Al is zero then jump to fin to perform MOV AH,0x0e; display a text MOV BX, the; Specify the character color INT0x10When calling the bios of the video card, the value in AH,BX is the parameter that the BIOS program will use in JMP putloop; before you see si constantly adding one, there is always a time to read the MSG saved data , then Al is 0, then executes the JE command to let the CPU stand by. fin:hlt; Let the CPU stop and wait for the command in JMP fin; Infinite loops
; Save the data to be printed out msg:db0x0a,0x0a; 2-time line break DB"Hello, World"DB0x0a; line break DB0
(⊙v⊙) Hmm. I explained the code in the comments above. (finally a little bit of yesterday's stuff)
But, write the ScanDisk and the operating system in a file and then rename it to IMG after compiling it nask, now it looks convenient. But what if the operating system is getting bigger and larger? What if you want to change or manage it later?
That's a sore egg.
So the author decides to write only the IPL and then the other files are written and then merge them with the Disk Management file.
Then the author decisively deleted the Code, and renamed Helloos.nas to Ipl.nas, by the way also modified asm.bat this batch file .
Oh ah. The author, by the way, outputs ipl.lst to record how each instruction is translated into machine language.
Oh, plus a makeimg.bat. The content is as follows:
.. \z_tools\edimg.exe imgin:.. /z_tools/fdimg0at.tek wbinimg src:ipl.bin len:0 to:0 imgout: Helloos.img
What do you mean by reading a blank disk image file Fdimg0at.tek, then writing the Ipl.bin content at the beginning , and finally outputting the result with a disk image file named Helloos.img.
Makefile Getting Started:
The basic format of MakeFile is as follows:
Macros define the interdependence between source files
Any executable shell command
The author gives the following code:
#デフォルト Motiondefault : ../z_tools/Make.exe img#ファイル Generation rules Ipl.bin:ipl.nas Makefile./z_tools/nask.exe ipl.nas ipl.bin ipl.lsthelloos.img:ipl.bin Makefile./z_tools/edimg.exe imgin:.. /z_tools/Fdimg0at.tek wbinimg src:ipl.bin len: + from:0To:0imgout:helloos.img#コマンドasm:../z_tools/make.exe-R ipl.binimg:../z_tools/make.exe-R helloos.imgrun:../z_tools/make.exe img Copy helloos.img. \z_tools\qemu\fdimage0.bin ./z_tools/make.exe-c. /z_tools/qemuinstall:../z_tools/make.exe img ./z_tools/imgtol.com w A:helloos.imgclean:-del Ipl.bin-del ipl.lstsrc_only:../z_tools/Make.exe Clean-del helloos.img
The author also gave a make.bat
.. \z_tools\make.exe%1%2%3%4%5%6%7%8%9
The subsequent%1,%2,%3 represents the passed parameter.
Okay, lazy work's done. Let's get here today.
Well, can you explain a little bit about the makefile file?
Well, see for yourself, you must understand.
30-day homemade operating system reading notes (ii)