Do you want to write your letter on the operating system that has been completed in 10 minutes?

Source: Internet
Author: User

Operating System completed in 10 minutes

Do you believe that there can be less than 20 lines of code for an "Operating System?
Example 1. Chapter1/A/boot. ASM
1 org 07c00h; tells the compiler program to load at 7c00
2 mov ax, CS
3 mov ds, ax
4 mov es, ax
5 call dispstr; call the display string routine
6 JMP $; infinite loop
7 dispstr:
8 mov ax, bootmessage
9 mov bp, ax; es: BP = string address
10 mov CX, 16; Cx = String Length
11 mov ax, 01301 h; Ah = 13, Al = 01 H
12 mov BX, 000ch; page number is 0 (bH = 0) black background red letter (BL = 0ch, highlighted)
13 mov DL, 0
14 int 10 h; 10 h interrupted
15 RET
16 bootmessage: DB "hello, Guest OS success world !"
17 times 510-($-$) db 0; fill in the remaining space to make the generated binary code exactly 512 bytes
1 8 DW 0xaa55; End mark
Compile the code using NASM:
$ NASM boot. ASM-O boot. Bin
We get a 512-byte boot. bin. Let's use the absolute sector read/write tool to write this file to the first sector of a blank floppy disk. In Linux, you can do this:
$ Dd If = boot. bin of =/dev/fd0 BS = 512 COUNT = 1
In Windows, you can do this:
$ Rawrite2.exe-F boot. Bin-D
Now, your first "Operating System" has been completed. This floppy disk is already a boot disk.
Put it in your drive and restart your computer. boot from a floppy disk. What do you see?
The computer shows your string! Red "Hello, OS world !", What a wonderful thing! Your "Operating System" is running!
If you use a virtual machine such as bochs (a detailed introduction to bochs will be provided below), you can read the specific results in this book.
This is really great. Although you know how simple it is, after all, you have made a bootable floppy disk and you have done all the work independently!

 

This article is excerpted from the book Orange's: the implementation of an operating system.

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.