]>
wirehaze git hosting - MS-DOS.git/blob - v4.0/src/CMD/FDISK/FDBOOT.ASM
1 ; BOOT - IBM hard disk boot record 6/8/82
4 ; This is the standard boot record that will be shipped on all hard disks. It contains:
6 ; 1. Code to load (and give control to) the boot record for 1 of 4 possible
9 ; 2. A partition table at the end of the boot record, followed by the required signature.
13 assume
cs:_data
,ds:_data
17 cli ;no interrupts for now
20 mov sp,7c00h
;new stack at 0:7c00
21 mov si,sp ;where this boot record starts - 0:7c00
23 pop es ;seg regs the same
26 sti ;interrupts ok now
28 mov di,0600h ;where to relocate this boot record to
30 repnz movsw ;relocate to 0:0600
35 mov si,offset tab
;partition table
36 mov bl,4 ;number of table entries
38 cmp byte ptr[si],80h
;is this a bootable entry?
40 cmp byte ptr[si],0 ;no, is boot indicator zero?
41 jne bad
;no, it must be x"00" or x"80" to be valid
42 add si,16 ;yes, go to next entry
45 int 18h
;no bootable entries - go to rom basic
47 mov dx,[si] ;head and drive to boot from
48 mov cx,[si+2] ;cyl, sector to boot from
49 mov bp,si ;save table entry address to pass to partition boot record
51 add si,16 ;next table entry
52 dec bl ;# entries left
53 jz tabok
;all entries look ok
54 cmp byte ptr[si],0 ;all remaining entries should begin with zero
55 je next1
;this one is ok
57 mov si,offset m1
;oops - found a non-zero entry - the table is bad
59 lodsb ;get a message character
65 int 10h
;and display it
67 jmp msg
;do the entire message
69 hold: jmp hold
;spin here - nothing more to do
73 mov bx,7c00h
;where to read system boot record
74 mov ax,0201h ;read 1 sector
76 int 13h
;get the boot record
78 jnc goboot
;successful - now give it control
79 xor ax,ax ;had an error, so
81 dec di ;reduce retry count
82 jnz rdboot
;if retry count above zero, go retry
83 mov si,offset m2
;all retries done - permanent error - point to message,
84 jmp msg
;go display message and loop
86 mov si,offset m3
;prepare for invalid boot record
88 cmp word ptr [di],0aa55h ;does the boot record have the
90 jne msg
;no, display invalid system boot record message
91 mov si,bp ;yes, pass partition table entry address
99 dw 0,0 ;partition 1 begin
100 dw 0,0 ;partition 1 end
101 dw 0,0 ;partition 1 relative sector (low, high parts)
102 dw 0,0 ;partition 1 # of sectors (low, high parts)
103 dw 0,0 ;partition 2 begin
104 dw 0,0 ;partition 2 end
105 dw 0,0 ;partition 2 relative sector
106 dw 0,0 ;partition 2 # of sectors
107 dw 0,0 ;partition 3 begin
108 dw 0,0 ;partition 3 end
109 dw 0,0 ;partition 3 relative sector
110 dw 0,0 ;partition 3 # of sectors
111 dw 0,0 ;partition 4 begin
112 dw 0,0 ;partition 4 end
113 dw 0,0 ;partition 4 relative sector
114 dw 0,0 ;partition 4 # of sectors
115 signa db 55h
,0aah ;signature