1.Code:
Org 07c00h; tells the CompilerProgramLoad mov ax, CS mov ds, ax mov es, ax call dispstr at 7c00; call the display string routine JMP $; infinite loop dispstr: mov ax, bootmessage mov bp, ax; ES: BP = string address mov CX, 16; Cx = string lengths mov ax, 01301 h; Ah = 13, Al = 01 H mov BX, 000ch; page number is 0 (bH = 0) black background red letter (BL = 0ch, highlighted) mov DL, 0 int 10 h; 10 h interrupt retbootmessage: DB "Hello, OS world! "Times 510-($-$) db 0; fill in the remaining space to make the generated binary code exactly 512 bytes DW 0xaa55; End mark
2. Question and Answer:
1) org: Tell the operating system to load the code to address 0x7c00. Why? Because the machine starts, the BIOS program is executed first. After the BIOS program is executed, the control is transferred to the entrance of the operating system boot program. The entry address is 0x7c00. For details, refer: Before Linux is started
2)MoV ax, CS: the value of CS is assigned to ax, but what is the value of CS? It is 0 xFFFF, The result agreed by the CPU vendor. For the reason, refer to: Before Linux Startup
3) int 10 h: 10hInterrupted, The service programs provided by the BIOS for the screen and display. For details, refer to here.
References:
[1] A comprehensive analysis of the "hands-on writing Operating System" Chapter 1: http://blog.csdn.net/zgh1988/article/details/7060032