Chapter 1 Boot. ASM source code analysis of "writing an operating system by yourself"

Source: Internet
Author: User
  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




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.