Professional Documents
Culture Documents
Thamk Hao
Thamk Hao
The following are instructions written in the above simple machine language.
Rewrite in English.
368A: lưu dl r6 vào đc A8
BADE:nhảy đến đc DE nếu giá trị tại thanh ghi rA = giá trị tại r0
803C:thực hiện AND r3 và rC ghi kq vào r0
40F4:chuyển dl của rF vô r4
7123:or r2 và r3 ghi kq vào r1
40E1:chuyển dl của re vào r1
A304:quay gtri r3 4 lần
B100:nhảy đến đc 00 nếu dl r1 = r0
2BCD:nạp gtri dl CD vào rB
What is the difference between the instructions 15AB and 25AB in the simple
machine language?
15AB :nạp dl từ đc AB vào r5
25AB :nạp dl AB vào r5
Here are some instructions in English. Translate each of them into the simple
machine language.
LOAD register number 3 with the hexadecimal 56. 2356
ROTATE register number 5 three bits to the right.A503
AND the contents of register A with the contents of register 5 and leave
the result in register 0. 80A5
1. What logical operation together with what mask can you use to change ASCII
codes of lower characters to uppercase? What about uppercase to lowercase?
2. Identify both the mask and the logical operation needed to accomplish each of
the following objectives:
• Put 1s in the upper 4 bits of an 8-bit pattern without disturbing the other bits.
• Complement the most significant bit of an 8-bit pattern without changing the
other bits.
• Complement a pattern of 8 bits.
• Put a 0 in the least significant bit of an 8-bit pattern without disturbing the
other bits.
3. Identify both the mask and the logical operation needed to accomplish each of
the following objectives:
• Put 1s in the upper 4 bits of an 8-bit pattern without disturbing the other bits.
• Complement the most significant bit of an 8-bit pattern without changing the
other bits.
• Complement a pattern of 8 bits.
• Put a 0 in the least significant bit of an 8-bit pattern without disturbing the
other bits.
4. Identify both the mask and the logical operation needed to accomplish each of
the following objectives:
• Put 1s in all but the most significant bit of an 8-bit pattern without disturbing
the most significant bit.
• Filter out all of the green color component from an RGB bitmap image pixel in
which the middle 8 bits of a 24-bit pattern store the green information.
• Invert all of the bits in a 24-bit RGB bitmap
• Set all the bits in a 24-bit RGB bitmap pixel to 1, indicating the color “white”.
5. Identify a logical operation (along with a corresponding mask) that, when
applied to an input string of 8 bits, produces an output string of all 0s if and
only ifs the input string is 1000 0001.
1. Suppose the memory cells from addresses 00 to 05 in the machine described
in Appendix C contain the (hexadecimal) bit patterns given in the following
table:
Address Contents
00 14
01 02
02 34
03 17
04 C0
05 00
If we start the machine with its program counter containing 00, what bit
pattern is in the memory cell whose address is hexadecimal 17 when the
machine halts?
2. Suppose the memory cells at addresses B0 to B8 in the machine described in
Appendix C contain the (hexadecimal) bit patterns given in the following table:
Address Contents
B0 13
B1 B8
B2 A3
B3 02
B4 33
B5 B8
B6 C0
B7 00
B8 0F
a. If the program counter starts at B0, what bit pattern is in register
number 3 after the first instruction has been executed?
b. What bit pattern is in memory cell B8 when the halt instruction is
executed?
3. Suppose the memory cells at addresses A4 to B1 in the machine described in
Appendix C contain the (hexadecimal) bit patterns given in the following table:
Address Contents
A4 20
A5 00
A6 21
A7 03
A8 22
A9 01
AA B1
AB B0
AC 50
AD 02
AE B0
AF AA
B0 C0
B1 00
When answering the following questions, assume that the machine is started
with its program counter containing A4.
a. What is in register 0 the first time the instruction at address AA is
executed?
b. What is in register 0 the second time the instruction at address AA is
executed?
c. How many times is the instruction at address AA executed before the
machine halts?
4. Suppose the memory cells at addresses F0 to F9 in the machine described in
Appendix C contain the (hexadecimal) bit patterns described in the following
table:
Address Contents
F0 20
F1 C0
F2 30
F3 F8
F4 20
F5 00
F6 30
F7 F9
F8 FF
F9 FF
If we start the machine with its program counter containing F0, what does the
machine do when it reaches the instruction at address F8?