boot.asm

来自「一个朋友写的操作系统源码」· 汇编 代码 · 共 56 行

ASM
56
字号
cseg segment 'code'

     assume cs:cseg

start:
      ;read MBR into 87C00 don't ruin the dos 

      mov ax,8000h
      mov es,ax
      mov ds,ax         ;partition table segment
      mov bx,7c00h
      mov ax,201h
      mov dl,80h
      mov dh,0
      mov ch,0
      mov cl,1
      int 13h

      ;load our entry

      mov si,7dbeh      ;point to the partition table
      xor cx,cx
      mov cx,4

searchloop:

      cmp byte ptr [si+4],23h
      je continue       ;got it!
      dec cx
die:  je die            ;can't find
      add si,16         ;address next entry
      jmp searchloop

continue:

      ;we should load the int 13 register parameters reading from Partition table

      mov dh,[si+1]
      mov cl,[si+2]
      mov ch,[si+3]

      xor ax,ax
      mov es,ax
      mov bx,7c00h
      mov dl,80h
      mov ax,201h
      int 13h

      db 0eah
      dw 7c00h
      dw 0

cseg  ends

end start

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?