summaryrefslogtreecommitdiff
path: root/v4.0/src/CMD/FDISK/FDBOOT.ASM
diff options
context:
space:
mode:
Diffstat (limited to 'v4.0/src/CMD/FDISK/FDBOOT.ASM')
-rw-r--r--v4.0/src/CMD/FDISK/FDBOOT.ASM119
1 files changed, 119 insertions, 0 deletions
diff --git a/v4.0/src/CMD/FDISK/FDBOOT.ASM b/v4.0/src/CMD/FDISK/FDBOOT.ASM
new file mode 100644
index 0000000..4d6aaf0
--- /dev/null
+++ b/v4.0/src/CMD/FDISK/FDBOOT.ASM
@@ -0,0 +1,119 @@
1; BOOT - IBM hard disk boot record 6/8/82
2;
3;
4; This is the standard boot record that will be shipped on all hard disks. It contains:
5;
6; 1. Code to load (and give control to) the boot record for 1 of 4 possible
7; operating systems.
8;
9; 2. A partition table at the end of the boot record, followed by the required signature.
10;
11;
12_data segment public
13 assume cs:_data,ds:_data
14
15 org 600h
16
17 cli ;no interrupts for now
18 xor ax,ax
19 mov ss,ax
20 mov sp,7c00h ;new stack at 0:7c00
21 mov si,sp ;where this boot record starts - 0:7c00
22 push ax
23 pop es ;seg regs the same
24 push ax
25 pop ds
26 sti ;interrupts ok now
27 cld
28 mov di,0600h ;where to relocate this boot record to
29 mov cx,100h
30 repnz movsw ;relocate to 0:0600
31; jmp entry2
32 db 0eah
33 dw $+4,0
34entry2:
35 mov si,offset tab ;partition table
36 mov bl,4 ;number of table entries
37next:
38 cmp byte ptr[si],80h ;is this a bootable entry?
39 je boot ;yes
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
43 dec bl
44 jnz next
45 int 18h ;no bootable entries - go to rom basic
46boot:
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
50next1:
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
56bad:
57 mov si,offset m1 ;oops - found a non-zero entry - the table is bad
58msg:
59 lodsb ;get a message character
60 cmp al,0
61 je hold
62 push si
63 mov bx,7
64 mov ah,14
65 int 10h ;and display it
66 pop si
67 jmp msg ;do the entire message
68;
69hold: jmp hold ;spin here - nothing more to do
70tabok:
71 mov di,5 ;retry count
72rdboot:
73 mov bx,7c00h ;where to read system boot record
74 mov ax,0201h ;read 1 sector
75 push di
76 int 13h ;get the boot record
77 pop di
78 jnc goboot ;successful - now give it control
79 xor ax,ax ;had an error, so
80 int 13h ;recalibrate
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
85goboot:
86 mov si,offset m3 ;prepare for invalid boot record
87 mov di,07dfeh
88 cmp word ptr [di],0aa55h ;does the boot record have the
89 ; required signature?
90 jne msg ;no, display invalid system boot record message
91 mov si,bp ;yes, pass partition table entry address
92 db 0eah
93 dw 7c00h,0
94
95include fdisk5.cl1
96
97 org 7beh
98tab: ;partition table
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
115signa db 55h,0aah ;signature
116
117_data ends
118 end
119 \ No newline at end of file