Material Type: Notes;
Professor: Kuyath;
Class: Intro to Microprocessors;
Subject: Electrical Engineering Tech;
University: University of North Carolina - Charlotte;
Term: Spring 2008;
Download Instruction Set - Introduction to Microprocessors | ETEE 2213 and more Study notes Microprocessors in PDF only on Docsity!
Topic 4
Instruction Set
Introduction to Microprocessors
Objectives
• Define RISC and CISC
Describe the difference
• To become familiar with the AVR instruction set
Specifically the ATmega instruction set
ATmega adds a few instructions
Examine Atmel‟s instruction set nomenclature
Examine both the Instruction Set Summary and the
more detailed documentation
The Status Register
• The Status Register
Flags
• Notation used by ATMEL to inform the
programmer that the instruction affects/does not
affect the status register bit
The Status Register
• V bit:
Set to a logic 1 if there is a 2‟s compliment overflow
as a result of the operation, otherwise 0
Example: if two positive numbers (MSb = 0) are added together and the result is a negative number (MSb = 1) - 7F + 1 = 80 (7F = 01111111, 1 = 00000001, 80 = 1000000)
Example: if two negative numbers (MSb = 1) are added together and the result is a positive number (MSb = 0) - 80 + 80 = 00 with C = 1 (80 = 1000000, 00 = 00000000)
The Status Register
• S bit:
Tests N V after the result
So if both N and V = 1, S =
If only N = 1 or if only V = 1, S =
• H bit:
Set to a logic 1 if there is a carry from b3 to b4 during
an ADD operation, otherwise 0
Other special situations set or clear H
Registers and Operands
• Notations used by ATMEL documentation
Example Instructions
• Let‟s look at a few Add instructions
Add Instructions
• ADD
The operation indicates that the values in the two registers are added and the result is stored in the destination register (Rd)
The Z, C, N, V, S, and H bits are affected by this instruction
The instruction takes one clock cycle to execute
Add Instructions
• ADC
The mnemonic is ADC
The operands are the destination register (Rd) and the source register (Rr)
The description indicates that this is an add with the carry bit
Add Instructions
• ADIW
This instruction is NOT as straightforward as the previous two instructions
The mnemonic is ADIW
The operands are the destination register (Rd) and immediate data (K) – see nomenclature on pg 11
The description indicates that this is an add immediate toword - But, what exactly does that mean?
Add Instructions
ADIW (You may be asking: exactly where did I get this
information?)
The operation indicates that the register specified (Rd) is combined with the register immediately following it (Rd+1), then ….
The 16 bit immediate data (K) is added to these two registers, then ….
The results are stored in the two combined registers » (Rd and Rd+1)
The Z, C, N, V, and S, (but not H) bits are affected by this instruction
Takes 2 clock cycles to execute
ADIW
The documentation provides more detailed information
For example …..
ADIW
This description let‟s us know that K (the immediate data) can be a number between 0 and 63
Only the uppermost 4 register pairs can be used
Must specify the “even numbered” register
Also, this instruction is not available on all AVR chips