
Here's an example division
using the flowchart to do Q/M where Q=10101b (21d) and M=00011b (3d)
On entry,
A=0, count=5, M=0001100000
A<<1, Q<<1 gives A=0, Q=101010
Q=Q-M gives Q=101010-1100000 which is negative
So
we set A[0]=0 and Q=Q+M=101010 again
count=4
A<<1, Q<<1 gives A=0, Q=1010100
Q=Q-M gives Q=1010100-1100000 which is negative
So
we set A[0]=0 and Q=Q+M=1010100 again
count=3
A<<1, Q<<1 gives A=0, Q=10101000
Q=Q-M gives Q=10101000-1100000 which is 1001000 (positive)
So
we set A[0]=1 (A=1)
count=2
A<<1, Q<<1 gives A=10, Q=10010000
Q=Q-M gives Q=100100000-1100000 which is 110000 (positive)
So
we set A[0]=1 (A=11)
count=1
A<<1, Q<<1 gives A=110, Q=1100000
Q=Q-M gives Q=1100000-1100000 which is 0
So
we set A[0]=1 (A=111)
count=0,
on exit, A=quotient=111b (7d) and Q=remainder=0 correct!!