为什么在切换实模式和保护模式时会死机
时间:2010-11-25
来源:互联网
jump16 macro selector,offsetv
db 0eah ;jmp
dw offsetv ;2 bytes offset address
dw selector
endm
jump32 macro selector,offsetv
db 0eah
dd offsetv ;4 bytes offset address
dw selector
endm
;
descriptor struc
limitl dw 0
basel dw 0
basem db 0
attributes dw 0
baseh db 0
descriptor ends
;
pdesc struc
limit dw 0
base dd 0
pdesc ends
.386P
;---------------------------------
dseg segment use16
gdt label byte
dummy descriptor <>
code32_sel = 08h
code32 descriptor <0ffffh,,,4098h,>
gdtlen = $-gdt
;
vgdtr pdesc <gdtlen-1,>
dseg ends
;----------------------
;
cseg1 segment use16
assume cs:cseg1, ds:dseg
start:
mov ax,dseg
mov ds,ax
;
mov bx,16
mul bx
add ax,offset gdt
adc dx,0
mov word ptr vgdtr.base,ax
mov word ptr vgdtr.base+2,dx
;
mov ax,cseg2
mul bx
mov code32.basel,ax
mov code32.basem,dl
mov code32.baseh,dh
;
lgdt fword ptr vgdtr
;
cli
call ea20
;
mov eax,cr0
or eax,1
mov cr0,eax
;进入保护模式
jump16 <code32_sel>,<offset spm32>
;
toreal:
call da20
sti
mov ah,4ch
int 21h
;
;
ea20 proc
push ax
in al,92h
or al,2
out 92h,al
pop ax
ret
ea20 endp
;
;
da20 proc
push ax
in al,92h
and al,0fdh ;0fdh=not 20h
out 92h,al
pop ax
ret
da20 endp
cseg1 ends
;---------------------------------
cseg2 segment use32
assume cs:cseg2
spm32:
mov eax,cr0
and eax,0fffffffeh
mov cr0,eax
;回到实模式
jump32 <seg toreal>,<offset toreal>
;
cseg2 ends
;--------------------------
end start
我的程序很简单,就是从实模式进入32位的保护模式,然后就返回到实模式,可是运行时会死机(我是用TASM编译的,
不知道为什么用masm5.1编译老是通不过),请问错在哪?如何改?
db 0eah ;jmp
dw offsetv ;2 bytes offset address
dw selector
endm
jump32 macro selector,offsetv
db 0eah
dd offsetv ;4 bytes offset address
dw selector
endm
;
descriptor struc
limitl dw 0
basel dw 0
basem db 0
attributes dw 0
baseh db 0
descriptor ends
;
pdesc struc
limit dw 0
base dd 0
pdesc ends
.386P
;---------------------------------
dseg segment use16
gdt label byte
dummy descriptor <>
code32_sel = 08h
code32 descriptor <0ffffh,,,4098h,>
gdtlen = $-gdt
;
vgdtr pdesc <gdtlen-1,>
dseg ends
;----------------------
;
cseg1 segment use16
assume cs:cseg1, ds:dseg
start:
mov ax,dseg
mov ds,ax
;
mov bx,16
mul bx
add ax,offset gdt
adc dx,0
mov word ptr vgdtr.base,ax
mov word ptr vgdtr.base+2,dx
;
mov ax,cseg2
mul bx
mov code32.basel,ax
mov code32.basem,dl
mov code32.baseh,dh
;
lgdt fword ptr vgdtr
;
cli
call ea20
;
mov eax,cr0
or eax,1
mov cr0,eax
;进入保护模式
jump16 <code32_sel>,<offset spm32>
;
toreal:
call da20
sti
mov ah,4ch
int 21h
;
;
ea20 proc
push ax
in al,92h
or al,2
out 92h,al
pop ax
ret
ea20 endp
;
;
da20 proc
push ax
in al,92h
and al,0fdh ;0fdh=not 20h
out 92h,al
pop ax
ret
da20 endp
cseg1 ends
;---------------------------------
cseg2 segment use32
assume cs:cseg2
spm32:
mov eax,cr0
and eax,0fffffffeh
mov cr0,eax
;回到实模式
jump32 <seg toreal>,<offset toreal>
;
cseg2 ends
;--------------------------
end start
我的程序很简单,就是从实模式进入32位的保护模式,然后就返回到实模式,可是运行时会死机(我是用TASM编译的,
不知道为什么用masm5.1编译老是通不过),请问错在哪?如何改?
作者: leetow2003 发布时间: 2010-11-25
我也卡在这里很久啦,。。。唉。。。。
作者: masmaster 发布时间: 2010-11-25
也找不到资料,怎么解决呀
作者: leetow2003 发布时间: 2010-11-25
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28