Lecture_10 - ECE 445 Computer Organization Computer...

Info iconThis preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 445 – Computer Organization Computer Arithmetic (Lecture #10)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 2 Arithmetic for Computers Operations on integers - Addition and subtraction - Multiplication and division - Dealing with overflow Floating-point real numbers - Representation and operations §3.1 Introduction
Background image of page 2
ECE 445 - Computer Organization 3 Integer Addition Example: 7 + 6 §3.2 Addition and Subtraction Overflow if result out of range Adding +ve and –ve operands, no overflow Adding two +ve operands Overflow if result sign is 1 Adding two –ve operands Overflow if result sign is 0
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 4 Integer Subtraction Add negation of second operand Example: 7 – 6 = 7 + (–6) +7: 0000 0000 … 0000 0111 –6: 1111 1111 … 1111 1010 +1: 0000 0000 … 0000 0001 Overflow if result out of range - Subtracting two +ve or two –ve operands, no overflow - Subtracting +ve from –ve operand Overflow if result sign is 0 - Subtracting –ve from +ve operand Overflow if result sign is 1
Background image of page 4
ECE 445 - Computer Organization 5 Dealing with Overflow Some languages (e.g., C) ignore overflow - Use MIPS addu , addui , subu instructions Other languages (e.g., Ada, Fortran) require raising an exception - Use MIPS add , addi , sub instructions - On overflow, invoke exception handler Save PC in exception program counter (EPC) register Jump to predefined handler address mfc0 (move from coprocessor reg) instruction can retrieve EPC value, to return after corrective action
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 445 - Computer Organization 6 Multiplication Start with long-multiplication approach    1000 ×  1001    1000   0000   0000   1000    1001000 Length of product is the sum of operand lengths multiplicand multiplier product §3.3 Multiplication
Background image of page 6
ECE 445 - Computer Organization 7 Multiplication Hardware Initially 0
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/15/2010 for the course ECE 445 taught by Professor Tabak,d during the Spring '08 term at George Mason.

Page1 / 23

Lecture_10 - ECE 445 Computer Organization Computer...

This preview shows document pages 1 - 8. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online