1 68HC11 Programming 68HC11 Programming Model & Addressing Model & Addressing Modes Modes Notes: Tests will be returned in your studios. Grades will be up by tonight. Today: • First Hour: HC11 Programming model – Section 1.1-1.5 of Huang’s Textbook – In-class Activity #1 • Second Hour: Addressing Modes • Section 1.6-1.7 of Huang’s Textbook – In-class Activity #2
68HC11 Programming Model & Addressing Modes. Notes: Tests will be returned in your studios. Grades will be up by tonight. Today: First Hour : HC11 Programming model Section 1.1-1.5 of Huang’s Textbook In-class Activity #1 Second Hour : Addressing Modes - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
68HC11 Programming 68HC11 Programming Model & Addressing Model & Addressing
ModesModesNotes: Tests will be returned in your studios. Grades will be
ProgrammingProgramming• “Program” is the sequence of instructions which
serves as input to the control FSM of the computer.
• “Machine instruction” is a sequence of binary digits which can be executed by the processor
• “Assembly language” : assembly instructions
–An assembly instruction is a mnemonic representation of a machine instruction
–Assembly programs must be translated before it can be executed: translated by an assembler
• “High-level language”: syntax similar to English
–A translator is required to translate the program written in a high-level language to machine language: compiler
4
Programming ModelProgramming ModelProgramming ModelProgramming Model
Toy Programmer’s ViewToy Programmer’s View
What does a programmer
need to know to program the computer?
What does a programmer
need to know to program the computer?
2. RegistersRegisters3. Instruction SetInstruction Set
1. Memory ModelMemory Model
Registers such as MAR and MBR are “invisible” to the programmer
AC (16 bits)
PC (14 bits) Memory
(16 bits wide,
14-bit address)
List of
Instructions
5
Toy InstructionsToy Instructions
16-bit Accumulator
14-bit Program Counter
15 AC 0
13 PC 0
RegistersRegistersRegistersRegisters
What registers
do we need?
What registers
do we need?
Mnemonic Operation Op-code
LOAD mem<qhhh> -> AC 00
STORE AC -> mem<qhhh> 01
ADD AC + mem<qhhh> -> AC 10
BRN IF AC<15> =1 THEN qhhh -> PC 11
6
Programming ModelProgramming ModelInstruction FormatInstruction FormatInstruction FormatInstruction Format
How many bits are needed for the OpCode?
22
How many bits are needed to access any memory location?
1414
16-bit Instruction16-bit Instruction
2-bit OpCode2-bit OpCode
OPOP OPERANDOPERAND
14-bit Operand14-bit Operand
7
What bus do
we take?
What bus do
we take?
Toy Programming ModelToy Programming ModelInstruction SetInstruction SetInstruction SetInstruction Set
Address Bus
M A R
P C
I R
Memory Address
Bus
Mnemonic Operation Op-code
LOAD mem<qhhh> -> AC 00
STORE AC -> mem<qhhh> 01
ADD AC + mem<qhhh> -> AC 10
BRN IF AC<15> =1 THEN qhhh -> PC 11
8
Introducing the M6811Introducing the M6811A “single-chip 8-bit micro-controller”– Intended to control appliances– 8-bit data bus– 16-bit address bus– Integrates many items on one chip:»Clock»CPU»RAM»ROM»Ports for External Input/Output»Several built-in Input/Output devices like
timers, serial and parallel communication
9
ROM-8KB
RAM-256 bytes
EEPROM-512 bytes
PORTA
PULSE ACCUMULATOR
PERIODIC INTERRUPT
COP WATCHDOG
PAIOC2
OC3OC4OC5
OC1
IC1
IC2IC3
PA7
PA6PA5PA4PA3PA2PA1
PA0
PE7
PE6PE5PE4
PE3
PE2
PE1PE0
PORTE
VREFH
VREFL
A/DCONVERTER
DA
TA
DIR
EC
TIO
N
PORTD
SSSCK
MOSI
MISO
SPI
TxD
RxDSCI
PD5
PD4PD3
PD2
PD1
PD0
M68HC11 CPU
ADDRESS DATA BUS
INTERRUPTS
RESET
XIRQ
IRQ(V
PPBULK) HANDSHAKE I/O
DATA DIRECTION C
PORT CPORT B
PARALLELI/O
SINGLECHIP
PB7
PB6
PB5
PB4
PB3
PB2
PB1
PB0
PC7
PC6
PC5
PC4
PC3
PC2
PC1
PC0
STRA
STRB
A15
A14
A13
A12
A11
A10
A9
A8
AD7
AD6
AD5
AD4
AD3
AD2
AD1
AD0
R/W ASEXPAND
OSCILLATOR
XTAL
EXTAL
E
MODALIR
MODB(VSTBY )
VDD
VSS
MODESELECT
POWER
M6811 Hardware ModelM6811 Hardware Model
10
Bus #1
M A R
Memory Address
Bus
A
B
M B R
Bus #2
Memory Data BusRegister File
(A, B, IX, IY, IR)
MUX
FLAGS
P C
M6811 ALUM6811 ALU
11
M6811 Memory ModelM6811 Memory ModelMemory = 64K x 8
Load ACCA with the content of memory address (EA), where
EA = IX + $28IX is called an Index Register It holds a 16-bit base address
The operand is an unsignedunsigned offset byteEA = Base + Offset
There’s another index register, IY
IND,X (indexed,X)A6 28: LDAA $28,X
Load ACCA with the content of memory address (EA), where
EA = IX + $28IX is called an Index Register It holds a 16-bit base address
The operand is an unsignedunsigned offset byteEA = Base + Offset
There’s another index register, IY
How much of the address space can we "reach" with IND,X?
256 BytesWhat is this mode good for?Addressing elements in an array
How much of the address space can we "reach" with IND,X?
256 BytesWhat is this mode good for?Addressing elements in an array
30
NeedNeed Addressing ModeAddressing Mode
Reach the first 256 RAM Directlocations quickly
Load a constant without having Immediateto first put it in memory
Access arrays of numbers Indexedefficiently, implement pointers
We’ll do array and pointer examples later...We’ll do array and pointer examples later...
What’s the big idea?What’s the big idea?All of the addressing modes were developed in response to specific needsAll of the addressing modes were developed in response to specific needs
31
Immediate OP CODE
DATA
Direct OP CODE
Address-Low00 Address-Low
Extended OP CODE
Address-High
Address-Low
Address-High Address-Low
Indexed OP CODE
Offset
Index Register
Address-High Address-Low
Effective Address
Address Mode SummaryAddress Mode SummaryOP CODE
DATA-High
DATA-Low
16-bit data
32
Do Activity #2 NowDo Activity #2 NowDue: End of Class Today.
RETAIN THE LAST PAGE(S) (#3 onwards)!!
For Next Class:• Bring Huang Textbook, & HC11 PRG
• Required Reading:– Sec 2.1-2.4, 2.8 of Huang
• This reading is necessary for getting points in the Studio Activity!