1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
; ------------------------------------------
; MISE EN PLACE DE LA GESTION MEMOIRE "FLAT"
; ------------------------------------------
LENGTH = (END_prog-$)/16+1
org 100h
FLAT_sel equ FLAT_desc - GDT
; Installation du mode FLAT
pushf
push ds
cli
xor eax,eax
mov ds,ax
mov word [ds:34h],FLAT_tsr
mov ax,cs
mov [ds:36h],ax
shl eax,4
add dword [cs:GDT+2],eax
pop ds
popf
; Sortie en TSR
mov ah,31h
mov dx,LENGTH
int 21h
mov ah,4Ch ;
int 21h ;exit
;------------------------------------------------------------------------
FLAT_tsr:
push eax
mov al,0Bh
out 20h,al
jmp $+2
; in al,20h
; test al,20h
lgdt [cs:GDT] ; Load GDT Register
push gs
push fs
push es
push ds
push bx
mov eax,CR0
or al,1
mov CR0,eax
jmp $+2
mov bx,FLAT_sel ; Load 4Gb limits
mov ds,bx
mov es,bx
mov fs,bx
mov gs,bx
and al,0FEh ; Back to Real mode
mov CR0,eax
pop bx
pop ds
pop es
pop fs
pop gs
pop eax
iret
GDT:
dw 15 ; Limit (16 bytes)
dw GDT,0 ; Offset within current segment...
dw 0 ; Unused
FLAT_desc:
dw 0ffffh ; Limit (bit 0..15)
db 0,0,0 ; Base (bit 0..23)
db 92h ; Access rights
db 0cfh ; Page granularity + Limit(16..19)
db 0 ; Base (bit 24..31)
END_prog: |
Partager