Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Assembly Language - <b>function 42h (66) move file pointer (lseek)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Function 42h (66)        Move File Pointer (LSEEK)

    Move the file-pointer the specified number of bytes from the
    beginning, end, or current location, as determined by the mode code in
    AL.

       On entry:      AH         42h
                      BX         File handle
                      CX:DX      Offset, in bytes (signed 32-bit integer)
                      AL         Mode code (see below)

       Mode Code:     AL         Action
                      0          Move pointer CX:DX bytes from beginning of
                                 file
                      1          Move pointer CX:DX bytes from current
                                 location
                      2          Move pointer CX:DX bytes from end of file

       Returns:       DX:AX      New pointer location (signed 32-bit integer),
                      or AX      Error code, if CF is set

       Error codes:   1          Invalid mode code
                      6          Invalid handle

                      Call Function 59h for extended error code information
                      (DOS 3.0 and above).

  --------------------------------------------------------------------------

    This function changes the logical read/write position in the specified
    file, by incrementing or decrementing the value assigned to the file
    pointer. The offset to add to the file pointer is given as a signed
    32-bit integer in the CX:DX register pair--the more significant
    portion of the offset in CX. A mode code, specified in AL, indicates
    whether the offset specified in CX:DX is referenced to the beginning
    of the file (mode 0), the pointer's current location (mode 1), or the
    end of the file (mode 2).

       Notes:         No matter what mode is specified in AL, a positive
                      offset value in CX:DX always increases the value of
                      the file pointer. Note that using mode 2 with a
                      positive value in CX:DX will therefore move the file
                      pointer beyond the end of the file.

                      Use a mode code of 2 with an offset of 0 to move the
                      file pointer to the end of the file, or to find the
                      length of the file.

                      It is possible to move the pointer to a location
                      before the beginning of the file or after the end of
                      the file. Moving the pointer to a position before
                      the start of the file will not generate an error,
                      but the next read or write operation will fail.

                      A file can be extended by moving the file pointer
                      past the end of the file and writing one or more
                      bytes of data.

                      A file can be truncated my moving the file pointer
                      to the new end of file and writing zero bytes using
                      function 40h.

See Also: 40h 59h

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson