Download presentation
Presentation is loading. Please wait.
Published byIlene Williamson Modified over 9 years ago
1
Add & Subtract
2
Addition Add bit by bit from right to left Ex 5+6 or 7+3 0101 (5)0111 (7) +0110 (6)OR +0011 (3) 1011 (11)1010 (10)
3
Subtraction Take the 2s compliment of subtracting number, then add the 2 numbers 2s compliment conversion: Invert bits then add 1 Ex subtract 5 from 91001 (9) +0101 (5) -1011 (-5) 0100 (4)
4
Overflow Overflow can occur when adding two positive numbers and the sum is negative, or vice versa. (+) + (+) = (-) or (-) + (-) = (+) Subtracting positive from a negative and result is negative or negative from a positive and the result is positive (-) – (+) = (-) or (+) – (-) = (+)
5
Overflow Cont’d Add, Addi (immediate), sub – cause exceptions on overflow Addu (unsigned), addiu (immediate unsigned), subu (unsigned) – do not cause exceptions on overflow
6
ALU Addition and subtraction are both handled by the ALU ALU takes 2 inputs from “register file”, a control input from “ALU control”, and outputs to “data memory”
7
ALU Control “ALU control” determines which function for the ALU to perform “ALU control” input consists of a 2 bit “ALUop” control field + a 6 bit function field ALUop for add and subtract is the same (10) Function field – Add : 100000 – Sub : 100010
8
ALU The 4 bit result from the ALU control is sent to the ALU This 4 bit control line controls which function is performed by the ALU 4 bit control line – Add : 0010 – Sub : 0110
9
ALU First input is read from register file (yellow wire, next slide) Second input, sign extended lower 16 bits of instruction (Blue wire) ALUop+Function sent to ALU control which converts to 4 bit signal sent to ALU (green wire) Result written to data memory (Red wire)
10
Data path
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.