an odd phenomena:pmode
Posted: Sat Dec 01, 2001 2:39 am
Following is a boot program(writed in TASM32) that will enter pmode.
The odd phenomena is that when I enable A20,
the line "mov byte ptr es:2,'@'" will resets CPU,and if I change 'byte'
to 'word',it will OK.
By contraries,If I disable A20, the line "mov word ptr es:2,'@'" will OK
and 'byte' will resets.
who knows why?
org 7c00h
jmp start
start:
mov ax,0
mov ss,ax
mov sp,0600h
mov es,ax
mov ds,ax
mov ax,3
int 10h
; in al,92h ;|
; or al,2 ;|enable A20
; out 92h,al ;|
;================================
mov bx,cs
shl ebx,4
mov eax,ebx
shr eax,16
mov word ptr [gdtcs+2],bx
mov byte ptr [gdtcs+4],al
mov byte ptr [gdtcs+7],ah
mov di,900h
lea si,gdt
mov cx,24
cld
rep movsb
mov ax,0b800h
mov es,ax
push dword 0
popfd
;=====above from Chris Giese'code
lgdt qword ptr gdtr
mov eax,cr0
or al,1
mov cr0,eax
mov byte ptr es:0,'1' ;this works
db 0eah
dw do_pm
dw gdt_cs
do_pm:
mov byte ptr es:2,'@'
jmp $
gdt:
dq 0 ;NULL descriptor
gdt_cs equ $-gdt
gdtcs:
dw 0ffffh ;limit 4G
dw 0 ;base addr L16
db 0 ;base addr M8
db 9ah ;(cs)code descriptor
db 0cfh ;G/D
db 0 ;base addr H8
gdt_ds equ $-gdt
dw 0ffffh
dw 0
db 0
db 92h ;(ds)data descriptor
db 0cfh
db 0
gdtr:
dw $-gdt-1
dd 900h
The odd phenomena is that when I enable A20,
the line "mov byte ptr es:2,'@'" will resets CPU,and if I change 'byte'
to 'word',it will OK.
By contraries,If I disable A20, the line "mov word ptr es:2,'@'" will OK
and 'byte' will resets.
who knows why?
org 7c00h
jmp start
start:
mov ax,0
mov ss,ax
mov sp,0600h
mov es,ax
mov ds,ax
mov ax,3
int 10h
; in al,92h ;|
; or al,2 ;|enable A20
; out 92h,al ;|
;================================
mov bx,cs
shl ebx,4
mov eax,ebx
shr eax,16
mov word ptr [gdtcs+2],bx
mov byte ptr [gdtcs+4],al
mov byte ptr [gdtcs+7],ah
mov di,900h
lea si,gdt
mov cx,24
cld
rep movsb
mov ax,0b800h
mov es,ax
push dword 0
popfd
;=====above from Chris Giese'code
lgdt qword ptr gdtr
mov eax,cr0
or al,1
mov cr0,eax
mov byte ptr es:0,'1' ;this works
db 0eah
dw do_pm
dw gdt_cs
do_pm:
mov byte ptr es:2,'@'
jmp $
gdt:
dq 0 ;NULL descriptor
gdt_cs equ $-gdt
gdtcs:
dw 0ffffh ;limit 4G
dw 0 ;base addr L16
db 0 ;base addr M8
db 9ah ;(cs)code descriptor
db 0cfh ;G/D
db 0 ;base addr H8
gdt_ds equ $-gdt
dw 0ffffh
dw 0
db 0
db 92h ;(ds)data descriptor
db 0cfh
db 0
gdtr:
dw $-gdt-1
dd 900h