STD Surveillance 2001 Adapted from CDC by Jill Gallin, CPNP Assistant Professor of Clinical Nursing.
Module 10 Adapted By and Prepared James Tan © 2001.
-
Upload
christian-lee -
Category
Documents
-
view
212 -
download
0
Transcript of Module 10 Adapted By and Prepared James Tan © 2001.
Module 10
Adapted By and Prepared James Tan © 2001
Objectives
• In this lecture we will be looking at :
• Addressing Mode
• Typical fetch & execute cycle in a CPU
10.1 Assembly Programming Techniques
• The specified address should be as short as possible Less time & space
• For table of data Use index method.
10.2 Addressing Mode
Direct Addressing The operand address field contains the address of the
operand.• Example:
• LOCN 03:OPCODE 1001 0110 (96) (LDA)
• LOCN 04:OPERAND 0000 0000 (00)
• Two limitations
– Need 2 bytes of code
– Not efficient for processing data arrays or tables, as it can only access a single fixed address at one time no good for scanning table of data.
Page Addressing
• Consider ADD 2007• Direct addressing can be improved by using 2
registers:– Instruction Register : storing ADD 7– Page Register (in thousands) : storing 2– Effective address = 2007
• Acc Acc + (content of loc 2007)
Further development of page addressing
• Page Zero Addressing
– Although at page 4, but page bit = 0 Address = 0038
• Current Page Addressing
– Although at page 4, but page bit = 1 Address = 4038
Address Instruction Page Bit
4010 ADD 38 0
Address Instruction Page Bit
4010 ADD 38 1
10.2.2 Indirect Addressing
• The operand address field gives the address of a
memory location which contains the address of
the operand.
• Note: M6800 series does not have indirect
• Example: ADD @ 100
• @ : indirect symbol
• Meaning: go to location 100, get its contents and
use it as an address, go to that address and add its
contents to the accumulator.
10.2.3 Immediate Addressing
• The operand address field contains the operand.
• Example: ADD #4
• # : Immediate symbol
• Meaning: Add the number 4 immediately to Acc.
• Good programming habit:
– Use Constants
M = 4
LDA M
10.2.4 Indexed Addressing
• Address of Operand =
(Index Register)+(Operand Address Field)
• Related Instructions
LDX Load the index register
INX increment the index register
DEX decrement the index register
STX store the contents of index\register in
memory
Example
• ADDA $15, X
• ADDA: add to Acc
• $15: dollar sign Hex number
• X: index register contents
• Meaning: ‘add the contents of location whose address is (1516
+ index register contents) into accumulator A’.
• Consider LDA 50, X [see page 10.8 for details]
• Resultant Address is 53
10.2.5 Relative Addressing
• Address of Operand = (PC) + (Operand Address Field).
• Example: BRANCH instruction: BRA * + 5
Effect: PC = PC + 5
5 : offset
• Some factors to consider:
Negative Branch Distance: 2’s complement
PC is incremented to point to next instruction before the
calculation of branch distance takes place,
Program Example 1: Forward Branching
Address
0 BRA LOOP
1 OFFSET
2 PC ROLA
3 PSHB
4 LOOP ADD
5
• OFFSET = 2, PC = 2
• PC = PC + OFFSET = 2 + 2 4
Program Example 2: Backward Branching
Address
0 LOOP CLR
1 ASRA
2 ROLA
3 PULA
4 NOP
5 NEGA
6 BRA LOOP
7 OFFSET
8 PC
• OFFSET = negative 8 F8 in two’s complement
• PC = 8
10.2.6 & 7 Register Direct/Indirect Addressing
• Only used in CPU which supports it
Stack Addressing
• Uses Stack Pointer (SP)
• Has Push and Pop operations
• Consider Page 10.10
• SP = 100, Acc A = 5610 Acc B = 3110
• Push A Location 100 = 56
SP = 99
Push B
• See End result at page 10.11
• Question: How about result of the following instructions?
Pop A
Pop B
10.3 Fetch & Execute Cycle
See File: CE_10B.ppt
End of Lecture