• Home
  • Textbooks
  • Computer Science - An Overview
  • Data Manipulation

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow

Chapter 2

Data Manipulation - all with Video Answers

Educators


Chapter Questions

01:19

Problem 1

a. In what way are general-purpose registers and main memory cells similar?
b. In what way do general-purpose registers and main memory cells differ?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:33

Problem 2

Answer the following questions in terms of the machine language described in Appendix C.
a. Write the instruction 2304 (hexadecimal) as a string of 16 bits.
b. Write the op-code of the instruction B2A5 (hexadecimal) as a string of 4 bits.
c. Write the operand field of the instruction B2A5 (hexadecimal) as a string of 12 bits.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:23

Problem 3

Suppose a block of data is stored in the memory cells of the machine described in Appendix C from address 98 to $\mathrm{A} 2$, inclusive. How many memory cells are in this block? List their addresses.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:22

Problem 4

What is the value of the program counter in the machine described in Appendix C immediately after executing the instruction B0CD?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:10

Problem 5

Suppose the memory cells at addresses 00 through 05 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 22 \\
01 & 11 \\
02 & 32 \\
03 & 02 \\
04 & \mathrm{C} 0 \\
05 & 00
\end{array}$$
Assuming that the program counter initially contained $00,$ record the contents of the program counter, instruction register, and memory cell at address 02 at the end of each fetch phase of the machine cycle until the machine halts.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:23

Problem 6

Suppose three values $x, y,$ and $z$ are stored in a machine's memory. Describe the sequence of events (loading registers from memory, saving values in memory, and so on) that leads to the computation of $x+y+z$. How about $(2 x)+y ?$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:27

Problem 7

The following are instructions written in the machine language described in Appendix C. Translate them into English.
a. 7123
b. $40 \mathrm{E} 1$
c. $A 304$
d. B100
e. $2 \mathrm{BCD}$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:12

Problem 8

Suppose a machine language is designed with an op-code field of 4 bits. How many different instruction types can the language contain? What if the op-code field is increased to 6 bits?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:01

Problem 9

Translate the following instructions from English into the machine language described in Appendix C.
a. LOAD register 6 with the hexadecimal value 77
b. LOAD register 7 with the contents of memory cell 77
c. JUMP to the instruction at memory location 24 if the contents of register 0 equals the value in register $A$
d. ROTATE register 4 three bits to the right.
e. AND the contents of registers $\mathrm{E}$ and 2 leaving the result in register 1

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:29

Problem 10

Rewrite the program in Figure 2.7 assuming that the values to be added are encoded using floating-point notation rather than two's complement notation.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:16

Problem 11

Classify each of the following instructions (in the machine language of Appendix $C$ ) in terms of whether its execution changes the contents of the memory cell at location $3 B$ retrieves the contents of the memory cell at location $3 \mathrm{C}$, or is independent of the contents of the memory cell at location 3C.
a. $353 \mathrm{C}$
b. $253 \mathrm{C}$
c. $153 \mathrm{C}$
d. $3 \mathrm{C} 3 \mathrm{C}$
e. $403 \mathrm{C}$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:16

Problem 12

Suppose the memory cells at addresses 00 through 03 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 26 \\
01 & 55 \\
02 & \text { C0 } \\
03 & 00
\end{array}$$
a. Translate the first instruction into English.
b. If the machine is started with its program counter containing $00,$ what bit pattern is in register 6 when the machine halts?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:10

Problem 13

Suppose the memory cells at addresses 00 through 02 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 12 \\
01 & 21 \\
02 & 34
\end{array}$$
a. What would be the first instruction executed if we started the machine with its program counter containing $00 ?$
b. What would be the first instruction executed if we started the machine with its program counter containing $01 ?$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:44

Problem 14

Suppose the memory cells at addresses 00 through 05 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 12 \\
01 & 02 \\
02 & 32 \\
03 & 42 \\
04 & \mathrm{C} 0 \\
05 & 00
\end{array}$$
When answering the following questions, assume that the machine starts with its program counter equal to 00
a. Translate the instructions that are executed into English.
b. What bit pattern is in the memory cell at address 42 when the machine halts?
c. What bit pattern is in the program counter when the machine halts?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:53

Problem 15

Suppose the memory cells at addresses 00 through 09 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 1 \mathrm{C} \\
01 & 03 \\
02 & 2 \mathrm{B} \\
03 & 03 \\
04 & 5 \mathrm{A} \\
05 & \mathrm{BC} \\
06 & 3 \mathrm{A} \\
07 & 00 \\
08 & \mathrm{C} 0 \\
09 & 00
\end{array}$$
Assume that the machine starts with its program counter containing 00
a. What will be in the memory cell at address 00 when the machine halts?
b. What bit pattern will be in the program counter when the machine halts?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:28

Problem 16

Suppose the memory cells at addresses 00 through 07 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 2 \mathrm{B} \\
01 & 07 \\
02 & 3 \mathrm{B} \\
03 & 06 \\
04 & \mathrm{C} 0 \\
05 & 00 \\
06 & 00 \\
07 & 23
\end{array}$$
a. List the addresses of the memory cells that contain the program that will be executed if we start the machine with its program counter containing 00
b. List the addresses of the memory cells that are used to hold data.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
06:04

Problem 17

Suppose the memory cells at addresses 00 through 0 D in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 20 \\
01 & 04 \\
02 & 21 \\
03 & 01 \\
04 & 40 \\
05 & 12 \\
06 & 51 \\
07 & 12 \\
08 & \text { B1 } \\
09 & 0 \mathrm{C} \\
0 \mathrm{A} & \text { B0 } \\
0 \mathrm{B} & 06 \\
0 \mathrm{C} & \text { C0 } \\
0 \mathrm{D} & 00
\end{array}$$
Assume that the machine starts with its program counter containing 00
a. What bit pattern will be in register 0 when the machine halts?
b. What bit pattern will be in register 1 when the machine halts?
c. What bit pattern is in the program counter when the machine halts?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:17

Problem 18

Suppose the memory cells at addresses F0 through FD in the machine described in Appendix C contain the following (hexadecimal j bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
\text { F0 } & 20 \\
\text { F1 } & 00 \\
\text { F2 } & 22 \\
\text { F3 } & 02 \\
\text { F4 } & 23 \\
\text { F5 } & 04 \\
\text { F6 } & \text { B3 } \\
\text { F7 } & \text { FC } \\
\text { F8 } & 50 \\
\text { F9 } & 02 \\
\text { FA } & \text { B0 } \\
\text { FB } & \text { F6 } \\
\text { FC } & \text { C0 } \\
\text { FD } & 00
\end{array}$$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:22

Problem 19

If the machine in Appendix C executes an instruction every microsecond (a millionth of a second), how long does it take to complete the program in Problem $18 ?$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:43

Problem 20

Suppose the memory cells at addresses 20 through 28 in the machine described in Appendix C contain the following bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
20 & 12 \\
21 & 20 \\
22 & 32 \\
23 & 30 \\
24 & B 0 \\
25 & 21 \\
26 & 24 \\
27 & C 0 \\
28 & 00
\end{array}$$
Assume that the machine starts with its program counter containing 20
a. What bit patterns will be in registers $0,1,$ and 2 when the machine halts?
b. What bit pattern will be in the memory cell at address 30 when the machine halts?
c. What bit pattern will be in the memory cell at address B0 when the machine halts?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:08

Problem 21

Suppose the memory cells at addresses AF through B1 in the machine described in Appendix C contain the following bit patterns:
What would happen if we started the machine with its program counter containing AF?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:45

Problem 22

Suppose the memory cells at addresses 00 through 05 in the machine described in Appendix C contain the following (hexadecimal bit patterns:
$$\begin{aligned}
&\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 25 \\
01 & \text { B0 } \\
02 & 35 \\
03 & 04 \\
04 & \text { C0 } \\
05 & 00
\end{array}\\
\end{aligned}$$
If we start the machine with its program counter containing $00,$ when does the machine halt?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
12:26

Problem 23

In each of the following cases, write a short program in the machine language described in Appendix C to perform the requested activities. Assume that each of your programs is placed in memory starting at address 00
a. Move the value at memory location D8 to memory location B3.
b. Interchange the values stored at memory locations D8 and B3.
c. If the value stored in memory location 44 is $00,$ then place the value 01 in memory location $46 ;$ otherwise, put the value $\mathrm{FF}$ in memory location 46

Shelby Mohamed
Shelby Mohamed
Numerade Educator
00:56

Problem 24

A game that used to be popular among computer hobbyists is core wars-a variation of battleship. (The term core originates from an early memory technology in which 0 s and 1 s were represented as magnetic fields in little rings of magnetic material. The rings were called cores.) The game is played between two opposing programs, each stored in different locations of the same computer's memory. The computer is assumed to alternate between the two programs, executing an instruction from one followed by an instruction from the other. The goal of each program is to cause the other to malfunction by writing extraneous data on top of it; however, neither program knows the location of the other.
a. Write a program in the machine language of Appendix $C$ that approaches the game in a defensive manner by being as small as possible.
b. Write a program in the language of Appendix C that tries to avoid any attacks from the opposing program by moving to different locations. More precisely, beginning at location $00,$ write a program that will copy itself to location 70 and then jump to location 70 .
c. Extend the program in (b) to continue relocating to new memory locations. In particular, make your program move to location 70 then to $\mathrm{E} 0(=70+70)$ then to $60(=70+$ $70+70$ ) etc.

Manik Pulyani
Manik Pulyani
Numerade Educator
03:36

Problem 25

Write a program in the machine language of Appendix C to compute the sum of floatingpoint values stored at memory locations $\mathrm{A} 0$ $\mathrm{A} 1, \mathrm{A} 2,$ and $\mathrm{A} 3 .$ Your program should store the total at memory location A4.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:33

Problem 26

Suppose the memory cells at addresses 00 through 05 in the machine described in Appendix C contain the following (hexadecimal) bit patterns:
$$\begin{array}{cc}
\text { Address } & \text { Contents } \\
00 & 20 \\
01 & \mathrm{C} 0 \\
02 & 30 \\
03 & 04 \\
04 & 00 \\
05 & 00
\end{array}$$
What happens if we start the machine with its program counter containing $00 ?$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:55

Problem 27

What happens if the memory cells at addresses 08 and 09 of the machine described in Appendix C contain the bit patterns B0 and 08, respectively, and the machine is started with its program counter containing the value $08 ?$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
07:56

Problem 28

Suppose the following program, written in the machine language of Appendix $\mathrm{C}$, is stored in main memory beginning at address 30 (hexadecimal - What task will the program perform when executed?
$$\begin{array}{l}
2003 \\
2101 \\
2200 \\
2310 \\
1400 \\
3410 \\
5221 \\
5331 \\
3239 \\
3338 \\
B 248 \\
B 038 \\
C 000
\end{array}$$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:18

Problem 29

Summarize the steps involved when the machine described in Appendix C performs an instruction with op-code B. Express your answer as a set of directions as though you were telling the CPU what to do.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:48

Problem 30

Summarize the steps involved when the machine described in Appendix C performs an instruction with op-code $5 .$ Express your answer as a set of directions as though you were telling the CPU what to do.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:22

Problem 31

Summarize the steps involved when the machine described in Appendix C performs an instruction with op-code 6. Express your answer as a set of directions as though you were telling the CPU what to do.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:16

Problem 32

Suppose the registers 4 and 5 in the machine described in Appendix C contain the bit patterns $3 \mathrm{A}$ and $\mathrm{C} 8,$ respectively. What bit pattern is left in register 0 after executing each of the following instructions:
a. 5045
b. 6045
c. 7045
d. 8045
e. 9045

Shelby Mohamed
Shelby Mohamed
Numerade Educator
12:26

Problem 33

Using the machine language described in Appendix C, write programs to perform each of the following tasks:
a. Copy the bit pattern stored in memory location 44 into memory location AA.
b. Change the least significant 4 bits in the memory cell at location 34 to 0 s while leaving the other bits unchanged.
c. Copy the least significant 4 bits from memory location A5 into the least significant 4 bits of location $\mathrm{A} 6$ while leaving the other bits at location A6 unchanged.
d. Copy the least significant 4 bits from memory location A5 into the most significant 4 bits of
A5. (Thus, the first 4 bits in $A 5$ will be the same as the last $4 \text { bits. })$

Shelby Mohamed
Shelby Mohamed
Numerade Educator
06:04

Problem 34

Perform the indicated operations:

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:55

Problem 35

Identify both the mask and the logical operation needed to accomplish each of the following objectives:
a. Put 1 s in the upper 4 bits of an 8 -bit pattern without disturbing the other bits.
b. Complement the most significant bit of an $8-$ bit pattern without changing the other bits.
c. Complement a pattern of 8 bits.
d. Put a 0 in the least significant bit of an 8-bit pattern without disturbing the other bits.
e. Put 1 s in all but the most significant bit of an 8 -bit pattern without disturbing the most significant bit.
f. Filter out all of the green color component from an $\mathrm{RGB}$ bitmap image pixel in which the middle 8 bits of a 24 -bit pattern store the green information.
g. Invert all of the bits in a 24 -bit RGB bitmap pixel.
h. Set all the bits in a 24 -bit $\mathrm{RGB}$ bitmap pixel to $1,$ indicating the color "white"

Stanley Enemuo
Stanley Enemuo
Numerade Educator
05:39

Problem 36

Write and test short Python scripts to implement each of the parts of the previous question.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:06

Problem 37

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 0 s if and only if the input string is 10000001

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:39

Problem 38

Write and test a short Python script to implement the previous question.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:06

Problem 39

Describe a sequence of logical operations (along with their corresponding masks) that, when applied to an input string of
8 bits, produces an output byte of all 0 s if the input string both begins and ends with 1 s. Otherwise, the output should contain at least one 1

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:39

Problem 40

Write and test a short Python script to implement the previous question.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:30

Problem 41

What would be the result of performing a 4-bit left circular shift on the following bit patterns?
a. 10101
b. 11110000
$\begin{array}{ll}c . & 001\end{array}$
d. 101000
e. 00001

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:12

Problem 42

What would be the result of performing a 2 -bit right circular shift on the following bytes represented in hexadecimal notation (give your answers in hexadecimal notation)?
a. 3F
b. $0 \mathrm{D}$
c. FF
d. 77

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:43

Problem 43

a. What single instruction in the machine language of Appendix C could be used to accomplish a 5 -bit right circular shift of register B?
b. What single instruction in the machine language of Appendix C could be used to accomplish a 2 -bit left circular shift of register B?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
12:26

Problem 44

Write a program in the machine language of Appendix C that reverses the contents of the memory cell at address $8 \mathrm{C}$. (That is, the final bit pattern at address $8 \mathrm{C}$ when read from left to right should agree with the original pattern when read from right to left.)

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:36

Problem 45

Write a program in the machine language of Appendix C that subtracts the value stored at A1 from the value stored at address $A 2$ and
places the result at address A0. Assume that the values are encoded in two's complement notation.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
05:13

Problem 46

High definition video can be delivered at a rate of 30 frames per second (fps) where each frame has a resolution of $1920 \times 1080$ pixels using 24 bits per pixel. Can an uncompressed video stream of this format be sent over a USB
1.1 serial port? USB 2.0 serial port? USB 3.0 serial port? (Note: The maximum speeds of USB $1.1,$ USB $2.0,$ and USB 3.0 serial ports are $12 \mathrm{Mbps}, 480 \mathrm{Mbps},$ and $5 \mathrm{Gbps}$ respectively.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:57

Problem 47

Suppose a person is typing forty words per minute at a keyboard. (A word is considered to be five characters.) If a machine executes 500 instructions every microsecond (millionth of a second), how many instructions does the machine execute during the time between the typing of two consecutive characters?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:27

Problem 48

How many bits per second must a keyboard transmit to keep up with a typist typing forty words per minute? (Assume each character is encoded in ASCII and each word consists of six characters.)

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:28

Problem 49

Suppose the machine described in Appendix C communicates with a printer using the technique of memory-mapped I/O. Suppose also that address FF is used to send characters to the printer, and address FE is used to receive information about the printer's status. In particular, suppose the least significant bit at the address FE indicates whether the printer is ready to receive another character (with a 0 indicating "not ready" and a 1 indicating "ready"). Starting at address $00,$ write a machine language routine that waits until the printer is ready for another character and then sends the

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:36

Problem 50

Write a program in the machine language described in Appendix C that places 0 s in all the memory cells from address A0 through $\mathrm{C} 0$ but is small enough to fit in the memory cells from address 00 through 13 (hexadecimal)

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:25

Problem 51

Suppose a machine has $200 \mathrm{GB}$ of storage space available on a hard disk and receives data over a broadband connection at the rate of 15 Mbps. At this rate, how long will it take to fill the available storage space?

Shelby Mohamed
Shelby Mohamed
Numerade Educator
03:14

Problem 52

Suppose a satellite system is being used to receive a serial data stream at 250 Kbps. If a burst of atmospheric interference lasts 6.96 seconds, how many data bits will be affected?

Zulfiqar Ali
Zulfiqar Ali
Numerade Educator
02:50

Problem 53

Suppose you are given 32 processors, each capable of finding the sum of two multidigit numbers in a millionth of a second. Describe how parallel processing techniques can be applied to find the sum of 64 numbers in only six-millionths of a second. How much time does a single processor require to find this same sum?

Jennifer Stoner
Jennifer Stoner
Numerade Educator
02:22

Problem 54

Summarize the difference between a CISC
architecture and a RISC architecture.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
01:42

Problem 55

Identify two approaches to increasing throughput.

Jennifer Stoner
Jennifer Stoner
Numerade Educator
02:50

Problem 56

Describe how the average of a collection of numbers can be computed more rapidly with a multiprocessor machine than a single processor machine.

Jennifer Stoner
Jennifer Stoner
Numerade Educator
03:17

Problem 57

Write and test a Python script that reads in a floating-point radius of a circle and outputs the circumference and area of the circle.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
02:22

Problem 58

Write and test a Python script that reads in a character string and an integer and outputs the character string repeated the number of times given by the integer.

Shelby Mohamed
Shelby Mohamed
Numerade Educator
04:44

Problem 59

Write and test a Python script that reads in two floating-point side lengths of a right triangle and outputs the hypotenuse length, perimeter, and area.

Shelby Mohamed
Shelby Mohamed
Numerade Educator