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
- mov si, 0x7c00
- mov di, 0x600
- mov cx, 0x100 ; 256 words = 512 bytes
- rep movsw
+ mov esi, 0x7c00
+ mov edi, 0x600
+ mov ecx, 0x80 ; 128 dwords = 512 bytes
+ rep movsd
; some BIOSes may set CS to 0x7c0, work around that
jmp 0:real_start
real_start:
.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