; load the FAT sector we're looking for
push di
push ebx ; offset
- push es ; we want to read at 0:1000, not STAGE3_SEGMENT:1000
+ push es ; we want to read at 0:800, not STAGE3_SEGMENT:800
push eax ; desired LBA
xor ax, ax
mov es, ax
pop ebx ; pop LBA into EBX
- mov di, 0x6000
+ mov di, 0x800
mov cx, 1
call read_sectors
cmp dl, 0
mov ds, ax
mov es, ax
mov ss, ax
- mov sp, 0x7c00 ; just under the soon-to-be-loaded VBR, should be more than sufficient space
+ mov sp, 0xfe00 ; just under the soon-to-be-loaded VBR, should be more than sufficient space
; perform self-relocation
cld
.load_vbr:
; load active partition's VBR
pop si
- mov ax, 0x7c0
+ mov ax, 0xfe0
add si, 8
mov edx, [si]
xor bx, bx
call read_sector
; check is the VBR bootable (ends with 0x55 0xaa), if not halt
- cmp word [0x7dfe], 0xaa55
+ cmp word [0xfffe], 0xaa55
jne .not_bootable
mov dl, [BOOT_DRIVE]
- call 0x7c00
+ call 0xfe00
.not_bootable:
mov si, no_os
call print
bits 16
cpu 686
-org 0x8000
+org 0x1800
%include "../fat32/fat32-structs.s"
.a20_enabled:
print a20_enabled
call get_1st_data_sec
- mov ax, 0x2000
+ mov ax, 0x1000
mov es, ax
mov eax, BPB_RootClus
xor di, di
push es
push ax
xor di, di
- mov ax, 0x100
+ mov ax, 0x1000
mov es, ax
pop ax
call read_cluster
push eax
push ebx
push ecx
- mov esi, 0x1000
+ mov esi, 0x10000
xor ebx, ebx
movzx eax, word BPB_BytsPerSec
movzx bx, byte BPB_SecPerClus
; This is what's going to be on most USB sticks and HDDs, for now
bits 16
-org 0x7c00
+org 0xfe00
cpu 686
-STAGE3_ADDRESS equ 0x8000
+STAGE3_ADDRESS equ 0x1800
STAGE3_SEGMENT equ STAGE3_ADDRESS >> 4
STAGE3_OFFSET equ STAGE3_ADDRESS & 0xf
real_start:
sti
; no need to set up segments and stack again, because MBR did it for us
- mov bp, 0x7c00
+ mov bp, 0xfe00
; we expect the boot drive to be in DL and our partition table entry in DS:SI
mov [BOOT_DRIVE], dl