40 likes | 235 Vues
TAL 2. Input/Output in TAL. In TAL, the input and output are responsibilities of the operating system. TAL uses the instruction syscall to request the operating system to perform a specified task.
E N D
Input/Output in TAL • In TAL, the input and output are responsibilities of the operating system. TAL uses the instruction syscall to request the operating system to perform a specified task. • The parameters that are needed to execute the system calls are passed via registers. Register $2 contains the function to be performed. • The arguments must in the correct registers when the system calls are executed. • The results of the system calls are placed in the specified registers.
function $2 value arguments results print_int 1 $4=integer print_string 4 $4=string read_int 5 $2=integer read_string 8 $4=buffer, $5=length exit 10 print_char 11 $4=ascii read_char 12 $2=ascii Using syscall $v0 = $2 $a1 = $5 $v1 = $3 $a2 = $6 $a0 = $4 $a3 = $7 Register names and their equivalent register numbers
Syscall examples MAL TAL addi $2,$0,11 add $4,$12,$0 syscall putc $12 done addi $2,$0,10 syscall li $v0,4 lui $a0,highadd ori $a0,lowadd syscall puts msg0 la $a0,msg0 These address are determined by the assembler