COCO, RPI, S03 Programming Model - PowerPoint PPT Presentation

1 / 33
About This Presentation
Title:

COCO, RPI, S03 Programming Model

Description:

COCO, RPI, S03 Programming Model – PowerPoint PPT presentation

Number of Views:37
Avg rating:3.0/5.0
Slides: 34
Provided by: badrinat
Category:
Tags: coco | rpi | bb | model | programming | s03

less

Transcript and Presenter's Notes

Title: COCO, RPI, S03 Programming Model


1
COCO, RPI, S03Programming Model
  • Memory Model
  • Registers
  • Instruction Set
  • Computer Operation
  • Addressing Modes

2
Programming 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
3
Programming Model
Memory Model
Number Notation denotes hexadecimal q 00 ..
11 h 0000 .. 1111
4
Programming Model
Registers Instruction Set
5
Programming 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
6
A 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.
7
M6811 Programming Model
Memory Model
Number Notation denotes hexadecimal h 0000 ..
1111
8
M6811 Registers
Simplified
Carry/borrow (MSB) oVerflow (2s
C) Zero Negative Half carry (bit 3?4)
9
Example Instruction
Look it up in the Programming Reference Guide!
What does this do ???
LDAA - Load Accumulator A
10
LDAA Operation Details
What M6811 registers are used ???
11
Example _at_ the Beginning
M6811 Registers
PC holds address of next instruction
PC
C1
20
IR
A
23
A contain values from previous write operations
12
1. Fetch Opcode
LDAA Example
M6811 Registers
Increment PC
PC
C1
20
21
B6
IR
A
23
13
2. Decode Opcode
LDAA Example
M6811 Registers
PC
C1
21
B6
IR
A
23
Decode opcode How many operand bytes? 2
Memory 64K x 8
14
3. 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
15
4. Instruction Execution
LDAA Example
M6811 Registers
PC
C1
23
B6
C2
10
IR
A
12
23
Get data from memory
16
Instruction 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

17
Instruction 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
18
Machine Language Programming
Example program
  • Add two 8-bit numbers N1 N2 to form an 8-bit
    sum SUM
  • That is,
  • N1 N2 ? SUM

19
N1 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
20
Load 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
21
Add 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
22
Store 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
23
Exercise 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.

24
Exercise 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

25
Exercise 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.

26
Exercise 2 Answer
  • N1 N2 N3 ? SUM

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
27
M6811 Addressing Model
28
Sample Instruction
How did we specify the operand?
The instruction directly specifies the address
This is not the only way to do the job
29
Addressing Modes
5 different ways to specify the operand!
They have different OpCodes
How do we tell these addressing modes apart?
30
Address 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
31
Address 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
32
Address 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
33
Whats 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
Write a Comment
User Comments (0)
About PowerShow.com