home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 23 / IOPROG_23.ISO / SOFT / NFSRC305.ZIP / CPMI / RESIZDOS.ASM < prev    next >
Encoding:
Assembly Source File  |  1995-05-01  |  2.0 KB  |  74 lines

  1. ; File......: RESIZDOS.ASM
  2. ; Author....: Ted Means
  3. ; CIS ID....: 73067,3332
  4. ;
  5. ; This is an original work by Ted Means and is placed in the
  6. ; public domain.
  7. ;
  8. ; Modification history:
  9. ; ---------------------
  10. ;     Rev 1.0   01 Jan 1995 03:01:00   TED
  11. ;  Initial release
  12. ;
  13. ;
  14.  
  15. ;  $DOC$
  16. ;  $FUNCNAME$
  17. ;     cpmiResizeDOSMem()
  18. ;  $CATEGORY$
  19. ;     CPMI
  20. ;  $ONELINER$
  21. ;     Resize a DOS memory block allocated with cpmiAllocDOSMem()
  22. ;  $SYNTAX$
  23. ;     int pascal cpmiAllocDOSMem( SELECTOR selector, unsigned int Size )
  24. ;  $ARGUMENTS$
  25. ;     selector identifies the DOS memory block.
  26. ;
  27. ;     size is the new size in bytes.
  28. ;  $RETURNS$
  29. ;     SUCCEED if successful, FAIL otherwise.
  30. ;  $DESCRIPTION$
  31. ;     This function is useful for resizing buffers that reside in the
  32. ;     lower 640K; e.g. for DOS interrupts.
  33. ;  $EXAMPLES$
  34. ;     char far * buffer;
  35. ;
  36. ;     FP_SEG( buffer ) = cpmiAllocDOSMem( 48 );
  37. ;     FP_OFF( buffer ) = 0;
  38. ;
  39. ;     // Do whatever
  40. ;
  41. ;     cpmiResizeDOSMem( FP_SEG( buffer ), 128 );
  42. ;  $INCLUDE$
  43. ;     CPMI.H
  44. ;  $SEEALSO$
  45. ;     cpmiAllocDOSMem(), cpmiFreeDOSMem()
  46. ;  $END$
  47. ;
  48.  
  49. IDEAL
  50. P286
  51.  
  52. Public    cpmiResizeDOSMem
  53.  
  54. Segment   _NanFor   Word      Public    "CODE"
  55.           Assume    CS:_NanFor
  56.  
  57. Proc      cpmiResizeDOSMem    Far
  58.  
  59.           Enter     0,0                           ; Create stack frame
  60.  
  61.           Mov       AX,102h                       ; DPMI -- resize DOS memory
  62.           Mov       BX,[Word Ptr BP + 6]          ; Get size in bytes
  63.           Add       BX,15                         ; Round up if necessary
  64.           SHR       BX,4                          ; Convert to paragraphs
  65.           Mov       DX,[Word Ptr BP + 8]          ; Get selector
  66.           Int       31h                           ; Call DPMI
  67.           Mov       AX,1                          ; Default to SUCCEED
  68.           SBB       AX,0                          ; Set to FAIL on error
  69.  
  70.           Leave                                   ; Destroy stack frame
  71.           RetF      4
  72. Endp      cpmiResizeDOSMem
  73. Ends      _NanFor
  74. End