Top Banner
Introduction to the PIC Assembly Language CP316 Assembly Language Programming Terry Sturtevant Wilfrid Laurier University November 8, 2017 Terry Sturtevant CP316 Assembly Language Programming
83

CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Mar 06, 2018

Download

Documents

dotuyen
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
Page 1: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language

CP316Assembly Language Programming

Terry Sturtevant

Wilfrid Laurier University

November 8, 2017

Terry Sturtevant CP316 Assembly Language Programming

Page 2: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 3: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields

→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 4: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3

→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 5: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands

→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 6: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10

→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 7: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8

→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 8: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9

assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 9: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives

→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 10: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4

assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 11: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Introduction to the PIC Assembly Language

instruction fields→ Section 2.3→ Section 20.0language operands→ Section 1.10→ Section 1.8→ Section 1.9assembler directives→ Section 2.4assembler directives vs. language instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 12: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compilerdo not become lines of codelanguage instructionsfor the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 13: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directives

for the compilerdo not become lines of codelanguage instructionsfor the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 14: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compiler

do not become lines of codelanguage instructionsfor the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 15: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compilerdo not become lines of code

language instructionsfor the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 16: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compilerdo not become lines of codelanguage instructions

for the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 17: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compilerdo not become lines of codelanguage instructionsfor the microprocessor

become lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 18: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

assembler directives vs. language instructions

assembler directivesfor the compilerdo not become lines of codelanguage instructionsfor the microprocessorbecome lines of code

Terry Sturtevant CP316 Assembly Language Programming

Page 19: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

sample code

h e r e andwf SSPCON2 ,W ; s t u f faddwf TMR0LCOPY, F , A

Terry Sturtevant CP316 Assembly Language Programming

Page 20: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

sample code

h e r e andwf SSPCON2 ,W ; s t u f faddwf TMR0LCOPY, F , A

Terry Sturtevant CP316 Assembly Language Programming

Page 21: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 22: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

here

optional labelandwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 23: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional label

andwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 24: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwf

commandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 25: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommand

SSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 26: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2

file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 27: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register

,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 28: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,F

destination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 29: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W)

,Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 30: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W),A

access bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 31: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR

;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 32: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;

comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 33: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instruction fields

hereoptional labelandwfcommandSSPCON2file register,Fdestination (F or W),Aaccess bank; i.e. no BSR;comment after this

Terry Sturtevant CP316 Assembly Language Programming

Page 34: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 35: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization

→ Section 2.6→ Section 1.5.4looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 36: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6

→ Section 1.5.4looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 37: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4

looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 38: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping

→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 39: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping→ Section 2.9

meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 40: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping→ Section 2.9meaning of “end” directive

→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 41: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 42: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Program Template

sample organization→ Section 2.6→ Section 1.5.4looping→ Section 2.9meaning of “end” directive→ Section 2.11 (bad example)

Terry Sturtevant CP316 Assembly Language Programming

Page 43: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9FSRssample instructions→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 44: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes

→ Section 1.9FSRssample instructions→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 45: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9

FSRssample instructions→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 46: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9FSRs

sample instructions→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 47: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9FSRssample instructions

→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 48: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9FSRssample instructions→ Section 1.10

result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 49: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Instructions

addressing modes→ Section 1.9FSRssample instructions→ Section 1.10result destination operands

Terry Sturtevant CP316 Assembly Language Programming

Page 50: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto→ Section 2.9.2$ = current instruction1 word instructions, except for movff, goto, call,lfsrskip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 51: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto

→ Section 2.9.2$ = current instruction1 word instructions, except for movff, goto, call,lfsrskip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 52: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto→ Section 2.9.2

$ = current instruction1 word instructions, except for movff, goto, call,lfsrskip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 53: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto→ Section 2.9.2$ = current instruction

1 word instructions, except for movff, goto, call,lfsrskip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 54: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto→ Section 2.9.2$ = current instruction1 word instructions, except for movff, goto, call,lfsr

skip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 55: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Branch Instructions

bra vs. goto→ Section 2.9.2$ = current instruction1 word instructions, except for movff, goto, call,lfsrskip instructions

Terry Sturtevant CP316 Assembly Language Programming

Page 56: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlwhardware stack→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 57: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall

→ Section 2.9.2return vs. retlwhardware stack→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 58: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2

return vs. retlwhardware stack→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 59: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlw

hardware stack→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 60: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlwhardware stack

→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 61: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlwhardware stack→ Section 1.5.4

→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 62: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlwhardware stack→ Section 1.5.4→ Section 4.7

subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 63: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines

call vs. rcall→ Section 2.9.2return vs. retlwhardware stack→ Section 1.5.4→ Section 4.7subroutines vs. macros

Terry Sturtevant CP316 Assembly Language Programming

Page 64: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1fast register stack→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 65: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers

→ Section 4.7.1fast register stack→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 66: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1

fast register stack→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 67: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1fast register stack

→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 68: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1fast register stack→ Section 4.7.5

return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 69: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1fast register stack→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 70: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Subroutines (continued)

shadow registers→ Section 4.7.1fast register stack→ Section 4.7.5return FAST

Terry Sturtevant CP316 Assembly Language Programming

Page 71: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Data in Program Memory

tblrd vs. lfsr→ Section 2.10tblptrl, tblptrh, tblptru

Terry Sturtevant CP316 Assembly Language Programming

Page 72: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Data in Program Memory

tblrd vs. lfsr

→ Section 2.10tblptrl, tblptrh, tblptru

Terry Sturtevant CP316 Assembly Language Programming

Page 73: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Data in Program Memory

tblrd vs. lfsr→ Section 2.10

tblptrl, tblptrh, tblptru

Terry Sturtevant CP316 Assembly Language Programming

Page 74: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Data in Program Memory

tblrd vs. lfsr→ Section 2.10tblptrl, tblptrh, tblptru

Terry Sturtevant CP316 Assembly Language Programming

Page 75: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Data in Program Memory

tblrd vs. lfsr→ Section 2.10tblptrl, tblptrh, tblptru

Terry Sturtevant CP316 Assembly Language Programming

Page 76: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Other Instructions

logical instructions→ Section 2.11rotate instructions; ( nc vs. c )→ Section 2.13

Terry Sturtevant CP316 Assembly Language Programming

Page 77: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Other Instructions

logical instructions

→ Section 2.11rotate instructions; ( nc vs. c )→ Section 2.13

Terry Sturtevant CP316 Assembly Language Programming

Page 78: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Other Instructions

logical instructions→ Section 2.11

rotate instructions; ( nc vs. c )→ Section 2.13

Terry Sturtevant CP316 Assembly Language Programming

Page 79: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Other Instructions

logical instructions→ Section 2.11rotate instructions; ( nc vs. c )

→ Section 2.13

Terry Sturtevant CP316 Assembly Language Programming

Page 80: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Other Instructions

logical instructions→ Section 2.11rotate instructions; ( nc vs. c )→ Section 2.13

Terry Sturtevant CP316 Assembly Language Programming

Page 81: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Timing Loops

instruction time→ Section 1.7

Terry Sturtevant CP316 Assembly Language Programming

Page 82: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Timing Loops

instruction time

→ Section 1.7

Terry Sturtevant CP316 Assembly Language Programming

Page 83: CP316- Assembly Language Programmingdenethor.wlu.ca/cp316/lectures/assemblybeam.pdf · Introduction to the PIC Assembly Language Program Elements Introduction to the PIC Assembly

Introduction to the PIC Assembly Language Program Elements

Timing Loops

instruction time→ Section 1.7

Terry Sturtevant CP316 Assembly Language Programming