home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / ofilaloc.asm < prev    next >
Assembly Source File  |  1988-08-28  |  2KB  |  58 lines

  1.  
  2. ;    FILENAME: OFILALOC.ASM
  3. ;    Copyright (c) 1988 by Borland International, Inc.
  4. ;
  5. ;    Description: This module implements the routine FileAlloc. FileAlloc
  6. ;    allocates a read/write buffer.
  7. ;
  8. ;    This module uses MASM mode syntax and standard segment directives. 
  9. ;    ASSEMBLY INSTRUCTIONS: To assemble this module use the following 
  10. ;    TASM command line. 
  11. ;        TASM ofilaloc
  12.  
  13. include globals.inc
  14.  
  15. _TEXT   segment
  16.  
  17.     FileAlloc proc
  18.  
  19.     ;    Input 
  20.     ;        bx - file record offset
  21.     ;        [bx+2] - buffer size
  22.     ;    Output (of INT 21h, Function 48h)
  23.     ;        cf - set if error occurred
  24.     ;        ax - error code
  25.     ;            7 - if memory control blocks destroyed
  26.     ;            8 - if insufficient memory
  27.     ;    Registers modified 
  28.     ;        ax
  29.  
  30.     push     cx
  31.     push     dx
  32.     push     bx
  33.     mov      bx, [bx+2]          ;size in bytes
  34.     mov      cl, 4               ;paragraph shift
  35.     shr      bx, cl              ;get size in paragraphs
  36.     inc      bx                  ;round up
  37.     mov      dx, bx
  38.     shl      dx, cl              ;shift back to byte form
  39.     mov      ah, 48h             ;function
  40.     int      21h                 ;execute
  41.     pop      bx
  42.     jc       filall1
  43.     mov      [bx+2], dx          ;save size
  44.     mov      WORD PTR [bx+4], 0  ;clear data pointer
  45.     mov      [bx+6], ax          ;save segment
  46.     mov      WORD PTR [bx+10], 0 ;clear bytes in buffer
  47. filall1:
  48.     pop      dx
  49.     pop      cx
  50.     ret
  51.     FileAlloc endp
  52.  
  53. _TEXT    ends
  54.  
  55. end
  56.