这里我们简单介绍一下Stage2.asm这个程序。

      整个程序代码如下:

   1: ; Note: Here, we are executed like a normal COM program, but we are still in
this loader to set up 32 bit mode and basic exception
   3: ; handling
   4:  
   5: ; This loaded program will be our 32 bit kernal.
   6:  
do not have the limitation of 512 bytes here, so we can add anything we
   8: ; want here!
   9:  
  10: org 0x0             ; offset to 0, we will set segments later
  11: bits 16             ; we are still in real mode
  12:  
  13: ; we are loaded at linear address 0x10000
  14:  
  15: jmp main
  16:  
  17: ;*********************************
  18: ;   Prints a String
  19: ;   DS=>SI: 0 terminated string
  20: ;*********************************
  21:  
  22: Print:
  23:         lodsb
  24:         or al, al
  25:         jz PrintDone
  26:         mov ah, 0eh
int 10h
  28:         jmp Print
  29: PrintDone:
  30:         ret
  31:         
  32: ;********************************
  33: ; Second Stage Loader Entry Point
  34: ;********************************
  35:  
  36: main:
  37:         cli
  38:         push cs
  39:         pop ds
  40: ;        xor ax, ax         ; org 0x0500
  41: ;        mov ds, ax         ; org 0x0500
  42:         
  43:         mov si, Msg
  44:         call Print
  45:         
  46:         cli
  47:         hlt
  48:         
  49: ;********************************
section
  51: ;********************************
  52:  
,13,10,0

相关文章:

  • 2022-12-23
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
  • 2021-11-17
猜你喜欢
  • 2021-05-24
  • 2021-11-30
  • 2021-11-30
  • 2021-06-17
  • 2021-11-30
  • 2021-11-30
  • 2021-11-30
相关资源
相似解决方案