240 likes | 550 Views
Unsigned Notation. IntroductionDefinition of Unsigned NotationAdditionSubtractionMultiplicationDivision. Introduction. Most frequently preformed operation is copying data from one place to another:From one register to anotherBetween a register and a memory location* Value is not modified a
E N D
1. Computer Arithmetic: Unsigned Notation
By Sherwin Chiu
2. Unsigned Notation Introduction
Definition of Unsigned Notation
Addition
Subtraction
Multiplication
Division
3. Introduction Most frequently preformed operation is copying data from one place to another:
From one register to another
Between a register and a memory location
* Value is not modified as it is copied
4. Definition of Unsigned Notation
Unsigned Notation: The notation does not have a separate bit to represent the sign of the number.
5. Unsigned Notation
There are two types of unsigned notation:
Non-negative notation
2s complement notation
6. Non-negative versus 2s complement
7. Addition Can be easily done when values fit the limitations for non-negative or 2s complement
A little more complicated when it does not.
8. Straightforward Addition Adding numbers that fit the limitations can perform a straightforward addition of binary numbers.
When adding two numbers of different signs (+/-), a valid result will always occur.
9. Implementation of ADD: X?X+Y
10. Overflow When two numbers being added exceed the number of bits available in the register, an overflow occurs.
In non-negative, an overflow flag is notified by the carry out bit.
In 2s complement, an overflow flag is notified by both the carry in and carry out bit.
11. Subtraction
Essentially treated the same as addition, but negating one of the values. X + (-Y)
Overflow is still caused by exceeding the number of bits available in the register.
12. Implementation ofSUB: X? X Y
13. Multiplication We could multiply by adding n copies of the number together, but it would be inefficient.
It is also not how people would do multiplication.
14. People to Shift-Add Multiplication
15. Binary Multiplication
Using binary notation makes multiplication even easier by having only two possible values, 0 (X 0 = 0) or 1 (1 X 1 = 1)
16. Shift-Add Multiplication in RTL Form X,U,V n bit register U high order half
C 1 bit register for carry V low order half
Start initiates Finish terminates
1: U?0, i ?n
Vo 2: CU ?U + X
2: i ?i 1
3: shr(CUV)
Z3: GOTO 2
Z 3: FINISH?1
17. 1: U?0, i ?n Vo 2: CU?U + X 2: i ?i 13: shr(CUV) Z3: GOTO 2 Z 3: FINISH?1
18. Implementation of Shift-Add Multiplication Algorithm
19. Division Can be done with the same idea of repeated additions like multiplication, but instead for division, it is repeated subtractions.
Shifting is also applicable in the same way as multiplication, just shifting left and subtracting instead.
20. Shift-Sub Division in RTL Form X,Y,U,V n bit register U high order half
C 1 bit register for carry V low order half
Start initiates Finish terminates
1 : CU?U+X+1
1 : U ?U+X
C1 : FINISH ?1,OVERFLOW ?1
2 : Y ?0,OVERLOW ?0,i ?n
3 : shl(CUV),shl(Y),i ?i-1
C4 : U ?U+X+1
C4 : CU ?U+X+1
C4 : Y ?1
C4 : U ?U+X
Z 4 :FINISH ?1
Z4 :GOTO 3
21. X,Y,U,V n bit register U high order halfC 1 bit register for carry V low order halfStart initiates Finish terminates
22. Implementation of shift-sub division algorithm
23. Conclusion Basic arithmetic functions are a lot more complicated than what it seems.
These implementations are only for unsigned notation.
There still exist signed notation and binary-coded decimal.
Any Questions?