who could help me?Thanks.
Look:
Code: Select all
;----------------------------------------------
JUMP16 MACRO selector, offsetv
DB 0EAH
DW offsetv
DW selector
ENDM
;---------------------------------------------
CALL16 MACRO selector, offsetv
DB 9AH
DW offsetv
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
;-----------------------------------------------
GATE STRUC
OFFSETL DW 0
SELECTOR DW 0
DCOUNT DB 0
GTYPE DB 0
OFFSETH DW 0
GATE ENDS
;-----------------------------------------------
.386P
;----------------------------------------------------------
;GDT
GDTSEG SEGMENT PARA USE16
GDT LABEL BYTE
DUMMY DESCRIPTOR <>
;
DEMOTSS DESCRIPTOR <104,DEMOTSSSEG,,89H,>
DEMOTSS_SEL = DEMOTSS - GDT
;
DEMOLDTD DESCRIPTOR <DEMOLDTLEN-1,DEMOLDTSEG, , 82H,>
DEMOLDT_SEL = DEMOLDTD - GDT
;
TEMPCODE DESCRIPTOR <0FFFFH,TEMPCODESEG, ,98H, >
TEMPCODE_SEL = TEMPCODE - GDT
GDTLEN = $-GDT
GDTSEG ENDS
;----------------------------------------------------------
;LDT
DEMOLDTSEG SEGMENT PARA USE16
DEMOLDT LABEL BYTE
;
DEMOSTACK0 DESCRIPTOR <DEMOSTACK0LEN-1, DEMOSTACK0SEG, , 92H , >
DEMOSTACK0_SEL = (DEMOSTACK0 - DEMOLDT) + 04H
;
DEMOSTACK1 DESCRIPTOR <DEMOSTACK1LEN-1, DEMOSTACK1SEG, , 92H + 20H, >
DEMOSTACK1_SEL = (DEMOSTACK1-DEMOLDT) + 04H + 01H
;
DEMOSTACK3 DESCRIPTOR <DEMOSTACK3LEN -1, DEMOSTACK3SEG, , 92H + 60H, >
DEMOSTACK3_SEL = DEMOSTACK3-DEMOLDT + 04H + 03H
;
DEMOCODE DESCRIPTOR <DEMOCODELEN-1, DEMOCODESEG, , 98H + 60H, >
DEMOCODE_SEL = (DEMOCODE-DEMOLDT) + 04H + 03H
;
T32CODE DESCRIPTOR <T32CODELEN-1, T32CODESEG, , 98H , >
T32CODE_SEL = (T32CODE-DEMOLDT) + 04H
;
TOT32GATEA GATE <T32Begin,T32CODE_SEL, 0, 8CH,>
TOT32A_SEL = (TOT32GATEA-DEMOLDT) + 04H
;
TOT32GATEB GATE <T32End,T32CODE_SEL, 0, 8CH + 60H, 0>
TOT32B_SEL = (TOT32GATEB-DEMOLDT) + 04H
;
DEMOLDTLEN = $ - DEMOLDT
DEMOLDTSEG ENDS
;----------------------------------------------------------
;TSS
DEMOTSSSEG SEGMENT PARA USE16
DD 0
DW DEMOSTACK0LEN,0
DW DEMOSTACK0_SEL,0
DW DEMOSTACK1LEN,0
DW DEMOSTACK1_SEL,0
DD ?
DW ?, 0
DD 0
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DD ?
DW ?, 0
DW ?, 0
DW ?, 0
DW ?, 0
DW ?, 0
DW ?, 0
DW DEMOLDT_SEL, 0
DW 0
DW $ + 2
DB 0FFH
DEMOTSSSEG ENDS
;----------------------------------------------------------
DEMOSTACK0SEG SEGMENT PARA USE16
DEMOSTACK0LEN = 512
DB DEMOSTACK0LEN DUP(0)
DEMOSTACK0SEG ENDS
;----------------------------------------------------------
DEMOSTACK1SEG SEGMENT PARA USE16
DEMOSTACK1LEN = 512
DB DEMOSTACK1LEN DUP(0)
DEMOSTACK1SEG ENDS
;----------------------------------------------------------
DEMOSTACK3SEG SEGMENT PARA USE16
DEMOSTACK3LEN = 512
DB DEMOSTACK3LEN DUP(0)
DEMOSTACK3SEG ENDS
;----------------------------------------------------------
;----------------------------------------------------------
DEMOCODESEG SEGMENT PARA USE16
ASSUME CS:DEMOCODESEG
DEMOBEGIN:
CALL16 TOT32B_SEL, 0
DEMOCODELEN = $ - DEMOBEGIN
DEMOCODESEG ENDS
;----------------------------------------------------------
T32CODESEG SEGMENT PARA USE16
ASSUME CS:T32CODESEG
T32BEGIN:
;
MOV AX, DEMOSTACK0_SEL
MOV SS, AX
MOV ESP, DEMOSTACK0LEN
;
PUSH DWORD PTR DEMOSTACK3_SEL
PUSH DWORD PTR DEMOSTACK3LEN
;
PUSH DWORD PTR DEMOCODE_SEL
PUSH OFFSET DEMOBEGIN
;
RETF
T32END:
JUMP16 TEMPCODE_SEL, <OFFSET TOREAL>
T32CODELEN = $ - T32BEGIN
T32CODESEG ENDS
;----------------------------------------------------------
TEMPCODESEG SEGMENT PARA USE16
ASSUME CS:TEMPCODESEG
VIRTUAL:
;Load TR
MOV AX, DEMOTSS_SEL
LTR AX
;Load LDTR
MOV BX, DEMOLDT_SEL
LLDT BX
;
JUMP16 TOT32A_SEL, 0
TOREAL:
;
MOV EAX, CR0
AND AX, 0FFFEH
MOV CR0, EAX
JUMP16 <SEG REAL>, <OFFSET REAL>
TEMPCODELEN = $ - VIRTUAL
TEMPCODESEG ENDS
;----------------------------------------------------------
RDATASEG SEGMENT PARA USE16
VGDTR PDESC <GDTLEN-1, >
RDATASEG ENDS
;----------------------------------------------------------
RCODESEG SEGMENT PARA USE16
ASSUME CS:RCODESEG
START:
;Set GDT Segment
ASSUME DS:GDTSEG
MOV AX,GDTSEG
MOV DS,AX
;
MOV BX,16
MOV AX,DEMOTSSSEG
MUL BX
MOV DEMOTSS.BASEL,AX
MOV DEMOTSS.BASEM,DL
MOV DEMOTSS.BASEH,DH
;
MOV AX,DEMOLDTSEG
MUL BX
MOV DEMOLDTD.BASEL,AX
MOV DEMOLDTD.BASEM,DL
MOV DEMOLDTD.BASEH,DH
;
MOV AX,TEMPCODESEG
MUL BX
MOV TEMPCODE.BASEL,AX
MOV TEMPCODE.BASEM,DL
MOV TEMPCODE.BASEH,DH
;Set LDT Segment
ASSUME DS:DEMOLDTSEG
MOV AX,DEMOLDTSEG
MOV DS,AX
MOV BX,16
MOV AX,DEMOSTACK0SEG
MUL BX
MOV DEMOSTACK0.BASEL,AX
MOV DEMOSTACK0.BASEM,DL
MOV DEMOSTACK0.BASEH,DH
;
MOV AX,DEMOSTACK1SEG
MUL BX
MOV DEMOSTACK1.BASEL,AX
MOV DEMOSTACK1.BASEM,DL
MOV DEMOSTACK1.BASEH,DH
;
MOV AX,DEMOSTACK3SEG
MUL BX
MOV DEMOSTACK3.BASEL,AX
MOV DEMOSTACK3.BASEM,DL
MOV DEMOSTACK3.BASEH,DH
;
MOV AX,DEMOCODESEG
MUL BX
MOV DEMOCODE.BASEL,AX
MOV DEMOCODE.BASEM,DL
MOV DEMOCODE.BASEH,DH
;
MOV AX,T32CODESEG
MUL BX
MOV T32CODE.BASEL,AX
MOV T32CODE.BASEM,DL
MOV T32CODE.BASEH,DH
;
ASSUME DS:RDATASEG
MOV AX, RDATASEG
MOV DS, AX
MOV BX,16
MOV AX,GDTSEG
MUL BX
MOV WORD PTR VGDTR.BASE,AX
MOV WORD PTR VGDTR.BASE+2,DX
LGDT FWORD PTR VGDTR
CLI
;
call ea20
MOV EAX,CR0
OR EAX,1
MOV CR0,EAX
;
JUMP16 TEMPCODE_SEL, <OFFSET VIRTUAL>
REAL:
STI
call da20
MOV AX, 4C00H
INT 21H
;-----------------------------------
ea20 proc near
push ax
in al,92h
or al,2
out 92h,al
pop ax
ret
ea20 endp
;
;
da20 proc near
push ax
in al,92h
and al,0fdh ;0fdh=not 20h
out 92h,al
pop ax
ret
da20 endp
;-------------------------------------
RCODESEG ENDS
END START