pmode help

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
jmpnop

pmode help

Post by jmpnop »

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
ASHLEY4

RE:pmode help

Post by ASHLEY4 »

1) I do not use tasm and i have herd it is not good for OS dev (May be this one).
2) You need a data desc,and load it the same has your code desc (May be this one).
3) your lgdt does not look right (May be this one).
4) you need to load  ds,ss, after the jump with data  (Not likely this one) .
5) you need to CLI before the jump to pmode (*THIS IS THE MAIN ONE *)

Other than that, It looks fine.

ASHLEY4.
jmpnop

RE:pmode help

Post by jmpnop »

it works now
it was the cli AND
TASM cant mix 16 and 32bit code in the same segment
so i entered pmode in my bootsector and jumped to the 32bit kernel.com
thanks
Post Reply