【收藏一】DOS6.0源程序中的硬盘引导记录源程序FDBOOT.ASM

  1;/* 
  2; * Microsoft Confidential 
  3; * Copyright (C) Microsoft Corporation 1983 - 1991 
  4; * All Rights Reserved. 
  5*/
 
  6; BOOT - IBM hard disk boot record 6/8/82 
  7
  8
  9; This is the standard boot record that will be shipped on all hard disks. It contains: 
 10
 111. Code to load (and give control to) the boot record for 1 of 4 possible 
 12; operating systems. 
 13
 142. A partition table at the end of the boot record, followed by the required signature. 
 15
 16
 17_data segment public 
 18assume cs:_data,ds:_data 
 19org 600h 
 20cli ;no interrupts for now 
 21xor ax,ax 
 22mov ss,ax 
 23mov sp,7c00h ;new stack at 0:7c00 
 24mov si,sp ;where this boot record starts - 0:7c00 
 25push ax 
 26pop es ;seg regs the same 
 27push ax 
 28pop ds 
 29sti ;interrupts ok now 
 30cld 
 31mov di,0600h ;where to relocate this boot record to 
 32mov cx,100h 
 33repnz movsw ;relocate to 0:0600 
 34; jmp entry2 
 35db 0eah 
 36dw $+4,0 
 37entry2: 
 38mov si,offset tab ;partition table 
 39mov bl,4 ;number of table entries 
 40next: 
 41cmp byte ptr[si],80h ;is this a bootable entry? 
 42je boot ;yes 
 43cmp byte ptr[si],0 ;no, is boot indicator zero? 
 44jne bad ;no, it must be x"00" or x"80" to be valid 
 45add si,16 ;yes, go to next entry 
 46dec bl 
 47jnz next 
 48int 18h ;no bootable entries - go to rom basic 
 49boot: 
 50mov dx,[si] ;head and drive to boot from 
 51mov cx,[si+2] ;cyl, sector to boot from 
 52mov bp,si ;save table entry address to pass to partition boot record 
 53next1: 
 54add si,16 ;next table entry 
 55dec bl ;# entries left 
 56jz tabok ;all entries look ok 
 57cmp byte ptr[si],0 ;all remaining entries should begin with zero 
 58je next1 ;this one is ok 
 59bad: 
 60mov si,offset m1 ;oops - found a non-zero entry - the table is bad 
 61msg: 
 62lodsb ;get a message character 
 63cmp al,0 
 64je hold 
 65push si 
 66mov bx,7 
 67mov ah,14 
 68int 10h ;and display it 
 69pop si 
 70jmp msg ;do the entire message 
 71
 72hold: jmp hold ;spin here - nothing more to do 
 73tabok: 
 74mov di,5 ;retry count 
 75rdboot: 
 76mov bx,7c00h ;where to read system boot record 
 77mov ax,0201h ;read 1 sector 
 78push di 
 79int 13h ;get the boot record 
 80pop di 
 81jnc goboot ;successful - now give it control 
 82xor ax,ax ;had an error, so 
 83int 13h ;recalibrate 
 84dec di ;reduce retry count 
 85jnz rdboot ;if retry count above zero, go retry 
 86mov si,offset m2 ;all retries done - permanent error - point to message, 
 87jmp msg ;go display message and loop 
 88goboot: 
 89mov si,offset m3 ;prepare for invalid boot record 
 90mov di,07dfeh 
 91cmp word ptr [di],0aa55h ;does the boot record have the 
 92; required signature? 
 93jne msg ;no, display invalid system boot record message 
 94mov si,bp ;yes, pass partition table entry address 
 95db 0eah 
 96dw 7c00h,0 
 97include fdisk5.cl1 
 98org 7beh 
 99tab: ;partition table 
100dw 0,0 ;partition 1 begin 
101dw 0,0 ;partition 1 end 
102dw 0,0 ;partition 1 relative sector (low, high parts) 
103dw 0,0 ;partition 1 # of sectors (low, high parts) 
104dw 0,0 ;partition 2 begin 
105dw 0,0 ;partition 2 end 
106dw 0,0 ;partition 2 relative sector 
107dw 0,0 ;partition 2 # of sectors 
108dw 0,0 ;partition 3 begin 
109dw 0,0 ;partition 3 end 
110dw 0,0 ;partition 3 relative sector 
111dw 0,0 ;partition 3 # of sectors 
112dw 0,0 ;partition 4 begin 
113dw 0,0 ;partition 4 end 
114dw 0,0 ;partition 4 relative sector 
115dw 0,0 ;partition 4 # of sectors 
116signa db 55h,0aah ;signature 
117_data ends 
118end 
119

posted on 2009-01-11 19:48 挑灯看剑 阅读(238) 评论(0)  编辑 收藏 引用 所属分类: Linux内核驱动编程

只有注册用户登录后才能发表评论。
<2009年1月>
28293031123
45678910
11121314151617
18192021222324
25262728293031
1234567

导航

公告

【自我介绍】 08年南开大学硕士毕业 最近关注:算法、Linux、c++、高并发 爱好:滑旱冰、打乒乓球、台球、保龄球

常用链接

随笔分类(139)

文章分类

我常去的网站

技术博客(都是大牛)

技术站点

搜索

积分与排名