Professional Documents
Culture Documents
Addressing
ASEN 4519/5519
Lecture #4
PIC Architecture
Harvard architecture
8 bits wide
12 bits wide
2^12 = 4096
15 bits wide
2^15 = 32768
Instruction bus
Operand
Address
Program
Address
12 bits
15 bits
Data bus
Program
Memory
CPU
Instruction
16 bits
Data
Operand
Memory
(SFR &
RAM)
8 bits
16 bits wide
ASEN 4519/5519
Lecture #4
RAM layout
0x000
0x080
0x100
Bank 1
Bank 0
GPR
0x200
Bank 2
GPR
0x300
GPR
Bank 3
0x400
GPR
Bank 4
0x500
GPR
Bank 5
0x600
UNUSED
0xF00
Bank 15
0xF80
0xFFF
Access RAM
GPR
ASEN 4519/5519
Lecture #4
SFR
3
Literal addressing
Direct Addressing
For moving variables (eg: movwf COUNT move the value of the working into
variable COUNT.
Access bank direct (0x000 to 0x07F)
Bank direct (0xB00 to 0xB7F)
Indirect Addressing
Variable pointers
ASEN 4519/5519
Lecture #4
ASEN 4519/5519
Lecture #4
ASEN 4519/5519
Lecture #4
ASEN 4519/5519
Lecture #4
MOVFF opcode
MOVFF instruction
Utilizes full 12 bit RAM
addresses
Can move to/from anywhere in
RAM
Requires two instruction cycles
to fetch the instruction before
execution
ASEN 4519/5519
Lecture #4
PIC Pipelining
Fetch nth instruction
Fetch n instruction
NOP
th
During two word instruction fetch the CPU is idle for one cycle
A majority of assembly operations include moving data between the
working register and RAM
Single word instructions increase system performance
Poor coding practices can directly effect performance
ASEN 4519/5519
Lecture #4
If a=1 (banked)
Upper nibble of RAM address is constructed from lower nibble of BSR
Lower byte of RAM address is constructed from instruction address byte
Requires BSR to be set correctly before instruction execution
ASEN 4519/5519
Lecture #4
10
Similar to pointers in C
Useful for accessing arrays
A variable (eg NUM=0x200), address of num is 0x00C
LFSR 0, NUM
Loads FSR0 with the value of 0x200 (2 word operand)
FSR0 is a 2 byte register (FSR0H:FSR0L)
The upper nibble of FSR0H is ignored
MOVF POSTINC0, W
Move the value stored at memory location 0x200 to WREG
Increment FSR0, now equal to 0x201
ADDWF POSTINC0, W
Add the value stored at memory location 0x201 to WREG
Keep result in WREG
Increment FSR0, now equal to 0x202
Copyright University of Colorado, 2005
ASEN 4519/5519
Lecture #4
11
ASEN 4519/5519
Lecture #4
12
ASEN 4519/5519
Lecture #4
13
TBLRD*+
Move the 8 bit value at location TBLPTRH:TBLPTRL to
TABLAT. TBLPTR is incremented
TBLRD+*
TBLPTR is first incremented then the 8 bit value at location
TBLPTRH:TBLPTRL is moved to TABLAT.
Copyright University of Colorado, 2005
ASEN 4519/5519
Lecture #4
14
STATUS register
ASEN 4519/5519
Lecture #4
15
Homework
LAB FRIDAY 09-SEP-05
ITLL Electronics shop
Install Qwikbug and QFPV using ICD module in ITLL
Show board to Bill Pisano to check operation and
workmanship in ITLL
LECTURE MONDAY 12-SEP-05
Read
Peatman Chapter 3 Instruction set
ASEN 4519/5519
Lecture #4
16