;******************************************
; botloader code begin
[bits 16] ; tell assembler that working in real mode(16 bit mode)
[org 0x7c00] ; organize from 0x7C00 memory location where BIOS will load us
start: ; start label from where our code starts
xor ax,ax ; set ax register to 0
mov ds,ax ; set data segment(ds) to 0
mov es,ax ; set extra segment(es) to 0
;******************************************
; jumping from rel mode to protected mode
; by using disk interrupt
mov ah, 0x02 ; load second stage to memory
mov al, 0x10 ; numbers of sectors to read into memory
mov dl, 0x80 ; sector read from fixed/usb disk
mov ch, 0 ; cylinder number
mov dh, 0 ; head number
mov cl, 2 ; sector number
mov bx, _start ; load into es:bx segment :offset of buffer
int 0x13 ; disk I/O interrupt
; before jumping clearing all interrupts
cli
; jump to protected mode
jmp _start ; jump to second stage
times (510 - ($ - $$)) db 0x00 ;set 512 bytes for boot sector which are necessary
dw 0xAA55 ; boot signature 0xAA & 0x55
; bootloader code end
;******************************************
; x86 code begin
_start:
main :
doesn't jump do protected mode. Theres no GDT in this code, an also, in protected mode you can't use bios interrupts.
Postdata: The disk reading code doesn't work on some emulators and computers, because CS isn't 0 ,you don't set the stack to 0x7c00, you musnt set dl to anything, you don't set bx to 0x7e00 and you don't jump to 0x7e00.