But I am stuck at the far jump after setting the bit 0 of cr0 register.
During the assembling by nasm I get the following warning:
Code: Select all
bootloader.asm:182: warning: word data exceeds bounds
Code: Select all
call setup_basic_gdt
mov ax,0x10
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
cli
mov eax,cr0
or eax,1
mov cr0,eax
mov eax,0xDEADBEEF
;jmp 0x8:0x00010000 ;Doesn't work (this is the place where I get the warning)
db 0x66 ;Current workaround
db 0xea
dd 0x00010000
dw 0x0008
How do I get NASM to emit the opcode for far jump of type ptr16:32
Also when I see the logs after exiting the VM (VirtualBox), the base of data descriptor appears to be 0x100 and limit is 0xffff whereas the expected value is base=0x00 and limit=0xfffff
Code: Select all
00:00:14.138038 ****************** Guest state at power off ******************
00:00:14.138041 Guest CPUM (VCPU 0) state:
00:00:14.138044 eax=cafebabe ebx=00000000 ecx=00040000 edx=534d4150 esi=00000203 edi=00000000
00:00:14.138046 eip=00010006 esp=00000c00 ebp=00000006 iopl=0 nv up di pl zr na po nc
00:00:14.138047 cs={0008 base=0000000000000000 limit=000fffff flags=0000409b} dr0=00000000 dr1=00000000
00:00:14.138049 ds={0010 base=0000000000000100 limit=0000ffff flags=00000093} dr2=00000000 dr3=00000000
00:00:14.138050 es={0010 base=0000000000000100 limit=0000ffff flags=00000093} dr4=00000000 dr5=00000000
00:00:14.138051 fs={0010 base=0000000000000100 limit=0000ffff flags=00000093} dr6=ffff0ff0 dr7=00000400
00:00:14.138052 gs={0010 base=0000000000000100 limit=0000ffff flags=00000093} cr0=00000011 cr2=00000000
00:00:14.138053 ss={0010 base=0000000000000100 limit=0000ffff flags=00000093} cr3=00000000 cr4=00000000
00:00:14.138054 gdtr=000000000000804c:001f idtr=0000000000000000:ffff eflags=00000006
00:00:14.138055 ldtr={0000 base=00000000 limit=0000ffff flags=00000082}
00:00:14.138056 tr ={0000 base=00000000 limit=0000ffff flags=0000008b}
Code: Select all
basic_GDT_table:
null_descriptor dq 0
code_segment:
cs_lim dw 0xffff
cs_base dw 0x0000
cs_base_high db 0x00
cs_access db 10011010b ;type 0x9a
cs_lim_high_flags db 0x4f
cs_base_highest db 0x00
data_segment:
ds_lim dw 0xffff
ds_base dw 0x0000
ds_base_high db 0x00
ds_access db 10010010b ;type 0x92
ds_lim_high_flags db 0x4f
ds_base_highest db 0x00
tss_segment dq 0