MIPS floating point instructions Load and Store Load

  • Slides: 8
Download presentation
MIPS floating point instructions

MIPS floating point instructions

Load and Store • Load or store from a memory location (pseudoinstruction ). Just

Load and Store • Load or store from a memory location (pseudoinstruction ). Just load the 32 bits into the register. – l. s $f 0, val – s. s $f 0, val • Load immediate number (pseudoinstruction ) – li. s $f 0, 0. 5

Print and load • Print: – li $v 0, 2 – li $f 12,

Print and load • Print: – li $v 0, 2 – li $f 12, 0. 5 – syscall • Read – li $v 0, 6 – syscall – (the read will be in $f 0)

Arithmetic Instructions • • • abs. s $f 0, $f 1 add. s $f

Arithmetic Instructions • • • abs. s $f 0, $f 1 add. s $f 0, $f 1, $f 2 sub. s $f 0, $f 1, $f 2 mul. s $f 0, $f 1, $f 2 div. s $f 0, $f 1, $f 2 neg. s $f 0, $f 1

Data move • mov. s $f 0, $f 1 • mfc 1 $t 0,

Data move • mov. s $f 0, $f 1 • mfc 1 $t 0, $f 0 • mtc 1 $t 0, $f 0

Convert to integer and from integer • cvt. s. w $f 0, $f 0

Convert to integer and from integer • cvt. s. w $f 0, $f 0 # convert the 32 bit in $f 0 currently representing an integer to float of the same value • cvt. w. s $f 0, $f 0 # the reverse

Comparison instructions • c. lt. s $f 0, $f 1 #set a flag in

Comparison instructions • c. lt. s $f 0, $f 1 #set a flag in coprocessor 1 if $f 0 < $f 1, else clear it. The flag will stay until set or cleared next time • c. le. s $f 0, $f 1 #set flag if $f 0 <= $f 1, else clear it • bc 1 t L 1 # branch to L 1 if the flag is set • bc 1 f L 1 # branch to L 1 if the flag is 0 • Where does the bc 1 t instruction take place? The main processor or the coprocessor?

Computing the square root of a number n • The Newton’s method • x’=(x+n/x)/2

Computing the square root of a number n • The Newton’s method • x’=(x+n/x)/2 • The code we used in the class is: http: //www. cs. fsu. edu/~zzhang/CDA 3100_Spring_2009_files/float 2. asm