Arithmetic for computers�(integer)
Lars Ailo Bongo <larsab@cs.uit.no>
inf-2200, fall 2022
12.09.22
Arithmetic for Computers
Chapter 3 — Arithmetic for Computers — 2
§3.1 Introduction
Our approach
Integer Addition
Chapter 3 — Arithmetic for Computers — 4
§3.2 Addition and Subtraction
Integer Subtraction
+7: 0000 0000 … 0000 0111�–6: 1111 1111 … 1111 1010�+1: 0000 0000 … 0000 0001
Chapter 3 — Arithmetic for Computers — 5
Overflow
How to deal with it?
Dealing with Overflow
Chapter 3 — Arithmetic for Computers — 7
ALU
Optimization
Arithmetic for Multimedia
Chapter 3 — Arithmetic for Computers — 10
Multiplication
Chapter 3 — Arithmetic for Computers — 11
1000
× 1001
1000
0000
0000
1000
1001000
Length of product is the sum of operand lengths
multiplicand
multiplier
product
§3.3 Multiplication
Multiplication Hardware
Chapter 3 — Arithmetic for Computers — 12
Initially 0
Optimized Multiplier
Chapter 3 — Arithmetic for Computers — 13
Faster Multiplier
Chapter 3 — Arithmetic for Computers — 14
MIPS Multiplication
Chapter 3 — Arithmetic for Computers — 15
Division
Chapter 3 — Arithmetic for Computers — 16
§3.4 Division
Division Hardware
Initially dividend
Initially divisor in left half
Optimized Divider
Chapter 3 — Arithmetic for Computers — 18
Faster Division
Chapter 3 — Arithmetic for Computers — 19
MIPS Division
Chapter 3 — Arithmetic for Computers — 20
Concluding Remarks
Chapter 3 — Arithmetic for Computers — 21
§3.10 Concluding Remarks
Concluding Remarks
Chapter 3 — Arithmetic for Computers — 22