Everything

FSEEK


Moves the file pointer to a specified position.

[Function Code (R1 Register)]

[Parameter Block (R2 Register)]

[Parameters]

Parameter

Description

Execution result (output)

0: Terminated normally

-1: Error

File number (input)

Number that is returned when a file is opened

Direction (input)

0: Offset in bytes from the beginning of a file

1: Offset in bytes from the current file pointer

2: Offset in bytes from the tail end of a file

Offset (input)

Number of bytes from the position specified by direction

[Detailed Description]

-

Moves the file pointer to a specified position.

[Example]

_fpseek:
        MOV.L       R2,R5           ; Set the value of R2 (offset) in R5.
        MOV.L       #PARM,R2        ; Set the address of the parameter block in R2.
        MOV.L       R5,4h:5[R2]     ; Set the value of R5 in R1 + 4 bytes (offset).
        MOV.B       R1,1h:5[R2]  ; Set the value of R1 (file number) in R1 + 1 bytes 
                                    ; (offset).
        MOV.B       R3,2h:5[R2]     ; Set the value of R3 (direction) in R2 + 2 bytes 
                                    ; (direction).
        MOV.L       #010C0000h,R1   ; Set the function code of FSEEK in R1.
        MOV.L       #SIM_IO,R5      ; Set the address of the system call in R5.
        JSR         R5              ; System call
        NOP
        MOV.L       #PARM,R1  ; Set the address of the parameter block in R1.
        MOV.B       [R1],R1   ; Set the first byte of R1 (result of execution) in R1.
        RTS                   ; Return to the address where the function was called.
 
         .SECTION  B,DATA,ALIGN=4
PARM:       .BLKL   2               ; Parameter block area