loadmbr.asm

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

ASM
74
字号
cseg segment 'code'

     assume cs:cseg

start:
      ;read MBR into 7C00 

      xor ax,ax
      mov ds,ax
      mov es,ax
      mov si,7c00h
      mov di,600h
      cld
      mov cx,100h
      repnz movsw

      db 0eah
      dw 617h
      dw 0

      ;jump here

      xor ax,ax
      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 win2000 entry

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

searchloop:

      cmp byte ptr [si+4],6h
      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


     ;make it execute

      db 0eah
      dw 7c00h
      dw 0

cseg  ends

end start

⌨️ 快捷键说明

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