Everything

FTELL


Obtains the current position of the file pointer.

[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

Offset (output)

Current position of the file pointer (Number of bytes from the top of the file)

[Detailed Description]

-

Obtains the current position of the file pointer.

[Example]

_fptell:
        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.B       R1,1h:5[R2]   ; Set the value of R1 (file number) in R2 + 1 bytes 
                                    ; (direction).
        MOV.L       #010D0000h,R1   ; Set the function code of FTELL in R1.
        MOV.L       #SIM_IO,R3      ; Set the address of the system call in R3.
        JSR         R3              ; System call
        NOP
        MOV.L       #PARM,R2        ; Set the address of the parameter block in R2.
        MOV.L       4h:5[R2],R1   ; Set the value of R2 + 4 bytes (new offset) in R1.
        MOV.L       R1,[R5]   ; Set the value of R1 in the location pointed to by R5 
                              ; (offset pointer).
        MOV.B       [R2],R1   ; Set the first byte of R2 (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