Posted on 2009-05-11 20:28
hays(海納百川) 閱讀(243)
評論(0) 編輯 收藏 所屬分類:
自己動手寫操作系統
1 .code16
2 .text
3 mov %cs,%ax
4 mov %ax,%ds
5 mov %ax,%es
6 call DispStr
7 jmp .
8 DispStr:
9 mov $BootMessage, %ax
10 mov %ax,%bp
11 mov $32,%cx #init the length of word.
12 mov $0x1301,%ax
13 mov $0x00c,%bx #page 0, black backgroud and red word
14 mov $0,%dl
15 int $0x10 #int 10h,display the screen
16 ret
17 BootMessage:.ascii "Hays, Welcome to OS world!"
18 .org 510
19 .word 0xaa55
這段是boot.S,也就是開機程序,基本的思想是將軟盤的第一扇區文件加載到內尋的0x7c00地址,nasm可以通過.org 07c00實現,linux通過下面的Hinix.old實現.
SECTIONS
{
. = 0x7c00;
.text :
{
_ftext = .; /*Program will be loaded to 0x7c00*/
} = 0
}
通過一些文檔查閱知道了int 10中斷相當于c里面的display()函數,當然前面的一些寄存器設置就是用來為中斷進行參數配置了,現在也就知道這么多。感覺吧,進行底層開發要查的硬件手冊肯定特別多。