自己动手写操作系统(1)---启动程序

 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()函数,当然前面的一些寄存器设置就是用来为中断进行参数配置了,现在也就知道这么多。感觉吧,进行底层开发要查的硬件手册肯定特别多。





















你可能感兴趣的:(自己动手写操作系统(1)---启动程序)