Basic info
I will make multiple parts of it
BIOS bootloaders must be 512 Bytes and end with 55AA bytes to be considered as bootloaders
So
.code16
.org 0
.text
.global _start
_start:
# Segment setup
xor %ax, %ax
mov %ax, %ds
mov %ax, %es
mov %ax, %ss
# Stack setup
mov $0x9c00, %bp
mov %bp, %sp
# If you don't want kernel, don't do this section from here to disable_int label
# Load Kernel from Disk
mov $0x1000, %ax # Segment 0x1000
mov %ax, %es # ES now points to 0x1000
xor %bx, %bx # Offset 0
# Destination is ES:BX -> (0x1000 * 16) + 0 = 0x10000
mov $2, %ah # BIOS read sector function
mov $8, %al # Number of sectors to read (adjust as needed)
xor %ch, %ch # Cylinder 0
mov $2, %cl # Sector 2 (Sector 1 is the bootloader)
xor %dh, %dh # Head 0
int $0x13
jc disk_error
jmp disable_int
disk_error:
mov $disk_err_msg, %dx
call print
call println
disable_int:
.fill 510-(.-_start), 1, 0 # if any space remains, fill with 0
.word 0xAA55
Top comments (0)