Assignment 4: Program Translation

advertisement
Assignment 4: Program Translation
This assignment is due Tuesday April 22th at class.
Please hand me a hard copy of your solutions at the beginning of the class on Tuesday April 22th.
1- Convert the following numbers into BCD notation:
a. 13
b. 280
c. 991
d. 1001
2- Convert the following BCD codes to decimal notation:
a. 00100000
b. 100000001001
c. 0000000001010000
d. 1000011101100111
e. 0011001000000000010101110000
3- Count from 0 to 32 in binary (base 2).
4- Convert the following decimals into binary. Show all the steps of the algorithm (process):
a. 5
b. 9
c. 16
d. 25
e. 32
f. 116
g. 128
h. 512
i. 999
j. 1000
k. 1024
5- Convert the following numbers in base 2 into decimal. Show the details:
a. 1
b. 10
c. 11
d. 010
e. 001
f. 1001
g. 1101
h. 10000
i. 10010
j. 1100001
k. 10110110
l. 11111111
m. 100000000
n. 100101011
6- Represent the following strings of characters (pieces of text) into binary format using ASCII
coding (Use table 6.1 page 246):
a. Hello, everyone!
b. Ysj 2Hb@?
7a. Use the following 8-bit operation codes to decode the given machine language piece
into PIPPIN assembly:
Instruction
Binary operation code
LOD
00000100
STO
00000101
ADD
00000000
SUB
11111111
HLT
00001111
Here is the piece of machine language:
0000010001000000
0000000001000001
0000000001000010
1111111101000100
0000010111100011
0000111100000000
b. Explain in plain English what does this piece of code do?
8-
What is the largest decimal number with length 8 base-2 presentation? (takes no more than 8
bits or one byte)
9- What is the size of a 2 Megabytes document in bits?
10a. Write a program in PIPPIN assembly which multiplies the content of memory location 96
by content of memory location 110 then subtracts the content of memory location 198
from the result of multiplication and finally adds the content memory location 244 to
the result of subtraction and stores the result in memory location 54.
b. Assuming the following contents for the memory locations:
Memory Cell
Contents
96
10
110
11
198
15
244
12
54
99
Write the contents of accumulator and memory locations 96, 110, 198, 244 and 54 at
each step of the execution of the program? (Before and after execution of each
instruction of the program, like the way we did in class.)
11a. Write the contents of accumulator and memory locations 120 and 121 at each step of
the execution of the following program:
[1] LOD #4
[2] STO 120
[3] LOD #1
[4] STO 121
[5] LOD 120
[6] JMZ 13
[7] SUB #1
[8] STO 120
[9] LOD 121
[10] MUL #2
[11] STO 121
[12] JMP 5
[13] HLT
b. What is the content of memory location 121 after the execution of the program stops?
c. If we change the first instruction of the program from LOD #4 to LOD #5, what will be
the content of memory location 121 after the execution of the program stops?
d. From b and c what can we refer about the formula this program computes?
Have fun!
Download