home *** CD-ROM | disk | FTP | other *** search
/ The Equalizer BBS / equalizer-bbs-collection_2004.zip / equalizer-bbs-collection / DEMOSCENE-STUFF / IMPHOB10.ZIP / IMP10_EX.ZIP / W_GEMMIS.ZIP / EXAMPLE.ASM next >
Assembly Source File  |  1995-05-15  |  4KB  |  159 lines

  1. ;║ A FLAT REAL MODE INITIALIZER EXAMPLE
  2. ;║ ────────────────────────────────────
  3. ;║
  4. ;║ Compliant with RAW, XMS or EMS environments
  5. ;║
  6. ;║ Documentation used :
  7. ;║ microsoft eXtended Memory Specification (XMS) ver 3.0
  8. ;║ lotus/intel/microsoft Expanded Memory Specification (EMS) ver 4.0
  9. ;║ microsoft undocumented Global EMM Import Specification (GEMMIS) ver 1.11
  10. ;║
  11. ;║ Documentation needed :
  12. ;║ standard method for detecting drivers which use the VDISK allocation scheme
  13. ;║   (this is an official publication by microsoft but I don't have it)
  14. ;║
  15. ;║ (c) Walken / IMPACT Studios in 1995 - for publication in Imphobia #10
  16. ;╚════════════════════════════════════════════════════════════════════════════
  17.  
  18. ;│ Legal stuff :
  19. ;│ This document can be copyed only when unmodified and in its entirety.
  20. ;│ Commercial use - including commercial distribution or use in commercial
  21. ;│   software - is strictly prohibited without the written permission
  22. ;│   of the author.
  23. ;│ The author excludes any and all implied warranties, including warranties
  24. ;│   of merchantability and fitness for a particular purpose. The author
  25. ;│   should have no liability for special, incidental, or consequential
  26. ;│   damages arising out or resulting from the use or modification of this
  27. ;│   source code.
  28. ;└────────────────────────────────────────────────────────────────────────────
  29.  
  30. ;║ You can contact the author at the following address :
  31. ;║ Walken / IMPACT Studios
  32. ;║ Michel LESPINASSE - 18 rue Jean Giono - 80090 Amiens - FRANCE
  33. ;╚════════════════════════════════════════════════════════════════════════════
  34.  
  35. .model tiny
  36.     .stack 200h
  37. locals
  38. o equ offset            ;hello ervin ! greetings....
  39. b equ byte ptr
  40. w equ word ptr
  41. d equ dword ptr
  42. f equ fword ptr
  43. include load_m32.inc
  44. include mem32imp.inc
  45.  
  46.     .data
  47. okay db "all right$"
  48. show_nb_mem db "number of allocated blocks : $"
  49. show_total_mem db " total allocated bytes : $"
  50.  
  51.     .code
  52.     .486p
  53.  
  54. debut:
  55.  
  56.     ;*********************;
  57.     ;* main example code *;
  58.     ;*********************;
  59.  
  60.     call mem32_init    ;INIT MEM32 MANAGER
  61.  
  62.     cmp native_V86,0
  63.     jz no_gemmis
  64. include gemmis.inc        ;dump GEMMIS information (just for the example)
  65. no_gemmis:
  66.  
  67.     call mem32_native    ;SWITCH TO NATIVE MODE (faster interrupts)
  68.  
  69.                     ;DISPLAY MEMORY ALLOCATION INFORMATION
  70.     mov dx,o show_nb_mem
  71.     call dump_msg
  72.     mov ax,nb_available_memory
  73.     xor ecx,ecx
  74.     mov cx,ax
  75.     call dump_word        ;display number of separate allocated memory blocks
  76.     mov dx,o show_total_mem
  77.     call dump_msg
  78.     xor eax,eax
  79.     jcxz total_free_memory_done
  80. total_free_memory:
  81.     add eax,available_memory_table[ecx*8-4]
  82.     sub eax,available_memory_table[ecx*8-8]
  83.     loop total_free_memory
  84. total_free_memory_done:
  85.     call dump_dword    ;display total amount of allocated memory
  86.     call dump_line
  87.  
  88.                     ;DISPLAY MEMORY MANAGER NAME
  89.     mov dx,o memory_manager_name
  90.     mov ah,9
  91.     int 21h            ;display memory manager name
  92.     call dump_line
  93.  
  94.     call mem32_flatreal    ;SWITCH BACK TO FLAT REAL MODE (but slow interrupts)
  95.  
  96.     mov dx,o okay
  97.     jmp exit            ;EXIT WITH MESSAGE
  98.  
  99.     ;*****************************;
  100.     ;* example display functions *;
  101.     ;*****************************;
  102.  
  103. hexa db '0123456789ABCDEF'
  104. dump_dword:
  105.     ror eax,16
  106.     call dump_word
  107.     rol eax,16
  108. dump_word:
  109.     ror ax,8
  110.     call dump_byte
  111.     rol ax,8
  112. dump_byte:
  113.     ror al,4
  114.     call dump_digit
  115.     rol al,4
  116. dump_digit:
  117.     push eax
  118.     push dx
  119.     movzx eax,al
  120.     and al,0fh
  121.     mov dl,hexa[eax]
  122.     mov ah,2
  123.     int 21h
  124.     pop dx
  125.     pop eax
  126.     ret
  127. dump_space:
  128.     push ax
  129.     push dx
  130.     mov ah,2
  131.     mov dl,32
  132.     int 21h
  133.     pop dx
  134.     pop ax
  135.     ret
  136. dump_msg:
  137.     push ax
  138.     mov ah,9
  139.     int 21h
  140.     pop ax
  141.     ret
  142. dump_line:
  143.     push ax
  144.     push dx
  145.     mov ah,2
  146.     mov dl,13
  147.     int 21h
  148.     mov dl,10
  149.     int 21h
  150.     pop dx
  151.     pop ax
  152.     ret
  153. dump_msg_line:
  154.     call dump_msg
  155.     call dump_line
  156.     ret
  157.  
  158. end debut
  159.