Lecture05_06

Download Report

Transcript Lecture05_06

ELE2MIC Friday Lecture Venue Change
• From Mon 13 August 2007
Lectures previously held in
PW101 are moving to
PW215.
• Not Glenn college as previously
advised. Please pass this on to
your fellow students.
ELE2MIC Lectures Week 4.
• ELE22MIC Lectures 7 and 8
• Binary Arithmetic Revision:
– ALU and Multiplexors
• Introduction to AVR Instruction set :
Registers, Load, store, Add, Set & Clear
bit, Instruction Set Overview
– Addressing Modes
– Add, Push, Pull, Jump
– Conditional Jumps
NAND GATE
AVR Assembler
(0)
AVR Assembly Language is a mnemonic language
aimed at making it more straight- forward to
command the micro-controller to perform a
sequence of instructions.
Basic instructions are broken down into 2 or more
parts:
1. The OpCode - this says what to do
2. The Operands - and what to do it to.
3. Ancillary functions
AVR Assembler
(1)
For example, if register r22 = $7F then the instruction:
inc
r22
1. inc is the increment OpCode
The Operation Code
2. r22 is the Operand = What to do it to
r22 is the destination
after instruction execution r22 = $80
AVR Assembler
(2)
For example, if register r0 = $34, r1 = $21 and the
carry flag was set (I.e = 1), then:
adc r0, r1
1. adc is the OpCode
Operation Code
2. r0 and r1 are the Operands
r0 is the destination
r1 is the (other) source
after the execution of the instruction r0 = $56
Register r1 would be unchanged and still equal $21
The carry flag would also be set to a 0
AVR Assembler
(0)
Assembly Directives
The assembler supports a number of directives
making the application development easier. In
addition to the directives for
macro generation and control, the assembler contains
directives for:
• Including files. Included files can be nested.
• Set program origin.
• Symbol usage. The user can define symbols and
labels and refer to these throughout the assembly
program.
• Constant data initialization. The user can do