Sie sind auf Seite 1von 23

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:
From

one register to another


Between a register and a memory location
* Value is not modified as it is copied

Definition of Unsigned
Notation
Unsigned Notation: The notation does not
have a separate bit to represent the sign of
the number.

Unsigned Notation
There are two types of unsigned notation:
Non-negative notation
2. 2s complement notation
1.

Non-negative versus
2s complement
Binary Representation

Non-negative

2s Complement

0000

0001

0111

7 (2 n-1- 1)

1000

-8 (2 n-1 )

1001

-7

1111

15 (2 - 1)

-1

Addition
Can

be easily done when values fit the


limitations for non-negative or 2s
complement

A little

more complicated when it does not.

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.

Implementation of
ADD: XX+Y

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.

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.

Implementation of
SUB: X X Y

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.

People to Shift-Add
Multiplication

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)

Shift-Add Multiplication
in RTL Form
X,U,V n bit register
C 1 bit register for carry
Start initiates

U high order half


V low order half
Finish terminates

1: U0, i n
Vo 2: CU U + X
2: i i 1
3: shr(CUV)
Z3: GOTO 2
Z 3: FINISH1

1: U0, i n
3: shr(CUV)
Conditions

Vo 2: CUU + X
Z3: GOTO 2
Micro-operations

START

2: i i 1
Z 3: FINISH1
i

xxxx

1011

U0, i 4

Vo 2,2

CUU+X, ii1

3, Z3

shr(CUV), GOTO 2

Vo 2,2

CUU+X, ii 1

3, Z3

shr(CUV), GOTO 2

3, Z3

ii 1
shr(CUV), GOTO 2

Vo 2,2

CUU+X, ii 1

3, Z 3

shr(CUV), FINISH1

FINISH
0

0000

1101

0110

0011

1001

1101
0
1110
0

0100

0001

1000

1111
1
1111

Implementation of Shift-Add
Multiplication Algorithm

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.

Shift-Sub Division in RTL Form


X,Y,U,V n bit register
C 1 bit register for carry
Start initiates

U high order half


V low order half
Finish terminates
1 1: CUU+X+1
1 2: U U+X
C1 2 : FINISH 1,OVERFLOW 1
2 : Y 0,OVERLOW 0,i n
3 : shl(CUV),shl(Y),i i-1
C4 1 : U U+X+1
C41 : CU U+X+1
C4 2 : Y01
C42 : U U+X
Z 4 2:FINISH 1
Z4 2 :GOTO 3

X,Y,U,V n bit register


C 1 bit register for carry
Start initiates
Conditions

Micro-operations

START

U high order half


V low order half
Finish terminates
i

1001

0011

xxxx

1100

11

CUU+X+1

12

U U+X

Y 0,OVERFLOW 0,i 4

shl(CUV),shl(Y),i i-1

C41

U U+X+1

C42,Z42

Y0 1,GOTO 3

shl(CUV),shl(Y),i i-1

C41

CU U+X+1

C42,Z42

U U+X,GOTO 3

shl(CUV),shl(Y),i i-1

C41

U U+X+1

C42,Z42

Y0 1,GOTO 3

shl(CUV),shl(Y),i i-1

C41

U U+X+1

C42,Z42

Y0 1,FINISH1

FINISH
0

1001
1

0010

0110

0000

0000

0101
0001
2

1010

1101

1100

0010

1000

0100

1010
1

0101
1000

0101
0

0001

0000

1010

0100
1011

Implementation of shift-sub
division algorithm

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 binarycoded decimal.
Any Questions?

Das könnte Ihnen auch gefallen