1 / 23

# Computer Arithmetic:

Computer Arithmetic:. Unsigned Notation By Sherwin Chiu. Unsigned Notation. Introduction Definition of Unsigned Notation Addition Subtraction Multiplication Division. Introduction. Most frequently preformed operation is copying data from one place to another:

Télécharger la présentation

## Computer Arithmetic:

E N D

### Presentation Transcript

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 • 2’s complement notation

6. Addition • Can be easily done when values fit the limitations for non-negative or 2’s complement • A little more complicated when it does not.

7. 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. 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 2’s complement, an overflow flag is notified by both the carry in and carry out bit.

10. 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.

11. Implementation ofSUB: X X – Y

12. 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. 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)

15. 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) Z’3: GOTO 2 Z 3: FINISH1

16. 1: U0, i n Vo 2: CUU + X 2: i i – 13: shr(CUV) Z’3: GOTO 2 Z 3: FINISH1

17. Implementation of Shift-Add Multiplication Algorithm

18. 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.

19. 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 C’4 : CU U+X’+1 C4 : Y 1 C’4 : U U+X Z 4 :FINISH 1 Z’4 :GOTO 3 1 2 2 1 1 0 2 2 2 2

20. X,Y,U,V – n bit register U – high order halfC – 1 bit register for carry V – low order halfStart – initiates Finish – terminates i

21. Implementation of shift-sub division algorithm

22. 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?

More Related