使用LDT又出了奇怪的问题!暂存,以后有时间再看!
下面这段代码,本意是跳入LDT的,但是执行会不断的循环,稍微跟了一下,发现out 0x92,al这句,执行会跳回起始地址,很郁闷!这句以前可没有错过,先留存,以后有时间在耐心看吧!org 0x100
jmp LABEL_BEGIN
LABEL_GDT dw 0,0,0,0
LABEL_DESC_CODE32 dw SegCode32Len - 1,0,0x9800,0x0040
LABEL_DESC_VIDEO dw 0xffff,0x8000,0x920b,0x0040
LABEL_DESC_LDT dw LdtLen - 1,0,0x8200,0x0040
GdtLen equ $ - LABEL_GDT
GdtPtr dw GdtLen - 1
dd 0
SelectorCode32 equ LABEL_DESC_CODE32 - LABEL_GDT
SelectorVideo equ LABEL_DESC_VIDEO - LABEL_GDT
SelectorLdt equ LABEL_DESC_LDT - LABEL_GDT
LABEL_LDT:
LABEL_DESC_CODEA dw SegCodeALen - 1,0,0x9800,0x0040
LdtLen equ $ - LABEL_LDT
SelectorCodeA equ LABEL_DESC_CODEA - LABEL_LDT + 4
LABEL_BEGIN:
mov ax,cs
mov ds,ax
mov ss,ax
mov sp,0x100
xor eax,eax
mov ax,cs
shl eax,4
add eax,LABEL_SEG_CODE32
mov ,ax
shr eax,16
mov ,al
mov ,ah
; Code32 Segment Init
xor eax,eax
mov ax,cs
shl eax,4
add eax,LABEL_GDT
mov ,eax
; GDT init
xor eax,eax
mov ax,cs
shl eax,4
add eax,LABEL_LDT
mov ,ax
shr eax,16
mov ,al
mov ,ah
; Ldt(GDT)
xor eax,eax
mov ax,cs
shl eax,4
add eax,LABEL_SEG_CODEA
mov ,ax
shr eax,16
mov ,al
mov ,ah
; Ldt init
lgdt
cli
in al,0x92
or al,1
out 0x92,al
mov eax,cr0
or al,2
mov cr0,eax
jmp dword SelectorCode32:0
LABEL_SEG_CODE32:
mov ax,SelectorVideo
mov gs,ax
mov al,'P'
mov ah,0xc
mov ,ax
mov ax,SelectorLdt
lldt ax
jmp dword SelectorCodeA:0
SegCode32Len equ $ - LABEL_SEG_CODE32
LABEL_SEG_CODEA:
mov al,'L'
mov ah,0xc
mov ,ax
jmp $
SegCodeALen equ $ - LABEL_SEG_CODEA
nasm?还是和操作系统有关的。。难! oggplay 发表于 2014-7-31 09:33
nasm?还是和操作系统有关的。。难!
是啊!有问题的程序,不想就这么删掉,又没许多时间debug,所以先放在这里,以后有时间有心情在慢慢看看!
页:
[1]