Chapter 2 - Microcontroller Architecture & Assembly Language
Chapter 2 - Microcontroller Architecture & Assembly Language
MICROCONTROLLER
ARCHITECTURE & ASSEMBLY
LANGUAGE
PROGRAMMING
PIC 12F508
PIC 16F84A
Motorola 68000
PIC 16C72
PIC 16F877
Motorola 68HC05B16
PIC18 Architecture
Von Neumann Architecture:
Fetches instructions and data from a single memory
space
Limits operating bandwidth
Von Neumann
Architecture
8-bit Bus
CPU
Program
& Data
Memory
PIC18 Architecture
Harvard Architecture:
Uses two separate memory spaces for program instructions and
data
Improved operating bandwidth
Allows for different bus widths
Harvard
Architecture
8-bit Bus
16-bit Bus
Program
Memory
CPU
Data
Memory
16 bit
2 MB
221
8 bit
4 KB
212
Registers
Bank Select Register (BSR)
4-bit register used in direct addressing the data memory
Control unit
Provides timing and control signals to various
Read and Write operations
Address bus
21-bit address bus for
program memory
addressing capacity: 2 MB
of memory
12-bit address bus for data
memory addressing
capacity: 4 KB of memory
Data bus
16-bit instruction/data bus
for program memory
8-bit data bus for data
memory
Control signals
Read and Write
WREG register
The 8-bit WREG register is the most widely used
register in the PIC micro controller.
WREG stands for working register, as there is only one.
MOVLW
The MOVLW instruction MOVES 8-bit data into the
WREG register. It has the following format:
MOVLW K
;move literal value K into WREG
MOVLW 25H ; move value 25H into WREG (WREG = 25H)
ADDLW
The ADDLW instruction ADD 8-bit data into the WREG
register. It has the following format:
ADDLW K
ADDLW 34H
Example:
MOVLW 12H
ADDLW 16H
ADDLW 32H
GP RAM
EEPROM
Register File
concept
All data memory
is part of register
file
Any location in
data memory can
be operated
directly
All peripherals
mapped into data
memory as a
series of registers
The microchip website provides the data RAM size, which is the same as
GPR size
SFR
GPR
(Bytes)
(Bytes)
(Bytes)
PIC12F508
PIC16F84
32
80
7
12
25
68
PIC18F1220
PIC18F452
PIC18F2220
PIC18F458
PIC18F8722
PIC18F4550
512
1792
768
1792
4096
2048
256
256
256
256
158
160
256
1536
512
1536
3938
1888
Example 1
C=0
DC=1
Z=0
Example 2
Show the status of the C, DC, Z flags after the
following addition instruction
MOVLW 9CH
ADDLW 64H
Solution
9CH + 64H = 100H WREG= 00H
C=1
DC=1
Z=1
8 bits
Binary B'00010010 or
Assembler Directives
Instruction
Tells the CPU what to do
Directives (pseudo-instruction)
Give directions to the assembler
START
INSTRUCTION/
ASS. DIRECTIVE
MOVLW
OPERAND
12H
COMMENT
Label:
use to represent the location of an instruction or a value no
spacing not more than 8 characters including number.
Instruction:
tells the controller what to do. Ex. MOVWF, GOTO..
Assembler directive:
tells the assembler suppose to do. Ex. EQU, ORG, END
Operand:
data to operate on / source of data to operate on and its
destination after processing.