home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 256_01 / lockfil.a < prev    next >
Encoding:
Text File  |  1988-01-08  |  2.3 KB  |  58 lines

  1. ;---------------------------------------------------------------------
  2. ;    ASM88 FILE:     LOCKFIL.A     Lock the File
  3. ;    ----------
  4. ;    WRITTEN:        25/10/87
  5. ;    -------
  6. ;    PURPOSE:        This is one of a series of files which take
  7. ;    -------         advantage of INT 21H functions under MS-DOS.
  8. ;                    In each case the error situation is marked by
  9. ;                    the carry flag being set.   We use the De Smet
  10. ;                    external variable '_carryf' to see whether the
  11. ;                    carry is set on return from the function.
  12. ;                    If so, the error code can be used to obtain
  13. ;                    information about the specific error.
  14. ;
  15. ;    USAGE:          int LOCKFIL(handle, offset, length, &_carryf)
  16. ;    -----           int handle;
  17. ;                    long offset, /* offset to specified region to lock */
  18. ;                         length; /* length of section to lock */
  19. ;                    char *_carryf;
  20. ;
  21. ;    DEPENDENCIES:           De Smet C V 2.44+
  22. ;    ------------
  23. ;    Copyright 1987 - Cogar Computer Services Pty. Ltd
  24. ;---------------------------------------------------------------------
  25.  
  26. CSEG
  27. PUBLIC LOCKFIL_
  28.  
  29. LOCKFIL_:
  30.     push    bp    ; normal De Smet C start
  31.     mov    bp,sp    ; point to the stack
  32.     mov    ax,ds    ; and make ES common with DS
  33.     mov    es,ax
  34. ;----------------------------------------------------------------------
  35. ;  The unique programme follows.
  36. ;----------------------------------------------------------------------
  37.     mov    bx,[bp+4]    ; the file handle
  38.     mov    cx,[bp+6]    ; low word of offset
  39.     mov    dx,[bp+8]    ; high word of offset
  40.     mov    si,[bp+10]    ; low word of length
  41.     mov    di,[bp+12]    ; high word of length
  42.     mov    al,0
  43.     mov    ah,5ch    ; the Function No.
  44.     int    21h
  45.     jc    LOCKFIL_ERROR
  46.     xor    ax,ax    ; prepare for normal return
  47.     jmp    LOCKFIL_QUIT
  48. LOCKFIL_ERROR:
  49.     mov    si,[bp+14]    ; get address of '_carryf' variable
  50.     mov    byte [si],1    ; return with _carryf = 1
  51. ;----------------------------------------------------------------------
  52. ;  Normal programme termination.
  53. ;----------------------------------------------------------------------
  54. LOCKFIL_QUIT:
  55.     pop    bp    ; restore starting conditions
  56.     ret
  57. ;----------------------------------------------------------------------
  58.