2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Bootsector for ISO file system
4 * PURPOSE: Normal DOS boot sector
5 * Ported to nasm from FreeDOS fdisk 1.2.0 by:
6 * PROGRAMMERS: Casper Hornstrup (chorns@users.sourceforge.net)
9 /* INCLUDES ******************************************************************/
13 //-----------------------------------------------------------------------
14 // ENTRY (copied from freedos bootsector)
16 // IN: DL = boot drive
17 // OUT: DL = boot drive
19 //-----------------------------------------------------------------------
26 mov ss, ax // initialize stack
32 /* Copy 512 bytes of MBR to 1fe0:7c00 */
40 /* Jump into relocated code */
41 ljmp16 HEX(1FE0), cont
44 /* Setup segment registers */
50 /* Search for active partition */
51 lea di, [bp + HEX(1be)] // start of partition table
53 test byte ptr ds:[di], HEX(80)
54 jne active_partition_found
55 add di, 16 // next table
56 cmp di, HEX(07c00) + HEX(1fe) // scanned beyond end of table ??
57 jb test_next_for_active
59 /*****************************************************************/
61 .asciz "no active partition found"
67 /*****************************************************************/
68 trouble_reading_drive:
70 .asciz "read error while reading drive"
73 /*****************************************************************/
75 invalid_partition_code:
77 .asciz "partition signature != 55AA"
81 /*****************************************************************/
83 active_partition_found:
85 // .asciz "loading active partition"
89 jc trouble_reading_drive
91 cmp word ptr es:[HEX(7c00)+HEX(1fe)], HEX(0aa55)
92 jne invalid_partition_code
94 ljmp16 0, HEX(7c00) // and jump to boot sector code
96 /*****************************
99 * IN: DI--> partition info
101 *****************************/
103 /* check for LBA support */
108 jc StandardBios // if (regs.b.x != 0xaa55 || (regs.flags & 0x01))
109 cmp bx, HEX(0aa55) // goto StandardBios;
112 /* if DAP cannot be used, don't use LBA
113 if ((regs.c.x & 1) == 0)
114 goto StandardBios; */
121 _bios_LBA_address_packet:
124 .byte 4 // read four sectors - why not
126 .word HEX(7c00) // fixed boot address for DOS sector
137 // copy start address of partition to DAP
139 mov word ptr ds:[_bios_LBA_low], ax
141 mov word ptr ds:[_bios_LBA_high], ax
143 mov ax, HEX(4200) // regs.a.x = LBA_READ;
144 mov si, offset _bios_LBA_address_packet // regs.si = FP_OFF(&dap);
149 /*****************************************************************
150 * read disk, using standard BIOS
153 mov ax, HEX(0204) // regs.a.x = 0x0201;
154 mov bx, HEX(7c00) // regs.b.x = FP_OFF(buffer);
157 ((chs.Cylinder & 0xff) << 8) + ((chs.Cylinder & 0x300) >> 2) +
160 mov cx, word ptr ds:[di + 2]
161 mov dh, byte ptr ds:[di + 1] // regs.d.b.h = chs.Head;
162 // regs.es = FP_SEG(buffer);
167 * prints text after call to this function.
170 xor bx, bx // video page 0
171 mov ah, HEX(0E) // else print it
172 int HEX(10) // via TTY mode
174 pop si // this is the first character
177 push si // stack up potential return address
178 cmp al, 0 // end of string?
179 jne print_1char // until done
180 ret // and jump to it
183 .byte HEX(55), HEX(0aa)