This bootloader loads the kernel from the second sector of a floppy or of an hard disk.
I tested it in bochs(If I remember correctly A20 is already enabled when the bootloader runs)
so I do not have to care if the A20 enabling code is perfect or not
(It is not because it assumes that a word over 0xfffff is 0 (nothing should accessed to it before.)).
While running it's skipped(I've checked this).
So my bootloader works fine until it copies data(nasm syntax):
Code: Select all
xor ecx,ecx
mov ch,[es:0x200] ;size in sectors of 512 bytes (the first byte is not part of the kernel code is its size).
shl ecx,9 ;size now in bytes
xor dx,dx
call segment_set ;set all the segment registers
mov esi,0x7e01
mov edi,0x100000
rep movsb ;but copies to 0x0 instead of 0x100000
mov dx,0x10 ;data descriptor
call segment_set
lgdt [gdt_descriptor]
mov eax,cr0
or ah,1
mov cr0,eax
jmp 0x8:0x0
So code is executed looking like A20 it's enabled
but data are not copied like A20 it's enabled because from 0x100000 only
Code: Select all
add byte ptr ds:[bx+si],al