Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab 7. Given: 1010 1100 0101 0000 0000 0000 0000 0000 Two’s complement integer -2 31 + 2 29 + 2 27 + 2 26 + 2 22 + 2 20 A single precision floating-point.

Similar presentations


Presentation on theme: "Lab 7. Given: 1010 1100 0101 0000 0000 0000 0000 0000 Two’s complement integer -2 31 + 2 29 + 2 27 + 2 26 + 2 22 + 2 20 A single precision floating-point."— Presentation transcript:

1 Lab 7

2 Given: 1010 1100 0101 0000 0000 0000 0000 0000 Two’s complement integer -2 31 + 2 29 + 2 27 + 2 26 + 2 22 + 2 20 A single precision floating-point number 010 1100 0 two = 88, bias = 127 1.101 two = 1 + 1*2 -1 +1*2 -3 = 1.625 -1.625 × 2 88-127 A MIPS instruction sw$16, 0($2)

3 To add slt to 32-bit ALU that support OR, AND, addition 1. Expand the multiplexor of each bit of the ALU by adding one more input (called LESS line, denoted by LESS0, LESS1, … LESS31) – to output 0 for all the 31 higher bits and 0/1 for the least significant bit. 2. Hard wire the LESS lines of all the 31 higher bits of the ALU to 0 3. Connect SUM31 to LESS0. (Set the control of the ALU to 0111.)

4 Given: 8-bit floating-point format - mimic IEEE 75 Sign Exp Significand Bias = 3 –2.75 = = 4.75 Smallest non-zero number = 0.015625 s3bits4bits 11000110 01010011 00000001

5 Proj 2 Input 2 integer number. Input operation +, -, /, *. Print out the calculated result. –Shouldn’t use mul*, div*.

6 System Calls (Reminder) ServiceSystem call codeArgumentsResult print_int1$a0 = integer print_float2$f12 = float print_double3$f12 = double print_string4$a0 = string read_int5integer (in $v0) read_float6float (in $f0) read_double7double (in $f0) read_string8$a0=buffer,$a1=len sbrk9$a0 = amountaddress (in $v0) exit10

7 .text.globl main main: # $s0 = the first integer # $s1 = the second integer # $s2 = the operation # Print out $s0 $s2 $s1 = li $v0, 10 syscall.data input_str1:.asciiz “Please enter the first operand:” input_str2:.asciiz “Please enter the second operand:” op_str:.asciiz “Please enter the operation (+, -, /, *):” op:.space 3

8 Multiplication slt $s4, $s0, 0 if ( $s4 == 1) $s0 = $zero - $s0; slt $s5, $s1, 0 if ( $s5 == 1) $s1 = $zero - $s1; $s3 = $s0 * $s1 $t0 = $s4 + $s5 if($t0 == 1) $s3 = $zero - $s3;

9 Multiplication If Multiplier is 0?

10 Multiplication Check if the least significant bit is 1 –and $t0, $t1, 1 $s3 = 0;// $s3 will store the result do{ if($s1 == 0) break; and $t0, $s1, 1 if ( $t0 == 1) $s3 = $s3 + $s0; $s0 = $s0 << 1 $s1 = $s1 >> 1 }while (true)

11 Division slt $s4, $s0, 0 if ( $s4 == 1) $s0 = $zero - $s0; slt $s5, $s0, 0 if ( $s5 == 1) $s1 = $zero - $s1; $s3 = $s0 / $s1 $t0 = $s4 + $s5 if($t0 == 1) $s3 = $zero - $s3; If divisor == 0, return error message.

12 Division 2b. Restore the original value by adding the Divisor register to the Remainder register, & place the sum in the Remainder register. Also shift the Quotient register to the left, setting the new least significant bit to 0. Test Remainder Remainder < 0 Remainder  0 1. Subtract the Divisor register from the Remainder register, and place the result in the Remainder register. 2a. Shift the Quotient register to the left setting the new rightmost bit to 1. 3. Shift the Divisor register right 1 bit. Done Yes: 33 repetitions Start: Place Dividend in Remainder 33 repetition? No: < 33 repetitions Divisor Dividend Divisor register Remainder register


Download ppt "Lab 7. Given: 1010 1100 0101 0000 0000 0000 0000 0000 Two’s complement integer -2 31 + 2 29 + 2 27 + 2 26 + 2 22 + 2 20 A single precision floating-point."

Similar presentations


Ads by Google