0% found this document useful (0 votes)
11 views6 pages

Binary Arithmetic Strategy Guide

1. The document describes an algorithm for long division using a reverse machine. 2. It involves repeatedly shifting, copying, adding, and subtracting the dividend and divisor until the remainder is isolated. 3. The key steps are shifting the dividend and divisor, adding or subtracting portions, and copying/shifting the results to continue the division process until the remainder is obtained.

Uploaded by

11sarmientojm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views6 pages

Binary Arithmetic Strategy Guide

1. The document describes an algorithm for long division using a reverse machine. 2. It involves repeatedly shifting, copying, adding, and subtracting the dividend and divisor until the remainder is isolated. 3. The key steps are shifting the dividend and divisor, adding or subtracting portions, and copying/shifting the results to continue the division process until the remainder is obtained.

Uploaded by

11sarmientojm
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Strategy

1 Mark 2 B's for each A's and


C's.
2 Check if all symbols are
marked at the end.
Strategy
1 Go to rightmost, until #.
2 Scan left, if 1, output 1
3 If you scan a zero, replace with
two zeroes, until you
encounter a #.
do "reverse" machine
1 shR 1 #1111#
2 const 1 #1111#1#
3 shR 1 #1111#1# (2nd iteration)
4 copy 1 #1111#1#1# #1111#11#11#
5 copy 2 #1111#1#1#1# #1111#11#11#11#
6 shL 2 #1111#1#1#1# #1111#11#11#11#
7 mult #1111#1#1# #1111#11#1111#
8 shR 1 #1111#1#1# #1111#11#1111#
9 copy 3 #1111#1#1#1111# #1111#11#1111#1111#
10 shL 2 #1111#1#1#1111# #1111#11#1111#1111#
11 ifEQL(17) #1111#1## #1111#11##
12 const 1 #1111#1#1#
13 shL 1 #1111#1#1#
14 add #1111#11#
15 shR 1 #1111#11#
16 goto(4) #1111#11#
17 shL 1 #1111#11##
18 move 1,1 #11##
#dividend#divisor#counter
(1st input) (2nd input - 1st iteration)
#111#11# #111111111#11#
1 shR 3 #111#11# # #111111111#11# # (2nd iteration) (3rd iteration) (4th iteration)
2 const 1 #111#11# #1# #111111111#11# #1# #1111111#11#1#1# #11111#11#11#1# #111#11#111#1#
3 shL 1 #111#11# #1# #111111111#11# #1# #1111111#11#1#1# #11111#11#11#1# #111#11#111#1#
4 add #111#11#1# #111111111#11#1# #1111111#11#11# #11111#11#111# #111#11#1111#
5 shR 1 #111#11#1# #111111111#11#1# #1111111#11#11# #11111#11#111# #111#11#1111#
6 copy 3 #111#11#1#111# #111111111#11#1#111111111# #1111111#11#11#1111111# #11111#11#111#11111# #111#11#1111#111#
7 copy 3 #111#11#1#111#11# #111111111#11#1#111111111#11# #1111111#11#11#1111111#11# #11111#11#111#11111#11# #111#11#1111#111#11#
8 shL 2 #111#11#1#111#11# #111111111#11#1#111111111#11# #1111111#11#11#1111111#11# #11111#11#111#11111#11# #111#11#1111#111#11#
9 monus #111#11#1#1# #111111111#11#1#1111111# #1111111#11#11#11111# #11111#11#111#111# #111#11#1111#1#
10 shR 1 #111#11#1#1# #111111111#11#1#1111111# #1111111#11#11#11111# #11111#11#111#111# #111#11#1111#1#
11 copy 3 #111#11#1#1#11# #111111111#11#1#1111111#11# #1111111#11#11#11111#11# #11111#11#111#111#11# #111#11#1111#1#11#
12 copy 3 #111#11#1#1#11#1# #111111111#11#1#1111111#11#1# #1111111#11#11#11111#11#11# #11111#11#111#111#11#111# #111#11#1111#1#11#1111#
13 shL 3 #111#11#1#1#11#1# #111111111#11#1#1111111#11#1# #1111111#11#11#11111#11#11# #11111#11#111#111#11#111# #111#11#1111#1#11#1111#
14 move 3,3 #1#11#1# #1111111#11#1# #11111#11#11# #111#11#111# #1#11#1111#
15 shR 3 #1#11#1# #1111111#11#1# #11111#11#11# #111#11#111# #1#11#1111#
16 copy 3 #1#11#1#1# #1111111#11#1#1111111# #11111#11#11#11111# #111#11#111#111# #1#11#1111#1#
17 copy 3 #1#11#1#1#11# #1111111#11#1#1111111#11# #11111#11#11#11111#11# #111#11#111#111#11# #1#11#1111#1#11#
18 shL 2 #1#11#1#1#11# #1111111#11#1#1111111#11# #11111#11#11#11111#11# #111#11#111#111#11# #1#11#1111#1#11#
19 ifLT(21) #1#11#1#
20 goto(4) #1#11#11#
21 const 1 #1#11#1#1# #1#11#1111#1#
22 shL 1 #1#11#1#1# #1#11#1111#1#
23 add #1#11#11# #1#11#11111#
24 move 2,1 #11# #11111#
(1st input - iteration 1) (2nd input - iteration 2)
#111# #1111#
1 shR 1 #111# (1st input - iteration2) #1111# (2nd input - iteration 2) (2nd input - iteration 3)
2 copy 1 #111#111# #111#11#11# #1111#1111# #1111#111#111# #1111#111#11#11#
3 const 1 #111#111#1# #111#11#11#1# #1111#1111#1# #1111#111#111#1# #1111#111#11#11#1#
4 shL 2 #111#111#1# #111#11#11#1# #1111#1111#1# #1111#111#111#1# #1111#111#11#11#1#
5 monus #111#11# #111#11#1# #1111#111# #1111#111#11# #1111#111#11#1#
6 shR 1 #111#11# #111#11#1# #1111#111# #1111#111#11# #1111#111#11#1#
7 copy 1 #111#11#11# #111#11#1#1# #1111#111#111# #1111#111#11#11# #1111#111#11#1#1#
8 const 1 #111#11#11#1# #111#11#1#1#1# #1111#111#111#1# #1111#111#11#11#1# #1111#111#11#1#1#1#
9 shL 2 #111#11#11#1# #111#11#1#1#1# #1111#111#111#1# #1111#111#11#11#1# #1111#111#11#1#1#1#
10 ifEQ(16) #111#11# #111#11#1# #1111#111# #1111#111#11# #1111#111#11#1#
11 copy 2 #111#11#111# #1111#111#1111# #1111#111#11#111#
12 copy 2 #111#11#111#11# #1111#111#1111#111# #1111#111#11#111#11#
13 shL 2 #111#11#111#11# #1111#111#1111#111# #1111#111#11#111#11#
14 ifLT(16) #111#11# #1111#111# #1111#111#11#
15 goto(2)
16 shL 3 #111#11#1# #1111#111#11#1#

You might also like