]> git.dujemihanovic.xyz Git - nameless-os.git/blobdiff - boot/x86/mbr.s
x86: mbr: Copy by dword during relocation
[nameless-os.git] / boot / x86 / mbr.s
index 613b24894d993a26fac2891e3ecad4768028cb7d..5319f4b54dfdd772ca503bf50cb0c4f111995073 100644 (file)
@@ -11,14 +11,14 @@ _start:
        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:
@@ -54,16 +54,16 @@ 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