Przeglądaj źródła

:new: 创建了loader.asm

fslongjin 3 lat temu
rodzic
commit
51e5a0ffb8
2 zmienionych plików z 38 dodań i 3 usunięć
  1. 5 3
      bootloader/boot.asm
  2. 33 0
      bootloader/loader.asm

+ 5 - 3
bootloader/boot.asm

@@ -48,7 +48,7 @@ Label_Start:
     mov bx, 0x0700  ;设置白色字体,不闪烁,字体正常亮度,黑色背景
     mov cx, 0
     mov dx, 0184fh
-    int 10h
+    int 0x10
 
     ;设置屏幕光标位置为左上角(0,0)的位置
     mov ax, 0x0200
@@ -60,7 +60,7 @@ Label_Start:
     mov ax, 0x1301 ;设置显示字符串,显示后,光标移到字符串末端
     mov bx, 0x000a ;设置黑色背景,白色字体,高亮度,不闪烁
     mov dx, 0x0000 ;设置游标行列号均为0
-    mov cx, 24 ;设置字符串长度为20
+    mov cx, 24 ;设置字符串长度为24
 
     push ax
     mov ax, ds
@@ -186,7 +186,9 @@ Label_Go_On_Loading_File:
     jmp Label_Go_On_Loading_File
 
 Label_File_Loaded:
-    jmp $
+    ; 跳转到loader
+    ; 这个指令结束后,目标段会复制到CS寄存器中
+    jmp BaseOfLoader:OffsetOfLoader
 
 
 ; 从软盘读取一个扇区

+ 33 - 0
bootloader/loader.asm

@@ -0,0 +1,33 @@
+; |==================|
+; |    这是loader程序  |
+; |==================|
+; Created by longjin, 2022/01/17
+
+; 由于实模式下,物理地址为CS<<4+IP,而从boot的定义中直到,loader的CS为0x1000, 因此loader首地址为0x10000
+org 0x10000
+    mov ax, cs
+    mov ds, ax ; 初始化数据段寄存器
+    mov es, ax ; 初始化附加段寄存器
+    mov ax, 0x00
+    mov ss, ax ;初始化堆栈段寄存器
+    mov sp, 0x7c00
+
+    ;在屏幕上显示 start Loader
+    mov ax, 0x1301
+    mov bx, 0x000f
+    mov dx, 0x0100  ;在第2行显示
+    mov cx, 23 ;设置消息长度
+    push ax
+
+    mov ax, ds
+    mov es, ax
+    pop ax
+    mov bp, Message_Start_Loader
+    int 0x10
+
+    jmp $
+
+
+; 要显示的消息文本
+Message_Start_Loader: db "[DragonOS] Start Loader"
+len_Message_Start_Loader: db 23