Unformatted text preview:

CS/COE0447 Computer Organization & Assembly LanguageFloating Point Instructions in MIPSAnother ExampleSlide 4Guard and Round bitsExample (in decimal) With Guard and Round bitsExample (in decimal) Without Guard and Round bits1CS/COE0447Computer Organization & Assembly LanguageChapter 3 Part 32Floating Point Instructions in MIPS.datanums: .float 0.75,15.25,7.625 .text la $t0,nums lwc1 $f0,0($t0) lwc1 $f1,4($t0) add.s $f2,$f0,$f1 #0.75 + 15.25 = 16.0 = 10000 binary = 1.0 * 2^4 #f2: 0 10000011 000000... = 0x41800000 swc1 $f2,12($t0) #1001000c now contains that number# Click on coproc1 in Mars to see the $f registers3Another Example.data nums: .float 0.75,15.25,7.625 .text loop: la $t0,nums lwc1 $f0,0($t0) lwc1 $f1,4($t0) c.eq.s $f0,$f1 # cond = 0 bc1t label # no branch c.lt.s $f0,$f1 # cond = 1 bc1t label # does branch add.s $f3,$f0,$f1label: add.s $f2,$f0,$f1 c.eq.s $f2,$f0 bc1f loop # branch (infinite loop) #bottom of the coproc1 display shows condition bits4nums: .double 0.75,15.25,7.625,0.75#0.75 = .11-bin. exponent is -1 (1022 biased). significand is 1000...#0 01111111110 1000... = 0x3fe8000000000000la $t0,numslwc1 $f0,0($t0) lwc1 $f1,4($t0) lwc1 $f2,8($t0) lwc1 $f3,12($t0) add.d $f4,$f0,$f2 #{$f5,$f4} = {$f1,$f0} + {$f2,$f1}; 0.75 + 15.25 = 16 = 1.0-bin * 2^4#0 10000000011 0000... = 0x4030000000000000# value+0 value+4 value+8 value+c# 0x00000000 0x3fe80000 0x00000000 0x402e8000# float double# $f0 0x00000000 0x3fe8000000000000# $f1 0x3fe80000# $f2 0x00000000 0x402e800000000000# $f3 0x402e8000# $f4 0x00000000 0x4030000000000000# $f5 0x403000005Guard and Round bits•To round accurately, hardware needs extra bits•IEEE 274 keeps extra bits on the right during intermediate additions–guard and round bits6Example (in decimal)With Guard and Round bits•2.56 * 10^0 + 2.34 * 10^2•Assume 3 significant digits•0.0256 * 10^2 + 2.34 * 10^2•2.3656 [guard=5; round=6]•Round step 1: 2.366•Round step 2: 2.377Example (in decimal)Without Guard and Round bits•2.56 * 10^0 + 2.34 * 10^2•0.0256 * 10^2 + 2.34 * 10^2•But with 3 sig digits and no extra bits:–0.02 + 2.34 = 2.36•So, we are off by 1 in the last


View Full Document

Pitt CS 0447 - LECTURE NOTES

Download LECTURE NOTES
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view LECTURE NOTES and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view LECTURE NOTES 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?