pmode help
Posted: Sat Apr 24, 2004 11:00 pm
when i try to run this .com-file from pure dos (no emm386 or himem) the cpu reboots. WHY?
i use TASM 2.02 so the syntax is a bit different from NASM.
MASM
.386p
com_seg segment byte private use16 'code'
assume ds:com_seg
assume ss:com_seg
assume cs:com_seg
org 100h
start:
xor eax,eax
mov ax,cs
shl eax,4
mov ebx,eax
add ebx,offset null_desc
mov gdt_base,ebx
lea di,code32_desc
mov [di+2],ax
shr eax,16
mov [di+4],al
mov [di+7],ah
lgdt fword ptr gdt_start
mov eax,cr0
or al,1
mov cr0,eax
db 0EAh ; far jmp
dw pmode ; offset
dw 0008h ; selector
pmode:
mov ax,0010h
mov es,ax
mov byte ptr [es:0B8000h],'A'
hlt
gdt_start:
gdt_limit dw gdt_end-null_desc-1
gdt_base dd 00000000h
null_desc:
dw 0000h
dw 0000h
db 00h
db 00h
db 00h
db 00h
code32_desc:
dw 0FFFFh
dw 0000h
db 00h
db 9Ah
db 0CFh
db 00h
linear_desc:
dw 0FFFFh
dw 0000h
db 00h
db 92h
db 0CFh
db 00h
gdt_end:
com_seg ends
end start
i use TASM 2.02 so the syntax is a bit different from NASM.
MASM
.386p
com_seg segment byte private use16 'code'
assume ds:com_seg
assume ss:com_seg
assume cs:com_seg
org 100h
start:
xor eax,eax
mov ax,cs
shl eax,4
mov ebx,eax
add ebx,offset null_desc
mov gdt_base,ebx
lea di,code32_desc
mov [di+2],ax
shr eax,16
mov [di+4],al
mov [di+7],ah
lgdt fword ptr gdt_start
mov eax,cr0
or al,1
mov cr0,eax
db 0EAh ; far jmp
dw pmode ; offset
dw 0008h ; selector
pmode:
mov ax,0010h
mov es,ax
mov byte ptr [es:0B8000h],'A'
hlt
gdt_start:
gdt_limit dw gdt_end-null_desc-1
gdt_base dd 00000000h
null_desc:
dw 0000h
dw 0000h
db 00h
db 00h
db 00h
db 00h
code32_desc:
dw 0FFFFh
dw 0000h
db 00h
db 9Ah
db 0CFh
db 00h
linear_desc:
dw 0FFFFh
dw 0000h
db 00h
db 92h
db 0CFh
db 00h
gdt_end:
com_seg ends
end start