home *** CD-ROM | disk | FTP | other *** search
/ PC Interdit / pc-interdit.iso / memory / flat / rmemasm.asm < prev    next >
Assembly Source File  |  1994-10-31  |  5KB  |  145 lines

  1. ;****************************************************************************
  2. ;***                   MICRO APPLICATION "PC INTERDIT"                    ***
  3. ;***                  =================================                   ***
  4. ;***                                                                      ***
  5. ;***                                                                      ***
  6. ;*** Auteur          : Boris Bertelsons                                   ***
  7. ;*** Nom de fichier  : RMEM.PAS                                           ***
  8. ;*** Dernière modif. : 28.04.1994                                         ***
  9. ;*** Version         : 1.0                                                ***
  10. ;*** Compilateur     : Turbo Pascal 6.0 et supérieur                      ***
  11. ;****************************************************************************
  12.  
  13. .386P
  14. .model tpascal
  15.  
  16. .data
  17. extrn GDT_Off         : byte
  18. extrn GDT             : byte
  19.  
  20. .code
  21. extrn xms_enable_a20  : far
  22.  
  23. public mem_lire
  24. public mem_Write
  25. public Enable_4Giga
  26. public Multitache_actif
  27.  
  28.  
  29. ;*************************************************************************
  30. ;***                                                                   ***
  31. ;***   Vérifie s'il y a multitâche actif  QEMM ou EMM386               ***
  32. ;***                                                                   ***
  33. ;*************************************************************************
  34. Multitache_actif proc pascal
  35.    mov eax,cr0
  36.    and ax,1
  37.    ret
  38. Multitache_actif endp
  39.  
  40. ;*************************************************************************
  41. ;***                                                                   ***
  42. ;***      Copie un bloc de RMEM dans la mémoire principale             ***
  43. ;***                                                                   ***
  44. ;*************************************************************************
  45. mem_Lire proc near
  46.          push bp
  47.          mov  bp,sp
  48.  
  49. source   equ dword ptr ss:[bp+10]  ; "Déclarer les variables" 
  50. ofscible  equ word ptr ss:[bp+8]
  51. segcible  equ word ptr ss:[bp+6]
  52. longueur   equ word ptr ss:[bp+4]
  53.  
  54.          call xms_Enable_A20
  55.          mov  ax,segcible          ; addy mémoire principale vers ES:SI
  56.          mov  es,ax
  57.          mov  di,ofscible
  58.          xor  ax,ax                ; Adresse source RMEM vers GS:EAX
  59.          mov  gs,ax
  60.          mov  eax,source
  61.          mov  cx,longueur
  62. lloop:   mov  bl,byte ptr gs:[eax] ; copie les octets
  63.          mov  es:[di],bl
  64.          inc  eax
  65.          inc  di
  66.          loop lloop
  67.          pop  bp
  68.          ret  10
  69. mem_Lire endp
  70.  
  71.  
  72. ;*************************************************************************
  73. ;***                                                                   ***
  74. ;***       Copie un bloc de mémoire principale dans la RMEM            ***
  75. ;***                                                                   ***
  76. ;*************************************************************************
  77.  
  78. mem_Write proc near
  79.          push bp
  80.          mov  bp,sp
  81.  
  82. source   equ dword ptr ss:[bp+10]  ; Déclaration des "variables" 
  83. ofscible  equ word ptr ss:[bp+8]
  84. segcible  equ word ptr ss:[bp+6]
  85. longueur   equ word ptr ss:[bp+4]
  86.  
  87.          call xms_Enable_A20
  88.          mov  ax,segcible          ; addy de mémoire principale vers ES:SI
  89.          mov  es,ax
  90.          mov  di,ofscible
  91.          xor  ax,ax                ; Adresse source RMEM vers GS:EAX
  92.          mov  gs,ax
  93.          mov  eax,source
  94.          mov  cx,longueur
  95. nloop:
  96.          mov  bl,es:[di]           ; copie les octets
  97.          mov  byte ptr gs:[eax],bl
  98.          inc  eax
  99.          inc  di
  100.          loop nloop
  101.          pop  bp
  102.          ret  10
  103. mem_Write endp
  104.  
  105. ;*************************************************************************
  106. ;***                                                                   ***
  107. ;***            Fait passer le processeur en modèle flat               ***
  108. ;***                                                                   ***
  109. ;*************************************************************************
  110.  
  111. Enable_4Giga proc near
  112.         mov GDT_Off[0],16
  113.         mov eax,seg GDT
  114.         shl eax,4
  115.         mov bx,offset GDT
  116.         movzx ebx,bx
  117.         add eax,ebx
  118.         mov dword ptr GDT_Off[2],eax
  119.         lgdt pword ptr GDT_Off         ; charge GDT 
  120.  
  121.         mov bx,08h                     ;  bx pointe la première entrée de la table GDT
  122.         push ds
  123.         cli                            ; Désactive les interruptions
  124.         mov eax,cr0                    ; Passe en Protected mode
  125.         or eax,1
  126.         mov cr0,eax
  127.         jmp En_Protectedmode           ; Efface Executionpipe
  128. En_Protectedmode:
  129.         mov gs,bx                      ; Adapte les segments à 4 GB
  130.         mov fs,bx
  131.         mov es,bx
  132.         mov ds,bx
  133.         and al,0FEh                    ; Retour en Real-mode sans
  134.         mov cr0,eax                    ; reset du processeur
  135.         jmp En_Realmode                ; Efface Executionpipe 
  136. En_Realmode:
  137.         sti                            ; Active à nouveau les interruptions
  138.         pop ds
  139.   ret
  140. Enable_4Giga endp
  141.  
  142. code ends
  143.  
  144. END
  145.