CHAPTER 8
Exercises
E8.1 The number of bits in the memory addresses is the same as the address
E8.3 Starting from the initial situation shown in Figure 8.7a in the book,
execution of the command PSHB results in:
0907:
Then, execution of the command PSHA results in:
0907:
Then, the PULX command reads two bytes from the stack and we have:
E8.4 Starting from the initial situation shown in Figure 8.7a in the book,
execution of the command PSHX results in:
0907:
0908:
Next the PULX command reads two bytes from the stack, and we have:
(b) LDAA #$43
(c) LDAA $05,X
This instruction uses constant offset indexed addressing. The effective
(d) LDAA $06
This instruction uses direct addressing. The effective address is 0006.
(e) LDAA $07,X-
This instruction uses auto post-decremented indexed addressing. The
effective address is the content of the X register which is 0200. In
E8.7 (a) Referring to Table 8.1 in the book, we see that CLRA is the clear
accumulator A instruction with a single byte op code 87. Furthermore
(b) When the instructions are executed, the CLRA command sets the Z
E8.8 One answer is given in the book. Of course, other correct answers exist.
Problems
P8.1 The functional parts of a computer are the central processing unit
P8.2 Tristate buffers act as switches that can be open or closed depending on
P8.3 Some examples of input/output devices are keyboards, display devices,
P8.4 In memory-mapped I/O, I/O devices are addressed by the same bus as
P8.5 A bus is a parallel set of conductors used to transfer multiple bits at one
P8.7* Because the address bus width is 16 bits, we conclude that the maximum
P8.8 A microprocessor is a CPU contained on a single integrated-circuit chip.
P8.9 In computers with Harvard architecture, there are separate memories
P8.10 As the term is currently used, RAM is read and write memory (originally
random access memory) that is based on semiconductor technology and is
P8.11* ROM is read-only memory. Some types are:
2. Programmable read-only memory (PROM) in which data is
3. Erasable PROMs (EPROMs) that can be erased by exposure to
4. Electrically erasable PROMs (EEPROMs) that can be erased by
P8.12 Some types of mass storage devices are hard disks, flash memory, and
CD-ROM or DVD-ROM disks.
P8.15* In the ignition control system for automobiles, we need to use ROM for
the programs and fixed data, because ROM is nonvolatile. Some RAM
P8.18 Elements of MCU-based control systems include analog and digital
P8.19 A sensor produces an analog or digital signal that is related to a physical
variable. Examples are a temperature sensor that produces an output
P8.20 Actuators produce physical outputs in response to digital or analog
electrical signals. Examples of digital actuators are switches or valves
P8.21* A digital sensor produces a logic signal or a digital word as its output. An
P8.22 Washing machines, clothes dryers, microwave ovens, refrigerators, ovens,
P8.23 Mechanical engineering:
Automotive applications such as ignition, anti-skid brakes, and
adaptive suspension.
Chemical engineering:
P8.24 An A/D is an analog-to-digital converter that converts samples of an
P8.25* A D/A is a digital-to-analog converter that converts a sequence of digital
P8.26 Polling is the process of periodically checking digital input signals to a
microprocessor to determine when actions are needed.
P8.27 The A, B, and D accumulators are registers that hold one of the
arguments and the results of all arithmetic and logical operations. The
P8.28 The program counter (PC) is a 16-bit register that contains the address
of the first byte of the next instruction to be fetched (read) from
P8.29* A stack is a sequence of locations in RAM used to store information such
as the contents of the program counter and other registers when a
P8.31* Initially, we have:
A: 07 0048: 00
X: 34BF 004B: 00
After the command PSHA, we have:
After the command PSHB, we have:
After the command PULA, we have:
After the command PULB, we have:
After the command PSHX, we have:
A: A9 0048: 00
004F: 00
P8.32 Initially, we have:
A: A7 0048: 00
After the command PSHY, we have:
A: A7 0048: 00
After the command PSHB, we have:
A: A7 0048: 00
After the command PULY, we have:
A: A7 0048: 00
B: 69 0049: 00
004F: 00
After the command PSHA, we have
A: A7 0048: 00
P8.33* A sequence of instructions that results in swapping the high and low
bytes of the X register is:
PSHA ;save the original content of A
P8.34 For each part of this problem, the initial contents of the registers are
A:01 and X:2000. The contents of various memory locations are shown in
Figure P8.34 in the book.
P8.35
Name of
Addressing
(D) =
(A):(B)
(X)
(Y)
Accumulator-offset IDX
$2003
$1FFF
$1000
incremented IDX
Indexed indirect
$0003
$37AF
$1000
Indexed indirect
$F303
$1FFF
$1000
P8.36 *(a) The A register contains FF. Because the most significant bit is 1,
(b) The A register initially contains FF. The INCA instruction causes
P8.37
Mnemonics
Machine codes
Memory locations occupied
by instruction
*(a)
CLRA
87
1
*(b)
ADDA $4A
9B 4A
2
(c)
ADDA $02FF
BB 02 FF
3
(d)
BNE -$06
26 FA
2
(e)
ADDA #$0D
8B 0D
2
P8.38
Instruction
sequence
Content of A
after execution
Z
N
LDAA #$01
01
0
0
ADDA #$F1
0
1
CLRA
00
1
0
P8.39* (a) 43 + 05 = 48
P8.40* The MUL instruction multiplies the content of A by that of B with the
result in D. The contents of A and B are treated as unsigned integers.
P8.41* The program listing is:
; ANSWER FOR PROBLEM 8.41
ORG 0200 ;Directive to begin in location 0200
P8.42 The program listing is:
;AN ANSWER FOR PROBLEM P8.42
ORG $0400
P8.43* This subroutine first clears register B which will hold the quotient after
the program has been executed. Then 3 is repeatedly subtracted from
P8.44
Source code
Description
Memory content
; PROBLEM 8.44
Comment
;
Comment (line space)
in location $0600
immediate addressing
0601:07
immediate addressing
0603:AF
0608:3E
of program
When the program is executed, the STD $0609 command results in
P8.45 The program is:
; Answer for Problem P8.45
;
MUL3 STAA $0A ;save original content of A
;
OUT INCA
;
; Branch to ADD1 if A initially contained 2 plus an integer multiple of 3:
P8.46 The program is:
; Answer for Problem P8.46. Convert content of B from BCD to binary.
;
; Multiply n by 2^4 to shift n four bits left to isolate upper nibble (4 bits)
; of n:
Practice Test
T8.3 Initially, we have:
A: A6 1034: 00
After the command PSHX, we have:
A: A6 1034: 00
After the command PSHB, we have:
A: A6 1034: 00
After the command PULA, we have:
A: 32 1034: 00
After the command PSHX, we have:
A: 32 1034: 00