Answers to Assignments
9/11 9/25 10/4 10/25 10/30 11/13
A - 1 (Sept 11, 2002)
1. Lab 1.2
1.a. The URL for lab 8.3 is:
http://www.brookscole.com/compsci_d/templates/student_resources/0534953654_decke
rhirchfield/aeonline/course/8/3/index.html
This URL can be found in the status bar at the bottom of the browser when you
mouse over the anchor; You can also right click the anchor, select "property",
and find the URL in the property window.
1b. There are 5 labs for module 7.
1c. The title of Lab 9.4 is "Decisions, decisions..."
3. Creating Unix folders and setting permissions (A typescript example)
(1) unixs1 $ mkdir is2000
(2) unixs1 $ cd is2000
(3) unixs1 $ mkdir public
(4) unixs1 $ fs la public
Access list for public is
Normal rights:
system:anyuser rl
username rlidwka
(5) unixs1 $ mkdir private
(6) unixs1 $ fs la private
Access list for private is
Normal rights:
system:anyuser rl
username rlidwka
(7) unixs1 $ fs setacl private system:anyuser none
(8) unixs1 $ fs la private
Access list for private is
Normal rights:
username rlidwka
(9) unixs1 $ exit
exit
A - 6 (Oct 30, 2002)
6.1 - 3
a. At what address is the MUL X instruction stored? How is that address represented
in binary?
It is stored at location 4. Binary representation : 0000 0100
b. What is the binary operation code that corresponds to the symbolic instruction
LOD?
Opcode for LOD : 0001 0100
c. How is the number 2 represented in binary?
0000 0010
d. At what address is variable Y stored, and how is that address represented
in binary?
Y is stored at location 130, represented as 1000 0010
e. Answer question d, this time for variable X.
X is stored at location 129, represented as 1000 0001
f. Answer question d, this time for variable W.
W is stored at location 128, represented as 1000 0000
g. What are the binary operation codes corresponding to the symbolic PIPPIN
instructions ADD? MUL? STO?
ADD: 0000 0000 MUL: 0000 0010 STO: 0000 0101
6.2 - 9
A: Y = X - 3 * Z
B: Y = ( X - 3 ) + Z
C: Y = X - ( 3 *( Z / 2 ))
6.4-8 Calculate average of 3 numbers stored in X,Y and Z and store result
in W.
LOD X
ADD Y
ADD Z
DIV #3
STO W
HLT
TM3
1. General statement of what TM3 does:
Addition. Takes two strings of 1s that are separated by a !.
2. Rules (numbers in the left column below are present states):
1 Change first 1 to b, go to state 2
2 Replace ! with 1 and halt
3 Move right past the 1s
3. Algorithm:
TM3 changes the first 1 to a b, then keeps moving right past all 1s until it
finds the !. It changes the ! to 1 and halts. By doing this it adds up the two
numbers.
------------------------------
TM4
1. General statement of what TM4 does:
Subtraction. Takes two strings of 1s that are separated by !.
2. Rules (numbers in the left column below are present states):
1 Consume the first 1. Move right
1 If !, go to state 6
2 Keep moving past 1s
2 If !, go to state 3
3 Keep moving past !s
3 If 1, change to !. goto state 4
3 If b (end) go to state 5
4 Move left past 1s
4 Move left past !s
4 If b go to state 1
5 Change ! to b. Move left
5 Move left past all 1s
5 If b, halt
6 If b, halt
6 Change 1s into b's
6 Change !s into b's
3. Algorithm:
TM4 changes the first 1 to b and move right until it finds the first 1 after
!. It changes the 1 to !, then moves back until it finds b. On finding b it
repeats the above process. It keeps repeating the process until all 1s in the
first string are replaced by b's , if the first string is longer. The remainder
is the result.
----------------------------------
TM5
1. General statement of what TM5 does:
Returns True for odd number of 1s and False otherwise.
2. Rules
1 If 1, go to state 2
1 If b, change it to F and halt
2 If 1, back to state 1
2 If b, change it to T and halt
3. Algorithm:
TM4 goes between state 1 and state 2, skipping 1s. If it finds b in state 1,
it changes that b to F and stops. If it finds b in state 2, it changes it to
T and stops. Which means if there are odd number of 1s, the string will end
with T. Otherwise it ends with an F.
----------------------------
TM6
1. General statement of what TM6 does:
It checks if the input string is a palindrome (P is for palindrome)
2. Rules
3. Algorithm:
TM6 takes a string that ends with b. It starts from the left, changing the first
symbol to b, then check the rightmost symbol before the ending b. If it is the
same, change it to b. Then it goes left and repeats the process. It keeps moving
rightward and leftward over the string inside b's, comparing the rightmost symbol
to the leftmost one. On finding the first right symbol different from the left
one after b, it writes N and halts. Otherwise on finding the last b it writes
P.
-----------------------
Grading criteria: For each TM, we give 0.5 point for clearly and briefly stating what it does (e.g. addition, subtraction, etc), 1 point for the rules, and 1 point for giving a correct description of the algorithm.