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

Chapter 2 RQ

This document contains a series of review problems related to data manipulation in machine language, focusing on various operations involving memory addresses, instruction execution, and register manipulation. It includes tasks such as translating hexadecimal instructions to binary, computing values stored in memory, and understanding the behavior of a hypothetical machine's program counter. The problems are designed to reinforce concepts from the associated appendix on machine language and data handling.
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)
2 views6 pages

Chapter 2 RQ

This document contains a series of review problems related to data manipulation in machine language, focusing on various operations involving memory addresses, instruction execution, and register manipulation. It includes tasks such as translating hexadecimal instructions to binary, computing values stored in memory, and understanding the behavior of a hypothetical machine's program counter. The problems are designed to reinforce concepts from the associated appendix on machine language and data handling.
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

102 Chapter 2 Data Manipulation

Chapter Review Problems


(Asterisked problems are associated with optional sections.)

1. a. In what way are general-purpose registers a. 7123 b. 40E1 c. A304


and main memory cells similar? d. B100 e. 2BCD
b. In what way do general-purpose registers 8. Suppose a machine language is designed with
and main memory cells differ? an op-code field of 4 bits. How many different
2. Answer the following questions in terms of instruction types can the language contain?
the machine language described in Appendix C. What if the op-code field is increased to 6 bits?
a. Write the instruction 2304 (hexadecimal) as 9. Translate the following instructions from
a string of 16 bits. English into the machine language described
b. Write the op-code of the instruction B2A5 in Appendix C.
(hexadecimal) as a string of 4 bits. a. LOAD register 6 with the hexadecimal
c. Write the operand field of the instruction value 77.
B2A5 (hexadecimal) as a string of 12 bits. b. LOAD register 7 with the contents of mem-
3. Suppose a block of data is stored in the mem- ory cell 77.
ory cells of the machine described in c. JUMP to the instruction at memory loca-
Appendix C from address 98 to A2, inclusive. tion 24 if the contents of register 0 equals
How many memory cells are in this block? the value in register A.
List their addresses. d. ROTATE register 4 three bits to the right.
4. What is the value of the program counter in e. AND the contents of registers E and 2 leav-
the machine described in Appendix C immedi- ing the result in register 1.
ately after executing the instruction B0CD? 10. Rewrite the program in Figure 2.7 assuming
5. Suppose the memory cells at addresses 00 that the values to be added are encoded using
through 05 in the machine described in floating-point notation rather than two’s com-
Appendix C contain the following bit patterns: plement notation.
11. Classify each of the following instructions (in
Address Contents
the machine language of Appendix C) in
00 22
terms of whether its execution changes the
01 11
contents of the memory cell at location 3B,
02 32
retrieves the contents of the memory cell at
03 02
location 3C, or is independent of the contents
04 C0
of the memory cell at location 3C.
05 00
a. 353C b. 253C c. 153C
Assuming that the program counter initially d. 3C3C e. 403C
contained 00, record the contents of the pro- 12. Suppose the memory cells at addresses 00
gram counter, instruction register, and memory through 03 in the machine described in
cell at address 02 at the end of each fetch phase Appendix C contain the following bit patterns:
of the machine cycle until the machine halts.
Address Contents
6. Suppose three values x, y, and z are stored in a 00 26
machine’s memory. Describe the sequence of 01 55
events (loading registers from memory, saving 02 C0
values in memory, and so on) that leads to the 03 00
computation of x  y  z. How about (2x)  y? a. Translate the first instruction into English.
7. The following are instructions written in the b. If the machine is started with its program
machine language described in Appendix C. counter containing 00, what bit pattern is
Translate them into English. in register 6 when the machine halts?
Chapter Review Problems 103

13. Suppose the memory cells at addresses 00 a. What will be in the memory cell at address
through 02 in the machine described in 00 when the machine halts?
Appendix C contain the following bit patterns: b. What bit pattern will be in the program
Address Contents counter when the machine halts?
00 12 16. Suppose the memory cells at addresses 00
01 21 through 07 in the machine described in
02 34 Appendix C contain the following bit patterns:
a. What would be the first instruction exe- Address Contents
cuted if we started the machine with its 00 2B
program counter containing 00? 01 07
b. What would be the first instruction exe- 02 3B
cuted if we started the machine with its 03 06
program counter containing 01? 04 C0
14. Suppose the memory cells at addresses 00 05 00
through 05 in the machine described in 06 00
Appendix C contain the following bit patterns: 07 23

Address Contents a. List the addresses of the memory cells that


00 12 contain the program that will be executed if
01 02 we start the machine with its program
02 32 counter containing 00.
03 42 b. List the addresses of the memory cells that
04 C0 are used to hold data.
05 00
17. Suppose the memory cells at addresses 00
When answering the following questions, through 0D in the machine described in
assume that the machine starts with its pro- Appendix C contain the following bit patterns:
gram counter equal to 00.
Address Contents
a. Translate the instructions that are executed
00 20
into English.
01 04
b. What bit pattern is in the memory cell at
02 21
address 42 when the machine halts?
03 01
c. What bit pattern is in the program counter
04 40
when the machine halts?
05 12
15. Suppose the memory cells at addresses 00 06 51
through 09 in the machine described in 07 12
Appendix C contain the following bit patterns: 08 B1
Address Contents 09 0C
00 1C 0A B0
01 03 0B 06
02 2B 0C C0
03 03 0D 00
04 5A
Assume that the machine starts with its pro-
05 BC
gram counter containing 00.
06 3A
a. What bit pattern will be in register 0 when
07 00
the machine halts?
08 C0
b. What bit pattern will be in register 1 when
09 00
the machine halts?
Assume that the machine starts with its pro- c. What bit pattern is in the program counter
gram counter containing 00. when the machine halts?
104 Chapter 2 Data Manipulation

18. Suppose the memory cells at addresses F0 21. Suppose the memory cells at addresses AF
through FD in the machine described in through B1 in the machine described in
Appendix C contain the following (hexadeci- Appendix C contain the following bit patterns:
mal) bit patterns: Address Contents
Address Contents AF B0
F0 20 B0 B0
F1 00 B1 AF
F2 22
What would happen if we started the machine
F3 02
with its program counter containing AF?
F4 23
F5 04 22. Suppose the memory cells at addresses 00
F6 B3 through 05 in the machine described in
F7 FC Appendix C contain the following (hexadeci-
F8 50 mal) bit patterns:
F9 02 Address Contents
FA B0 00 25
FB F6 01 B0
FC C0 02 35
FD 00 03 04
04 C0
If we start the machine with its program
05 00
counter containing F0, what is the value in
register 0 when the machine finally executes If we start the machine with its program counter
the halt instruction at location FC? containing 00, when does the machine halt?
19. If the machine in Appendix C executes an 23. In each of the following cases, write a short
instruction every microsecond (a millionth of program in the machine language described in
a second), how long does it take to complete Appendix C to perform the requested activi-
the program in Problem 18? ties. Assume that each of your programs is
20. Suppose the memory cells at addresses 20 placed in memory starting at address 00.
through 28 in the machine described in a. Move the value at memory location D8 to
Appendix C contain the following bit patterns: memory location B3.
b. Interchange the values stored at memory
Address Contents locations D8 and B3.
20 12 c. If the value stored in memory location 44 is
21 20 00, then place the value 01 in memory loca-
22 32 tion 46; otherwise, put the value FF in
23 30 memory location 46.
24 B0
25 21 24. A game that used to be popular among com-
26 24 puter hobbyists is core wars—a variation of
27 C0 battleship. (The term core originates from an
28 00 early memory technology in which 0s and 1s
were represented as magnetic fields in little
Assume that the machine starts with its pro- rings of magnetic material. The rings were
gram counter containing 20. called cores.) The game is played between two
a. What bit patterns will be in registers 0, 1, opposing programs, each stored in different
and 2 when the machine halts? locations of the same computer’s memory.
b. What bit pattern will be in the memory cell The computer is assumed to alternate
at address 30 when the machine halts? between the two programs, executing an
c. What bit pattern will be in the memory cell instruction from one followed by an instruc-
at address B0 when the machine halts? tion from the other. The goal of each program
Chapter Review Problems 105

is to cause the other to malfunction by writing 2200


extraneous data on top of it; however, neither 2310
program knows the location of the other. 1400
a. Write a program in the machine language 3410
of Appendix C that approaches the game 5221
in a defensive manner by being as small 5331
as possible. 3239
b. Write a program in the language of 333B
Appendix C that tries to avoid any attacks B248
from the opposing program by moving to B038
different locations. More precisely, begin- C000
ning at location 00, write a program that 29. Summarize the steps involved when the
will copy itself to location 70 and then machine described in Appendix C performs
jump to location 70. an instruction with op-code B. Express your
c. Extend the program in (b) to continue relo- answer as a set of directions as though you
cating to new memory locations. In particu- were telling the CPU what to do.
lar, make your program move to location 70,
then to E0 ( 70  70), then to 60 ( 70  *30. Summarize the steps involved when the
70  70), etc. machine described in Appendix C performs
an instruction with op-code 5. Express your
25. Write a program in the machine language of answer as a set of directions as though you
Appendix C to compute the sum of floating- were telling the CPU what to do.
point values stored at memory locations A0,
A1, A2, and A3. Your program should store the *31. Summarize the steps involved when the
total at memory location A4. machine described in Appendix C performs
an instruction with op-code 6. Express your
26. Suppose the memory cells at addresses 00
answer as a set of directions as though you
through 05 in the machine described in
were telling the CPU what to do.
Appendix C contain the following (hexadeci-
mal) bit patterns: *32. Suppose the registers 4 and 5 in the machine
Address Contents described in Appendix C contain the bit pat-
00 20 terns 3A and C8, respectively. What bit pat-
01 C0 tern is left in register 0 after executing each
02 30 of the following instructions:
03 04 a. 5045 b. 6045 c. 7045
04 00 d. 8045 e. 9045
05 00 *33. Using the machine language described in
Appendix C, write programs to perform each
What happens if we start the machine with its
of the following tasks:
program counter containing 00?
a. Copy the bit pattern stored in memory
27. What happens if the memory cells at location 44 into memory location AA.
addresses 08 and 09 of the machine described b. Change the least significant 4 bits in the
in Appendix C contain the bit patterns B0 and memory cell at location 34 to 0s while
08, respectively, and the machine is started with leaving the other bits unchanged.
its program counter containing the value 08? c. Copy the least significant 4 bits from
28. Suppose the following program, written in the memory location A5 into the least signifi-
machine language of Appendix C, is stored in cant 4 bits of location A6 while leaving the
main memory beginning at address 30 (hexa- other bits at location A6 unchanged.
decimal). What task will the program perform d. Copy the least significant 4 bits from
when executed? memory location A5 into the most signifi-
2003 cant 4 bits of A5. (Thus, the first 4 bits in
2101 A5 will be the same as the last 4 bits.)
106 Chapter 2 Data Manipulation

*34. Perform the indicated operations: accomplish a 5-bit right circular shift of
a. 111001 b. 000101 register B?
AND 101001 AND 101010 b. What single instruction in the machine lan-
guage of Appendix C could be used to accom-
c. 001110 d. 111011
plish a 2-bit left circular shift of register B?
AND 010101 AND 110111
*41. Write a program in the machine language of
e. 111001 f. 010100 Appendix C that reverses the contents of the
OR 101001 OR 101010 memory cell at address 8C. (That is, the final
g. 000100 h. 101010 bit pattern at address 8C when read from left
OR 010101 OR 110101 to right should agree with the original pat-
tern when read from right to left.)
i. 111001 j. 000111
XOR 101001 XOR 101010 *42. Write a program in the machine language of
Appendix C that subtracts the value stored at
k. 010000 l. 111111 A1 from the value stored at address A2 and
XOR 010101 XOR 110101 places the result at address A0. Assume that
*35. Identify both the mask and the logical opera- the values are encoded in two’s complement
tion needed to accomplish each of the follow- notation.
ing objectives: *43. High definition video can be delivered at a
a. Put 1s in the upper4 bits of an 8-bit pat- rate of 30 frames per second (fps) where each
tern without disturbing the other bits. frame has a resolution of 1920  1080 pixels
b. Complement the most significant bit of an using 24 bits per pixel. Can an uncompressed
8-bit pattern without changing the other bits. video stream of this format be sent over a
c. Complement a pattern of 8 bits. USB 1.1 serial port? USB 2.0 serial port?
d. Put a 0 in the least significant bit of an 8-bit USB 3.0 serial port? (Note: The maximum
pattern without disturbing the other bits. speeds of USB 1.1, USB 2.0, and USB 3.0 serial
e. Put 1s in all but the most significant bit of ports are 12Mbps, 480Mbps, and 5Gbps
an 8-bit pattern without disturbing the respectively.)
most significant bit. *44. Suppose a person is typing forty words per
*36. Identify a logical operation (along with a corre- minute at a keyboard. (A word is considered
sponding mask) that, when applied to an input to be five characters.) If a machine executes
string of 8 bits, produces an output string of all 500 instructions every microsecond (millionth
0s if and only if the input string is 10000001. of a second), how many instructions does the
machine execute during the time between the
*37. Describe a sequence of logical operations
typing of two consecutive characters?
(along with their corresponding masks) that,
when applied to an input string of 8 bits, pro- *45. How many bits per second must a keyboard
duces an output byte of all 0s if the input string transmit to keep up with a typist typing forty
both begins and ends with 1s. Otherwise, the words per minute? (Assume each character is
output should contain at least one 1. encoded in ASCII and each word consists of
six characters.)
*38. What would be the result of performing a 4-bit
left circular shift on the following bit patterns? *46. Suppose the machine described in Appendix
a. 10101 b. 11110000 c. 001 C communicates with a printer using the
d. 101000 e. 00001 technique of memory-mapped I/O. Suppose
also that address FF is used to send characters
*39. What would be the result of performing a to the printer, and address FE is used to
2-bit right circular shift on the following receive information about the printer’s status.
bytes represented in hexadecimal notation In particular, suppose the least significant bit
(give your answers in hexadecimal notation)? at the address FE indicates whether the
a. 3F b. 0D printer is ready to receive another character
c. FF d. 77 (with a 0 indicating “not ready” and a 1 indi-
*40. a. What single instruction in the machine cating “ready”). Starting at address 00, write a
language of Appendix C could be used to machine language routine that waits until the
Social Issues 107

printer is ready for another character and *50. Suppose you are given 32 processors, each
then sends the character represented by the capable of finding the sum of two multidigit
bit pattern in register 5 to the printer. numbers in a millionth of a second. Describe
*47. Write a program in the machine language how parallel processing techniques can be
described in Appendix C that places 0s in all applied to find the sum of 64 numbers in
the memory cells from address A0 through C0 only six-millionths of a second. How much
but is small enough to fit in the memory cells time does a single processor require to find
from address 00 through 13 (hexadecimal). this same sum?
*48. Suppose a machine has 200 GB of storage *51. Summarize the difference between a CISC
space available on a hard disk and receives architecture and a RISC architecture.
data over a broadband connection at the rate *52. Identify two approaches to increasing
of 15 Mbps. At this rate, how long will it take throughput.
to fill the available storage space? *53. Describe how the average of a collection of
*49. Suppose a satellite system is being used to numbers can be computed more rapidly with
receive a serial data stream at 250 Kbps. If a a multiprocessor machine than a single-
burst of atmospheric interference lasts 6.96 sec- processor machine.
onds, how many data bits will be affected?

Social Issues
The following questions are intended as a guide to the ethical/social/legal issues
associated with the field of computing. The goal is not merely to answer these
questions. You should also consider why you answered as you did and whether
your justifications are consistent from one question to the next.
1. Suppose a computer manufacturer develops a new machine architecture. To
what extent should the company be allowed to own that architecture? What
policy would be best for society?
2. In a sense, the year 1923 marked the birth of what many now call planned
obsolescence. This was the year that General Motors, led by Alfred Sloan,
introduced the automobile industry to the concept of model years. The idea
was to increase sales by changing styling rather than necessarily introducing
a better automobile. Sloan is quoted as saying, “We want to make you dissat-
isfied with your current car so you will buy a new one.” To what extent is this
marketing ploy used today in the computer industry?
3. We often think in terms of how computer technology has changed our society.
Many argue, however, that this technology has often kept changes from occur-
ring by allowing old systems to survive and, in some cases, become more
entrenched. For example, would a central government’s role in society have
survived without computer technology? To what extent would centralized
authority be present today had computer technology not been available? To
what extent would we be better or worse off without computer technology?
4. Is it ethical for an individual to take the attitude that he or she does not need
to know anything about the internal details of a machine because someone
else will build it, maintain it, and fix any problems that arise? Does your
answer depend on whether the machine is a computer, automobile, nuclear
power plant, or toaster?
5. Suppose a manufacturer produces a computer chip and later discovers a flaw
in its design. Suppose further that the manufacturer corrects the flaw in
future production but decides to keep the original flaw a secret and does not

You might also like