lecture 12 mips assembly language 5
play

lecture 12 MIPS assembly language 5 - coprocessor 1 (floating - PowerPoint PPT Presentation

lecture 12 MIPS assembly language 5 - coprocessor 1 (floating point unit FPU) - coprocessor 0 (kernel use, exception handing) February 17, 2016 lecture 12 MIPS assembly language 5 - coprocessor 1 (floating point unit FPU) -


  1. lecture 12 MIPS assembly language 5 - coprocessor 1 (floating point unit FPU) - coprocessor 0 (kernel use, exception handing) February 17, 2016

  2. lecture 12 MIPS assembly language 5 - coprocessor 1 (floating point unit FPU) - coprocessor 0 (kernel use, exception handling) February 17, 2016 Example: arithmetic overflow addi $s0, $0, 1 # $s0 = 2^0 sll $s0, $s0, 30 # $s0 = 2^30 add $t0, $s0, $s0 # $t0 = 2^31 This causes overflow because largest signed number is 2^31 - 1.

  3. addi $s0, $0, 1 # $s0 = 1 sll $s0, $s0, 30 # $s0 = 2^30 addi $s0, $s0, -1 # $s0 = 2^30 - 1 add $t0, $s0, $s0 # $t0 = 2^31 - 2 This does not cause overflow, because it is within the range allowed for signed numbers. addi $s0, $0, 1 sll $s0, $s0, 30 # $s0 = 2^30 mtc1 $s0, $f0 cvt.s.w $f0, $f0 # $f0 = 2^30 mul.s $f0, $f0, $f0 # $f0 = 2^60 mul.s $f0, $f0, $f0 # $f0 = 2^120 mul.s $f0, $f0, $f0 # $f0 = 2^240 -> overflow In fact, what happens is $f0 = +infinity (no exception)

  4. Announcements Quiz 3 on Monday ( Lastname I-P in Arts 145) It will cover lectures 8, 9, 10 (not this week's lectures) A2 is due next Sunday at midnight. A3 will be posted early next week and will be due on the last day of Reading Week (~3 weeks from now).

Recommend


More recommend