Title: COCO, RPI, S03 Programming Model
1COCO, RPI, S03Programming Model
- Memory Model
- Registers
- Instruction Set
- Computer Operation
- Addressing Modes
2Programming Model
Tri-Bus Computer
What does a programmer need to know to program
the computer?
Programming Model
1. Memory Model
2. Registers
3. Instruction Set
3Programming Model
Memory Model
Number Notation denotes hexadecimal q 00 ..
11 h 0000 .. 1111
4Programming Model
Registers Instruction Set
5Programming Model
Instruction Format
16-bit Instruction
How many bits are needed for the OpCode? 2 How
many bits are needed to access any memory
location? 14
2-bit OpCode
14-bit Operand
6A Real Programming Model
M68HC11 Microcontroller
A microcontroller is an integrated circuit that
combines a microprocessor with other peripheral
functions, such as memories, timers and
converters.
Widely used in communication, industry control
and automotives, etc.
7M6811 Programming Model
Memory Model
Number Notation denotes hexadecimal h 0000 ..
1111
8M6811 Registers
Simplified
Carry/borrow (MSB) oVerflow (2s
C) Zero Negative Half carry (bit 3?4)
9Example Instruction
Look it up in the Programming Reference Guide!
What does this do ???
LDAA - Load Accumulator A
10LDAA Operation Details
What M6811 registers are used ???
11Example _at_ the Beginning
M6811 Registers
PC holds address of next instruction
PC
C1
20
IR
A
23
A contain values from previous write operations
121. Fetch Opcode
LDAA Example
M6811 Registers
Increment PC
PC
C1
20
21
B6
IR
A
23
132. Decode Opcode
LDAA Example
M6811 Registers
PC
C1
21
B6
IR
A
23
Decode opcode How many operand bytes? 2
Memory 64K x 8
143. Operand Fetch
LDAA Example
M6811 Registers
Increment PC
Increment PC
PC
C1
21
22
23
B6
10
IR
C2
A
23
Fetch two operand bytes
154. Instruction Execution
LDAA Example
M6811 Registers
PC
C1
23
B6
C2
10
IR
A
12
23
Get data from memory
16Instruction Operation Notation
See PRG entry for LDAA
- LDAA (opr) opr data in memory
- The Load Accumulator A instruction copies the
contents of the addressed memory register into
the accumulator - This means the contents of memory (M) replaces
the contents of accumulator A (A) - denoted by (M) ? (A)
- Motorola short-hand notation M ? A
17Instruction Set Table
Machine Code
Source Form
Boolean Expression
Bytes
Operation
Opcode
Operand
LDAA Load Accumulator A M ? A B6 hh ll 3 ADDA Add
memory to A A M ? A BB hh ll 3 STAA Store
Accumulator A A ? M B7 hh ll 3
18Machine Language Programming
Example program
- Add two 8-bit numbers N1 N2 to form an 8-bit
sum SUM - That is,
- N1 N2 ? SUM
19N1 N2 ? SUM
Program fragment
... ... LDAA C120 B6 C121 C2 C122 10 ADDA C
123 BB C124 C2 C125 11 STAA C126 B7 C127 C2
C128 12 ... ... N1 C210 12 N2 C211 34 SUM C212
FF ... ...
PC
C1
20
A
B
Let's go through it instruction by instruction
20Load Accumulator A
N1 ? A
... ... LDAA C120 B6 C121 C2 C122 10 ADDA C
123 BB C124 C2 C125 11 STAA C126 B7 C127 C2
C128 12 ... ... N1 C210 12 N2 C211 34 SUM C212
FF ... ...
PC
C1
23
A
12
B
The result of the first instruction
21Add to Accumulator A
A N2 ? A
... ... LDAA C120 B6 C121 C2 C122 10 ADDA C
123 BB C124 C2 C125 11 STAA C126 B7 C127 C2
C128 12 ... ... N1 C210 12 N2 C211 34 SUM C212
FF ... ...
PC
C1
26
A
46
B
The result of the second instruction
22Store Accumulator A
A ? SUM
... ... LDAA C120 B6 C121 C2 C122 10 ADDA C
123 BB C124 C2 C125 11 STAA C126 B7 C127 C2
C128 12 ... ... N1 C210 12 N2 C211 34 SUM C212
46 ... ...
PC
C1
29
A
46
B
The result of the third instruction
23Exercise 1
- Rewrite the program
- N1 N2 ? SUM
- so the data immediately follow the instructions.
- A. Put the first instruction at memory location
C100. - B. Use a three column table with headings
- Instruction
- Memory Location, and
- Machine Code.
24Exercise 1 Answer
- N1 N2 ? SUM
- Instruction Memory Location Machine Code
- LDAA C100 B6
- C101 C1
- C102 09
- ADDA C103 BB
- C104 C1
- C105 0A
- STAA C106 B7
- C107 C1
- C108 0B
- N1 C109 12
- N2 C10A 34
- SUM C10B FF
- Arbitrary values
25Exercise 2
- Modify the program of Exercise 1
- N1 N2 N3 ? SUM
- A. Put the first instruction at memory location
D000. - B. Use a three column table with headings
- Instruction
- Memory Location, and
- Machine Code.
26Exercise 2 Answer
Instruction Memory Machine Location Code LDAA
D000 B6 D001 D0 D002 0C ADDA D003 BB D004 D
0 D005 0D ADDA D006 BB D007 D0 D008 0E
Instruction Memory Machine Location Code
STAA D009 B7 D00A D0 D00B 0F N1 D00C 12
N2 D00D 34 N3 D00E 56 SUM D00F FF
Arbitrary values
27M6811 Addressing Model
28Sample Instruction
How did we specify the operand?
The instruction directly specifies the address
This is not the only way to do the job
29Addressing Modes
5 different ways to specify the operand!
They have different OpCodes
How do we tell these addressing modes apart?
30Address Mode Examples
IMM (immediate) 86 28 LDAA 28 Load ACCA with
the "immediate" constant 28
How much of the address space can we "reach" with
DIR? 256 Bytes What is this mode good for? Saves
Bytes Fetches
DIR (direct) 96 28 LDAA 28 Load ACCA with the
content of memory address 0028
31Address Mode Examples-2
EXT (extended) B6 C128 LDAA C128 Load ACCA
with the content of memory address C128
How much of the address space can we "reach" with
EXT? 65536 Bytes What is this mode good
for? Reaches all memory
32Address Mode Examples-3
IND,X (indexed,X) A6 28 LDAA 28,X Load ACCA
with the content of memory address (EA), where EA
IX 28 IX is called an Index Register It
holds a 16-bit base address The operand is an
unsigned offset byte EA Base Offset Theres
another index register, IY
How much of the address space can we "reach" with
IND,X? 256 Bytes What is this mode good
for? Addressing elements in an array
33Whats the big idea?
All of the addressing modes were developed in
response to specific needs
Need Addressing Mode Reach the first 256
RAM Direct locations quickly Load a constant
without having Immediate to first put it in
memory Access arrays of numbers Indexed efficien
tly, implement pointers Access all the 64K
memory Extended