[slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

4
START Sign Check If ( A > 0 ) If ( B > 0 ) If ( A < 0 ) If ( B < 0 ) CH = 0 CL = 1 CH = 1 CL = 0 PUSH CX The first bit of A and B is set to 0 as if they were positive number Original values are restored at the end

description

Our old algorithm strikes again, this time the original flow chart describing the high level procedure was found in a remote folder, and it is published for your pleasure. By Vittorio Giovara and Alberto Grand

Transcript of [slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

Page 1: [slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

START

Sign Check

If ( A > 0 ) If ( B > 0 )

If ( A < 0 ) If ( B < 0 )

CH = 0

CL = 1CH = 1

CL = 0

PUSH CX

The first bit of A and B is set to 0as if they were positive number

Original values are restoredat the end

Page 2: [slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

15th bit check

To reduce the number ofiterations we round the number

up by adding 1 to the MSB of thenumber (if this doesn't cause

overflow)

Estimation of Results

Using the invariance propertywe compute an estimated result

A* = TMP_low*B_low + + (TMP_low*B_high + TMP_high*B_low)*2^16 +

+ TMP_high*B_high*2^32

Then we calculate A* by multiplying theobtained value with the second operand

Page 3: [slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

A > A*

S = A - A*A = A* - B

S < BA* = A* + B

END

YN

Y

N

A = A* ENDY

N

R = S

Page 4: [slides] Microprocessor-Based Systems - 48/32-bit division algorithm - flow chart

Restoration

Finally we restore the sign of theoperands by popping CX andwe make final controls on the

residual