
- •Contents
- •Preface
- •List of Figures
- •List of Tables
- •Acknowledgments
- •1.1.2 The Instruction
- •1 Problems
- •2 Programming Microcomputers
- •3 Bus Hardware and Signals
- •3.3 Conclusions
- •3 Problems
- •5 Interrupts and Alternatives
- •5.4.1 Direct Memory Access
- •7.1.3 Other Transducers
- •7.2 Basic Analog Processing Components
- •7.2.1 Transistors and Silicon Controlled Rectifiers
- •8 Counters and Timers
- •9. Communications Systems
- •9.3.3 The ACIA
- •9.4.4 The Small Computer System Interface (SCSI)
- •9.5 Conclusions
- •10.1.2 A 6812 SPI Display

38 |
Chapter 1 Microcomputer Architecture |
Problems
Problems 1 through 3 in this chapter and many problems in later chapters are paragraph correction problems. We use thefollowing guidelines for all these problems.
These paragraph correction problems have been proven useful in helping students understand concepts and definitions. Theparagraph in eachproblem has some correctand some erroneous sentences. Your task is to rewrite the paragraph so the wholeparagraph is correct, deleting any sentences that do not fit into the paragraph's theme. However, if a sentence is correct, you should not change it, and you cannot use the word "not "or its equivalent to correct the sentence. Consider the first sentence in problem 1: "The architecture is the block diagram of a computer." This is incorrect. It can be made correct by changing "architecture"to "organization,"or by changing "block diagram"to either "programmer's view"or "instructionset and I/O connection capabilities."Any of these corrections would be acceptable. The second sentence is correct, however, and should not be rewritten. Try to complete the problems without referring to the chapter, then check your answers by looking up the definitions. If you get a couple of sentences wrong, you're doing fine. But if you have more trouble, you should reread the sections the problem covers.
1. * The architecture is the block diagram of a computer. Von Neumann invented the architecture used on microcomputers. In it, the controller is analogous to the adding machine. We recall words from primary memory into the controller using the program counter (left hand). Symbolic addresses are used in assembly languages to represent locations in this memory. A macro is a program in another part of memory that is called by a program, so that when the macro is done, the calling program resumes execution at an instruction below the jump to macro. An I/O interrupt is like a subroutine that is requested by an I/O device. The latency time is the time needed to completely execute an interrupt. To optimize the speed of execution, choose a computer with good static efficiency. A microcomputer is a controller and data operator on a single LSI chip, or on a few LSI chips.
2, * Addressing modes are especially important because they affect the efficiency of the most common class of instructions, the arithmetic class. Direct addressing has the operand data in a part of the instruction called the displacement, and the displacement would be 8 bits long for an instruction using it to load an 8-bit accumulator. Indirect addressing allows programs to be position independent. The 6812 has direct page addressing, which is a "quick-and-dirty" index-addressing mode. Index addressing is especially useful for jumping to nearby locations. If we want to move data around in memory during execution of a program, indirect addressing is the only mechanism that can efficiently access single words as well as arrays.


40 |
Chapter 1 Microcomputer Architecture |
8. Suppose a memory is filled, except for the program that follows, like this: the word at address $WXYZ is $YZ (for example, location $2538 has value $38).Assumingthat an address in X never points to the program, what will the value of X be after each instruction is executed in thisprogram?
LDX #$1
LDX 0,X
LDX 4,X
9. Suppose the condition code register is clear and the ADDA APLHA instruction is executed. Give the value in the condition code register if
a.Accumulator A is $77, ALPHA is$77.
b.Accumulator A is $C8, ALPHA is$77.
c.Accumulator A is $8C, ALPHA is$C8.
d.Repeat part c for SUBA ALPHA.
10.Explain under what conditions the H, N, Z, V, and C bits in the condition code register are set.Also explain the difference between overflow and carry.
11.If the accumulator Acontains the value $59 and ALPHA contains the value $6C,what will be the value of the condition code register after the following instructions? (Assume the condition code register is clear before each instruction.)
a.ADDA ALPHA
b. SUBA ALPHA
C, TSTA
d.COMA
e.BITA ALPHA f.EORA ALPHA
12.Repeat problem 11, assuming that the accumulator Acontains the value $C9, ALPHA contains the value $59,and the condition code register is set to the value $FF before each instruction.
13.Give the shortest 6812 instruction sequences that perform the same operation as the following nonexistent 16-bit 6812instructions. State whether the condition codes are set properly ornot.
a. ASRD (shift Dright arithmetically) c. NEGD (negate accumulator D)
b. INCD ALPHA (increment 16-bit ALPHA) d. DECD ALPHA (decrement 16-bit ALPHA)
e.MULS (multiply signed 8-bit A times 8-bit B to get 16-bit result in D)
14.Give the shortest 6812 instruction sequences to implement 32-bit arithmetic operations for each case given below. In each case, the data arrive in register Y(high 16 bits) and register D(low 16 bits), and are returned in the same way.

Problems |
|
41 |
a. Complement b. Increment |
c. Decrement |
d. Shift right logical |
e. Shift right arithmetic |
f. Shift left (arithmetic or logical) |
15. Explain, in terms of condition code bits, when the branch is taken for the following conditional branchinstructions:
a. BEQ
b.BGT C. BHI
d.BHS C. BLE
f.BPL
16.How many times does the following loop get repeated when the instruction CND is
a.BNE?
b.BPL?
C. BLT?
LDAA #200
LOOP : statement list
DECA
CND |
LOOP |
Show calculationsor explain your answers.
17. What is the value of accumulator B after the following program ends, when the instruction COND is
a.BEQ?
b.BMI?
C,BGT?
d. BVS?
LDAA #200
CLRB
LOOP: DECA
COND EXIT
INCB
BRA LOOP
EXIT: SWI
Show calculations or explain answers.
18. Convert the following high-level programming language construct into the shortest 6812 assembly-language instructions, assuming that the variable A is already assigned to the accumulator A. As long as the expression in the while statement is true, the statements inside braces are repeated.


