home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / FM-EXT20.ZIP / MEMDUMP.MAC < prev   
Text File  |  1995-09-20  |  5KB  |  209 lines

  1. Halt MACRO
  2.         mov     ax,4c00h
  3.         int     21h
  4. ENDM
  5.  
  6. WaitForKey MACRO
  7.         mov     ah,0
  8.         int     16h
  9. ENDM
  10.  
  11.  
  12. ;-----------------------------------------------------------------------
  13. ;                    OPEN A FILE
  14. ;
  15. ; OpenFile     <Handle>,<'path\filename'>
  16. ;
  17. ; Example:      OpenFile      myfile,'c:\gif\bird.gif'
  18. ;
  19. ;-----------------------------------------------------------------------
  20. OpenFile macro X, FileName, nameOFS
  21. local skip_opfi
  22.         IFB <nameOFS>
  23.               mov edx,offset file_to_open&X    ; DS:EDX   points to file name
  24.         ELSE
  25.               mov edx,nameOFS
  26.         ENDIF
  27.         mov ax,3D02h        ; open a file function
  28.         Int 21h
  29.         mov FileHandle&X , AX
  30.         jmp  skip_opfi
  31. file_to_open&X  db FileName,0
  32. FileHandle&X    dw 0
  33. skip_opfi:
  34. endm
  35.  
  36.  
  37.  
  38. ;-----------------------------------------------------------------------
  39. ;                    CREATE A FILE
  40. ;
  41. ; Usage:       CreateFile     <Handle>,<'path\filename'>
  42. ;
  43. ; Example:      CreateFile      myfile,'drum.voc'
  44. ;
  45. ;-----------------------------------------------------------------------
  46. CreateFile macro X, FileName , nameSEG , nameOFS
  47. local skip_crfi
  48.     jmp skip_crfi
  49. file_to_open&X  db FileName,0
  50. FileHandle&X    dw 0
  51. skip_crfi:
  52.         IFB <nameOFS>
  53.               mov edx,offset file_to_open&X    ; DS:EDX   points to file name
  54.         ELSE
  55.                 mov edx,nameOFS
  56.         ENDIF
  57.         mov     ax,3C02h            ; creat a file function
  58.         xor     ecx,ecx
  59.         Int 21h
  60.         mov FileHandle&X , AX
  61. endm
  62.  
  63.  
  64.  
  65.  
  66. ;-----------------------------------------------------------------------
  67. ;                     CLOSE A FILE
  68. ; Usage:         Close    <Handel>
  69. ;
  70. ; Example:       Close     myfile
  71. ;
  72. ;-----------------------------------------------------------------------
  73. Close  macro  X
  74.         mov ah,03Eh         ; close a file function
  75.         mov BX,FileHandle&X
  76.         int 21h
  77. endm
  78.  
  79.  
  80. ;-----------------------------------------------------------------------
  81. ;                   READ BLOCK FROM A FILE
  82. ;
  83. ; Usage:       BlockRead    <handel>,<32bit offset>,<bytes to read>
  84. ;
  85. ; Example:      BlockRead   myfile, EDX ,700000
  86. ;
  87. ;-----------------------------------------------------------------------
  88. BlockRead  macro   X , POINTER, BYTE_COUNT
  89.     push    ecx
  90.     push    edx
  91.     push    eax
  92.         mov     ecx, dword ptr BYTE_COUNT
  93.         mov     edx, dword ptr POINTER
  94.         mov     BX,FileHandle&X
  95.         mov     ah,3Fh
  96.         int     21h
  97.     pop    eax
  98.     pop    edx
  99.     pop    ecx
  100. endm
  101.  
  102.  
  103. ;-----------------------------------------------------------------------
  104. ;                   WRITE A BLOCK TO A FILE
  105. ;
  106. ; Usage:     BlockWrite  <handel>,<32bit offset>,<bytes to read>
  107. ;
  108. ; Example:     BlockWrite   myfile, EDX ,700000
  109. ;
  110. ;-----------------------------------------------------------------------
  111. BlockWrite  macro  X , POINTER, BYTE_COUNT
  112.     push    ecx
  113.     push    edx
  114.     push    eax
  115.         mov     ecx, dword ptr BYTE_COUNT
  116.         mov     edx, dword ptr POINTER
  117.         mov     BX,FileHandle&X
  118.         mov     ah,40h
  119.         int     21h
  120.     pop    eax
  121.     pop    edx
  122.     pop    ecx
  123. endm
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130. ;-------------------------------------------------------------------------
  131. ;              DISPLAY A STRING ON SCREEN
  132. ;
  133. ; Usage:        Write   <' string to display '>
  134. ;
  135. ;
  136. ;-------------------------------------------------------------------------
  137. Write MACRO STRING_, COLOR5_T
  138. LOCAL TEXT5_T , skip_wrln
  139.         push  eax
  140.         push  edx
  141.         jmp skip_wrln
  142.  
  143.         IFB <STRING_>
  144. TEXT5_T DB 36
  145.         ELSE
  146. TEXT5_T DB STRING_,36
  147.         ENDIF
  148. skip_wrln:
  149.  
  150.         MOV     EDX,OFFSET TEXT5_T
  151.         mov     ah,9
  152.         int     21h
  153.         pop edx
  154.         pop eax
  155. ENDM
  156.  
  157.  
  158.  
  159. ;-------------------------------------------------------------------------
  160. ;              DISPLAY A STRING ON SCREEN WITH CARAGE RETURN
  161. ;
  162. ; Usage:       Writeln   <' string to display '>
  163. ;
  164. ;
  165. ;-------------------------------------------------------------------------
  166. Writeln MACRO STRING_
  167. LOCAL TEXT3_S
  168. local skip_wrln
  169.         push eax
  170.         push edx
  171.  
  172.         jmp skip_wrln
  173.  
  174.         IFB <STRING_>
  175. TEXT3_S DB 13,10,36
  176.         ELSE
  177. TEXT3_S DB STRING_,13,10,36
  178.         ENDIF
  179. skip_wrln:
  180.         mov     EDX,offset TEXT3_S
  181.         mov     ah,9
  182.         Int  21h
  183.         pop edx
  184.         pop eax
  185. ENDM
  186.  
  187.  
  188. ;-----------------------------------------------------------------------
  189. ;                   ALLOCATE MEMORY
  190. ;
  191. ; Usage:       AllocMem    <size>,<pointer>
  192. ;
  193. ; Example:      AllocMem    4000h, buffer
  194. ;
  195. ;-----------------------------------------------------------------------
  196.  
  197. AllocMem  macro  size, POINTER
  198.     push    edx
  199.     push    eax
  200.         mov     edx, dword ptr size
  201.         mov     ax,0EE42h
  202.         int     31h                            ; Returns EAX with actual size
  203.         mov     dword ptr size, eax             
  204.         mov     dword ptr POINTER, edx         ; EDX returns pointer to memory
  205.     pop    eax
  206.     pop    edx
  207. endm
  208.  
  209.