2 ; normal DOS boot sector
4 ; Ported to nasm from FreeDOS fdisk 1.2.0 by:
5 ; Casper Hornstrup (chorns@users.sourceforge.net)
10 global _bootnormal_code
13 ;-----------------------------------------------------------------------
14 ; ENTRY (copied from freedos bootsector)
19 ;-----------------------------------------------------------------------
24 mov ss, ax ; initialize stack
37 jmp word 0x1FE0:0x7c00+ cont-real_start
45 ; search for active partition
46 lea di, [bp+0x1be] ; start of partition table
49 jne active_partition_found
50 add di,0x10 ; next table
51 cmp di, 07c00h+0x1fe; scanned beyond end of table ??
52 jb test_next_for_active
54 ;*****************************************************************
56 db 'no active partition found',0
62 ;*****************************************************************
63 trouble_reading_drive:
65 db 'read error while reading drive',0
68 ;*****************************************************************
70 invalid_partition_code:
72 db 'partition signature != 55AA',0
77 ;*****************************************************************
79 active_partition_found:
81 ; db 'loading active partition',0
85 jc trouble_reading_drive
87 cmp word [es:0x7c00+0x1fe],0xaa55
88 jne invalid_partition_code
90 jmp word 0x0:0x7c00 ; and jump to boot sector code
93 ;*****************************
96 ; IN: DI--> partition info
98 ;*****************************
101 ; /* check for LBA support */
106 jc StandardBios ; if (regs.b.x != 0xaa55 || (regs.flags & 0x01))
107 cmp bx,0xaa55 ; goto StandardBios;
110 ; /* if DAP cannot be used, don't use LBA */
111 ; if ((regs.c.x & 1) == 0)
119 _bios_LBA_address_packet:
122 db 4 ; read four sectors - why not
124 dw 0x7c00 ; fixed boot address for DOS sector
132 ; copy start address of partition to DAP
134 mov [0x7c00+ (_bios_LBA_low-real_start)],ax
136 mov [0x7c00+ (_bios_LBA_high-real_start)],ax
138 mov ax,0x4200 ; regs.a.x = LBA_READ;
139 mov si,0x7c00+ (_bios_LBA_address_packet-real_start); regs.si = FP_OFF(&dap);
144 ;*****************************************************************
145 ; read disk, using standard BIOS
148 mov ax,0x0204 ; regs.a.x = 0x0201;
149 mov bx,0x7c00 ; regs.b.x = FP_OFF(buffer);
150 mov cx,[di+2] ; regs.c.x =
151 ; ((chs.Cylinder & 0xff) << 8) + ((chs.Cylinder & 0x300) >> 2) +
154 mov dh,[di+1] ; regs.d.b.h = chs.Head;
155 ; regs.es = FP_SEG(buffer);
162 ; prints text after call to this function.
165 xor bx, bx ; video page 0
166 mov ah, 0x0E ; else print it
167 int 0x10 ; via TTY mode
168 print: pop si ; this is the first character
169 print1: lodsb ; get token
170 push si ; stack up potential return address
171 cmp al, 0 ; end of string?
172 jne print_1char ; until done
177 times 0x1fe-$+$$ db 0