FGETC


Reads 1 byte of data from a file.

[Function Code (R1 Register)]

[Parameter Block (R2 Register)]

[Parameters]

Parameter

Description

Execution result (output)

0: Terminated normally

-1: EOF detected

File number (input)

Number that is returned when a file is opened

Beginning address of input buffer (input)

Beginning address of the buffer to which input data is written

[Detailed Description]

-

Reads 1 byte of data from a file.

[Example]

_fcharget:
        MOV.L       R2,R5           ; Set the value of R2 (file number) in R5.
        MOV.L       #PARM,R2        ; Set the address of the parameter block in R2.
        MOV.L       R1,4h:5[R2] ; Set the value of R1 (input buffer) in R2 + 4 bytes.
        MOV.B       R5,1h:5[R2] ; Set the value of R5 in R2 + 1 bytes (file number).
        MOV.L       #01270000h,R1   ; Set the function code of FGETC in R1.
        MOV.L       #SIM_IO,R3      ; Set the address of the system call in R3.
        JSR         R3              ; 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