home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn42h.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  1.8 KB  |  35 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;           Function 42H: Move File Pointer                  ;
  4.         ;                                                            ;
  5.         ;           long seek(handle,distance,mode)                  ;
  6.         ;                int handle,mode;                            ;
  7.         ;                long distance;                              ;
  8.         ;                                                            ;
  9.         ;           Modes:                                           ;
  10.         ;                   0: from beginning of file                ;
  11.         ;                   1: from the current position             ;
  12.         ;                   2: from the end of the file              ;
  13.         ;                                                            ;
  14.         ;           Returns -1 if there was a seek error,            ;
  15.         ;           otherwise returns long pointer position.         ;
  16.         ;                                                            ;
  17.         ;************************************************************;
  18.  
  19. cProc   seek,PUBLIC
  20. parmW   handle
  21. parmD   distance
  22. parmB   mode
  23. cBegin
  24.         mov     bx,handle       ; Get handle.
  25.         les     dx,distance     ; Get distance into ES:DX.
  26.         mov     cx,es           ; Put high word of distance into CX.
  27.         mov     al,mode         ; Get move method code.
  28.         mov     ah,42h          ; Set function code.
  29.         int     21h             ; Ask MS-DOS to move file pointer.
  30.         jnb     sk_ok           ; Branch if seek successful.
  31.         mov     ax,-1           ; Else return -1.
  32.         cwd
  33. sk_ok:
  34. cEnd
  35.