Question Details

No question body available.

Tags

assembly x86-16 bootloader

Answers (1)

Accepted Answer Available
Accepted Answer
June 6, 2026 Score: 4 Rep: 42,111 Quality: Expert Completeness: 60%

All of those print, enablea20, and rdisk subroutines get called from within the real address mode. None of them should linger beneath that [bits 32]. Put the lot in between:

jmp 0x08:protectedmode

print: enable_a20: rdisk:

[bits 32]

Make it count

cli
hlt
jmp $

The infinite loop jmp $ should better read jmp $-2 so that the cli and hlt instructions can re-execute.

Make it a habit

cli
mov eax, 0x10
mov ds, eax
mov es, eax
mov ss, eax
mov fs, eax
mov gs, eax
mov ebp, 0x90000
mov esp, ebp

Even while under the protection of cli, it is a good habit to ALWAYS change SS and SP in tandem AND in this order (you did it all right at the start):

cli
mov ebp, 0x90000
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax       ; 1st
mov esp, ebp     ; 2nd

Magic number

xor ax, ax
mov es, ax
mov bx, 0x8000

What is the use of defining KERNEL equ 0x8000 if you're not using it in your program?
And why repeat setting up ES=0 that was done at the start?
So this becomes:

mov bx, KERNEL

Trust BIOS

mov dl, 0x80

There's not much that you get from BIOS when your bootloader begins, but the number for the BootDrive you do receive in the DL register. Use it instead of this hard-coded 0x80.