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.

Slides:



Advertisements
Similar presentations
Multiplication and Division
Advertisements

The MIPS 32 1)Project 1 Discussion? 1)HW 2 Discussion? 2)We want to get some feel for programming in an assembly language - MIPS 32 We want to fully understand.
Arithmetic in Computers Chapter 4 Arithmetic in Computers2 Outline Data representation integers Unsigned integers Signed integers Floating-points.
CSCE 212 Chapter 3: Arithmetic for Computers Instructor: Jason D. Bakos.
Lecture 16: Computer Arithmetic Today’s topic –Floating point numbers –IEEE 754 representations –FP arithmetic Reminder –HW 4 due Monday 1.
Division CPSC 321 Computer Architecture Andreas Klappenecker.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3: IT Students.
Integer Multiplication and DivisionICS 233 – KFUPM © Muhamed Mudawar slide 1 Multiplicand and HI are sign-extended  Sign is the sign of the result Signed.
1 Lecture 9: Floating Point Today’s topics:  Division  IEEE 754 representations  FP arithmetic Reminder: assignment 4 will be posted later today.
Chapter 3 Arithmetic for Computers. Multiplication More complicated than addition accomplished via shifting and addition More time and more area Let's.
361 div.1 Computer Architecture ECE 361 Lecture 7: ALU Design : Division.
Arithmetic IV CPSC 321 Andreas Klappenecker. Any Questions?
Computer Organization Multiplication and Division Feb 2005 Reading: Portions of these slides are derived from: Textbook figures © 1998 Morgan Kaufmann.
Solutions and Examples or $t0, $zero, $zero# i = 0 li $t1, 101# $t1 = 101 for:beq $t0, $t1, exit# if (i==101) exit add $t2, $t0, $a1 lw $s1, 0($t2)#
Integer Arithmetic Floating Point Representation Floating Point Arithmetic Topics.
1 Lecture 8: Binary Multiplication & Division Today’s topics:  Addition/Subtraction  Multiplication  Division Reminder: get started early on assignment.
COMPUTER ARCHITECTURE & OPERATIONS I Instructor: Hao Ji.
COE 308: Computer Architecture (T041) Dr. Marwan Abu-Amara Integer & Floating-Point Arithmetic (Appendix A, Computer Architecture: A Quantitative Approach,
DIGITAL SYSTEMS TCE1111 Representation and Arithmetic Operations with Signed Numbers Week 6 and 7 (Lecture 1 of 2)
Simple Data Type Representation and conversion of numbers
1 Arithmetic and Logical Operations - Part II. Unsigned Numbers Addition in unsigned numbers is the same regardless of the base. Given a pair of bit sequences.
Computer Organization and Architecture Computer Arithmetic Chapter 9.
Computer Arithmetic Nizamettin AYDIN
Computer Arithmetic. Instruction Formats Layout of bits in an instruction Includes opcode Includes (implicit or explicit) operand(s) Usually more than.
Computer Arithmetic.
Computer Architecture ALU Design : Division and Floating Point
ECE232: Hardware Organization and Design
Data Representation in Computer Systems
S. Rawat I.I.T. Kanpur. Floating-point representation IEEE numbers are stored using a kind of scientific notation. ± mantissa * 2 exponent We can represent.
Copyright 1995 by Coherence LTD., all rights reserved (Revised: Oct 97 by Rafi Lohev, Oct 99 by Yair Wiseman, Sep 04 Oren Kapah) IBM י ב מ 10-1 The ALU.
07/19/2005 Arithmetic / Logic Unit – ALU Design Presentation F CSE : Introduction to Computer Architecture Slides by Gojko Babić.
Oct. 18, 2007SYSC 2001* - Fall SYSC2001-Ch9.ppt1 See Stallings Chapter 9 Computer Arithmetic.
Fixed and Floating Point Numbers Lesson 3 Ioan Despi.
Lecture 9: Floating Point
CSC 221 Computer Organization and Assembly Language
Conversion to Larger Number of Bits Ex: Immediate Field (signed 16 bit) to 32 bit Positive numbers have implied 0’s to the left. So, put 16 bit number.
Princess Sumaya Univ. Computer Engineering Dept. Chapter 3:
Csci 136 Computer Architecture II – Multiplication and Division
Chapter 3 Arithmetic for Computers. Chapter 3 — Arithmetic for Computers — 2 Arithmetic for Computers Operations on integers Addition and subtraction.
Computer Architecture Lecture Notes Spring 2005 Dr. Michael P. Frank Competency Area 4: Computer Arithmetic.
Division Check for 0 divisor Long division approach – If divisor ≤ dividend bits 1 bit in quotient, subtract – Otherwise 0 bit in quotient, bring down.
CDA 3101 Spring 2016 Introduction to Computer Organization
Division Quotient Divisor Dividend – – Remainder.
1 ALU for Computers (MIPS) design a fast ALU for the MIPS ISA requirements ? –support the arithmetic/logic operations: add, addi addiu, sub, subu, and,
Integer Operations Computer Organization and Assembly Language: Module 5.
By Wannarat Computer System Design Lecture 3 Wannarat Suntiamorntut.
William Stallings Computer Organization and Architecture 8th Edition
Computer Architecture & Operations I
Computer Architecture & Operations I
Integer Multiplication and Division
Lecture 9: Floating Point
Morgan Kaufmann Publishers
CS/COE 0447 (term 2181) Jarrett Billingsley
Morgan Kaufmann Publishers
CDA 3101 Summer 2007 Introduction to Computer Organization
Lecture 8: Addition, Multiplication & Division
Lecture 8: Addition, Multiplication & Division
Topic 3c Integer Multiply and Divide
Microprocessor and Assembly Language
ECEG-3202 Computer Architecture and Organization
Computer Architecture
مظفر بگ محمدی دانشگاه ایلام
October 15 Chapter 4 – Multiplication/Division Go to the State Fair!
Morgan Kaufmann Publishers Arithmetic for Computers
Presentation transcript:

Lab 7

Given: Two’s complement integer A single precision floating-point number two = 88, bias = two = 1 + 1* *2 -3 = × A MIPS instruction sw$16, 0($2)

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.)

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

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

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

.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

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;

Multiplication If Multiplier is 0?

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)

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.

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 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