Chapter 03
Chapter 03
5th
Edition
The Hardware/Software Interface
Chapter 3
Arithmetic for Computers
§3.1 Introduction
Arithmetic for Computers
! Operations on integers
! Addition and subtraction
! Multiplication and division
! Dealing with overflow
! Floating-point real numbers
! Representation and operations
Length of product is
the sum of operand
lengths
Initially 0
! Can be pipelined
! Several multiplication performed in parallel
Chapter 3 — Arithmetic for Computers — 12
MIPS Multiplication
! Two 32-bit registers for product
! HI: most-significant 32 bits
! LO: least-significant 32-bits
! Instructions
! mult rs, rt / multu rs, rt
! 64-bit product in HI/LO
! mfhi rd / mflo rd
! Move from HI/LO to rd
! Can test HI value to see if product overflows 32 bits
! mul rd, rs, rt
! Least-significant 32 bits of product –> rd
Initially dividend
Two representations
of 0.0!
Step 1
Step 2
Step 3
Step 4
! Optional variations
! I: integer operand
! P: pop operand from stack
! R: reverse operand order
! But not all combinations allowed