Title: Instruction Set
1Instruction Set
- Introduction to Microcontroller Programming
2Instruction Set
- See the Instruction Set summary in the
Programming Reference Guide (pp.13-21) - For a detailed description of each instruction
see Appendix A of the Reference Manual
(pp.487-604)
3(No Transcript)
4(No Transcript)
5Arithmetic Instructions (2)
6Arithmetic Instructions (3)
7Example 16-bit addition
8Logic Instructions
9Data Testing and Bit Manipulations
10Example
11Shift and Rotate Instructions
12Example
13(No Transcript)
14CCR Instructions
15Program Flow Control
- High level programming structures
- if-then-else
- while loop
- for loop
16if-then-else
Example in C if v2 gt v1 is_greater() else
is_less_or_equal()
Example in Assembly
ldaa v2 cmpa v1 bgt GTLABEL
jsr ISLESSOREQUAL bra
CONTINUE GTLABEL bra ISGREATER CONTINUE ISL
ESSOREQUAL ISGREATER
bra CONTINUE
17while-loop
Example in C while (v2 gt v1) task_a()
Example in Assembly
WLOOP ldaa v2 cmpa v1 bgt
TASKA bra CONTINUE TASKA
bra WLOOP CONTINUE
18for-loop
Example in C for (i 4 i lt67i)
task_a()
iinitialvalue
Example in Assembly
for (true)
ldd 4 FLOOP cpd 67 bhs
CONTINUE addd 1 bra TASKA TASKA
bra FLOOP CONTINUE
(false)
true?
ii1
19(No Transcript)
20Jump and Subroutine Instructions
21Jump Instructions
- Jump instructions specify the exact absolute
16-bit location for the next instruction (and are
not conditional) - Example
-
- START CBA compare A to B
- BEQ SKIP branch if equal
- JMP NEQ jump
- SKIP INCA increment A
-
- NEQ BRA loop here forever
22Interrupt Handling Instructions
23Miscellaneous Instructions
24Relocatable Programs
- A relocatable program is one that can start
anywhere in memory without changing the machine
code. - Branch instructions are relocatable because their
address is relative to the instruction itself. - Jump instructions are not relocatable because
their address is absolute