在big real mode 選取GDT TABLE問題,請多多指教。
在big real mode 選取GDT TABLE問題,請多多指教。
請問大家如果想選取第1和第3組TABLE時候,該如何選取呢?
CODE如下:
.model small
.586p
DSEG SEGMENT USE16
DESC STRUC
LimitL DW 0 ;段界限(BIT0-15)
BaseL DW 0 ;段基地址(BIT0-15)
BaseM DB 0 ;段基地址(BIT16-23)
Attributes DB 0 ;段屬性
LimitH DB 0 ;段界限(BIT16-19)
BaseH DB 0 ;段基地址(BIT24-31)
DESC ENDS
PDesc STRUC
Limit DW 0 ;16位界限
Base DD 0 ;32位基地址
PDesc ENDS
GDT_def Label Fword
Null_Desc DESC < 0h, 0h, 00h, 00h, 000h, 0>
Data_Desc DESC < 0FFFFh, 0h, 00h, 92h, 08Fh, 0>
Data_Desc1 DESC < 0FFFFh, 8000h, 0bh, 92h, 0CFh, 0> ;0b8000
GDT_Addr PDesc <$-GDT_def-1>;
DSEG ENDS
CSEG SEGMENT USE16
ASSUME CS:CSEG,DS:DSEG
.Startup
call Set4gb
;
;
; code
;
.exit
Set4gb PROC NEAR
mov eax, ds
shl eax, 4
xor ebx, ebx
mov bx, offset GDT_def
add eax, ebx
mov dword ptr GDT_Addr+2, eax
lgdt fword ptr GDT_Addr
cli
; mov word ptr GDT_Addr, (2*8-1);
in al, 92h
or al, 002
out 092h, al
out 0edh, al
mov bx, 8
mov eax, cr0
or al, 1
mov cr0, eax
jmp pMod
pMod:
mov fs, bx
mov gs, bx
and al, 0FEh
mov cr0, eax
jmp rMod
rMod:
mov ax, 0
mov fs, ax
mov gs, ax
sti
ret
Set4gb ENDP
hexput endp
CSEG ENDS
end