{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Lecture_10

# Lecture_10 - ECE 445 Computer Organization Computer...

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

ECE 445 – Computer Organization Computer Arithmetic (Lecture #10)

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

View Full Document
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
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

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

View Full Document
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
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

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

View Full Document
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
ECE 445 - Computer Organization 7 Multiplication Hardware Initially 0

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### 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
Ask a homework question - tutors are online