Thanks for reply Alex,
I usually load the registers in this order GS,FS,DS,ES,SS with value zero (segments of the real mode) or ignore. I tested the code implementing the operand 'HLT' producing a triple fault, here the code and Bochs log.
Neo92
Code: Select all
org 7c00h
use16
jmp 0:rmode
rmode:
mov ax,0
mov gs,ax
mov fs,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0fffeh
cli
lgdt[gdt]
mov eax,cr4
or al,1
mov cr4,eax
mov eax,cr0
or eax,1
mov cr0,eax
jmp gdt_code-gdt_table:pmode
vm86:
mov ax,0
mov gs,ax
mov fs,ax
mov ds,ax
mov es,ax
mov ss,ax
mov sp,0fffeh
mov ax,3
int 10h
mov bx,0b800h
mov es,bx
mov bx,0
mov byte[es:bx+2],42h
mov byte[es:bx+3],7
hlt
jmp $
use32
pmode:
mov ax,gdt_data-gdt_table
mov gs,ax
mov fs,ax
mov ds,ax
mov es,ax
mov ss,ax
mov esp,9fffch
mov al,0f0h
out 60h,al
mov al,0
out 60h,al
scan1:
in al,60h
cmp al,1eh
jne scan1
mov byte[0b8000h],41h
mov byte[0b8000h+1],7
push 0
push 0
push 0
push 0
push 0
push 0fffeh
push 20000h
push 0
push vm86
iret
gdt:
dw gdt_table-1
dd gdt_table
gdt_table:
dd 0
dd 0
gdt_code:
dw 0ffffh
dw 0
db 0
db 9ah
db 0cfh
db 0
gdt_data:
dw 0ffffh
dw 0
db 0
db 92h
db 0cfh
db 0
times 510-($-$$) db 0
dw 0aa55h
Code: Select all
00014918918i[BIOS ] Booting from 0000:7c00
00049566128e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x0d)
00049566128e[CPU0 ] interrupt(): gate descriptor is not valid sys seg (vector=0x08)
00049566128i[CPU0 ] CPU is in v8086 mode (active)
00049566128i[CPU0 ] CS.mode = 16 bit
00049566128i[CPU0 ] SS.mode = 16 bit
00049566128i[CPU0 ] EFER = 0x00000000
00049566128i[CPU0 ] | EAX=60000030 EBX=00000000 ECX=00090000 EDX=00000000
00049566128i[CPU0 ] | ESP=0000fffe EBP=00000000 ESI=000e0000 EDI=0000ffac
00049566128i[CPU0 ] | IOPL=0 id vip vif ac VM RF nt of df if tf sf zf af pf cf
00049566128i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00049566128i[CPU0 ] | CS:0000( 0001| 0| 3) 00000000 0000ffff 0 0
00049566128i[CPU0 ] | DS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00049566128i[CPU0 ] | SS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00049566128i[CPU0 ] | ES:b800( 0002| 0| 3) 000b8000 0000ffff 0 0
00049566128i[CPU0 ] | FS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00049566128i[CPU0 ] | GS:0000( 0002| 0| 3) 00000000 0000ffff 0 0
00049566128i[CPU0 ] | EIP=00007c59 (00007c59)
00049566128i[CPU0 ] | CR0=0x60000011 CR2=0x00000000
00049566128i[CPU0 ] | CR3=0x00000000 CR4=0x00000001
00049566128i[CPU0 ] 0x0000000000007c59>> hlt : F4
00049566128e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting
00049566128i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00049566128i[CPU0 ] cpu hardware reset