home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctchnqs / 1991 / number2 / grab.asm < prev    next >
Assembly Source File  |  1991-05-06  |  1KB  |  53 lines

  1. ideal
  2. proc setfile   far
  3.  
  4. ; DX:AX contains the size to set to.  BX contains the file 
  5. ; handle to set. All registers are returned unchanged--only
  6. ; the flags are modified. If an error occurs, the carry flag 
  7. ; will be set.  Possible errors are "invalid handle" and
  8. ; "insuffficient disk space".  The file size will be unchanged
  9. ; on error. If successful, file pointer is positioned at the 
  10. ; end of the file (EOF=TRUE).
  11.  
  12.      push cx
  13.      push dx
  14.      push ax
  15.      mov  cx,dx
  16.      mov  dx,ax
  17.      mov  ax,04200h
  18.      int  021h      ;Move to the correct position
  19.      jc   @@err1
  20.      mov  ah,040h
  21.      xor  cx,cx
  22.      int  021h      ;Set the file size
  23.      jc   @@err1
  24.      mov  ax,04202h
  25.      mov  dx,cx
  26.      int  021h      ;Get the actually size to see 
  27.                     ;if everything was written    
  28.      jc   @@err1
  29.      pop  cx
  30.      cmp  ax,cx     ;Check the low  word
  31.      je   @@cont
  32.      mov  ax,cx
  33.      stc            ;Set error condition
  34.      jmp  @@err2
  35. @@cont:
  36.      pop  cx
  37.      or   dx,cx     ;Check the high word (and clear 
  38.                     ;the carry flag)    
  39. jz   @@done
  40.      mov  dx,cx
  41.      stc            ;Set the error condition
  42.      db   0b9h      ;Jump to @@done without emptying prefetch
  43.                     ;(trashes CX) 
  44. @@err1:
  45.      pop  ax
  46. @@err2:
  47.      pop  dx
  48. @@done:
  49.      pop  cx
  50.      retf
  51. endp set_file
  52.  
  53.