By: Dr. Hamed Saghaei

Similar documents
AT90S Bit Microcontroller with 1K bytes Downloadable Flash AT90S1200. Features. Description. Pin Configuration

APPENDIX B AVR INSTRUCTIONS EXPLAINED OVERVIEW

8-bit Instruction Set

8-Bit Microcontroller with 1K bytes In-System Programmable Flash AT90S1200. Features. Description. Pin Configuration

8-bit Instruction Set

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I) Lecturer: Sri Parameswaran Notes by: Annie Guo

AVR ISA & AVR Programming (I)

8-Bit Microcontroller with 2K Bytes of In-System Programmable Flash. AT90S2323 AT90LS2323 AT90S2343 AT90LS2343 Preliminary AT90S/LS2323.

8-Bit Microcontroller with 2K bytes Downloadable Flash. AT90S2313 Preliminary. Features. Description. Pin Configuration

AVR Instruction Set Encoding

CN310 Microprocessor Systems Design

ก AVR Microcontrollers

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22L. Preliminary

Logic Instructions and Programs READING

AVR Logical and Bitwise Instructions

AT90S Bit Microcontroller with 8K bytes Downloadable Flash. AT90S8515 Preliminary. Features. Description. Pin Configurations

University of Florida EEL 4744 Dr. Eric M. Schwartz. Page 1/11 Revision 0 20-Feb-14 Mixed C and Assembly (for Atmel XMEGA)

APPENDIX A FOR SKEE3732 LABORATORY 1 SHEET

8-bit Microcontroller with 2K bytes In-System Programmable Flash AT90S2313. Features. Description. Pin Configuration PDIP/SOIC

COMP2121: Microprocessors and Interfacing. Instruction Formats and Addressing Modes

Chapter 4: Atmel s AVR 8-bit Microcontroller Part 1 Assembly Programming

COMP2121: Microprocessors and Interfacing

Gates and flip-flops: glue logic, simple FSMs, registers Two-level PLDs: FSMs, muxes, decoders. Programmable logic devices (CSE370, CSE467)

Building A RISC Microcontroller in an FPGA. Yap Zi He

Mechatronics and Microcomputers. Stipendium Hungaricum 2018/2019 Autumn Semester Szilárd Aradi, PhD

Programming. A. Assembly Language Programming. A.1 Machine Code. Machine Code Example: Motorola ADD

AVR Control Transfer -AVR Branching

COMP2121: Microprocessors and Interfacing. AVR Assembly Programming (I) Basic AVR Instructions

AVR MICROCONTROLLER ARCHITECTURTE

COMP2121: Microprocessors and Interfacing

COMP3221: Microprocessors and Embedded Systems

COMP3221: Microprocessors and Embedded Systems

TYPES OF INTERRUPTS: -

DatasheetDirect.com. Visit to get your free datasheets. This datasheet has been downloaded by

;Compiler Options.NOLIST.INCLUDE "C:\Program Files (x86)\atmel\avr Tools\AvrAssembler2\Appnotes\m8515def.inc"

Speed and Size-Optimized Implementations of the PRESENT Cipher for Tiny AVR Devices

ECED3204: Microprocessor Part I--Introduction

8-bit Microcontroller with 1K Bytes Flash. ATtiny15L. Advance Information

instruction 1 Fri Oct 13 13:05:

Menu. Programming Models for the Atmel XMEGA Architecture (and others devices) Assembly Programming Addressing Modes for the XMEGA Instruction Set

Assembly Programming (III) Lecturer: Sri Parameswaran Notes by: Annie Guo Dr. Hui Wu

Assembly Programming (III)

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash. ATtiny22 ATtiny22L. Preliminary. Features. Description

Microcontroller Intel [Instruction Set]

8-bit Microcontroller with 8K Bytes Programmable Flash AT90C8534. Preliminary

EE 308: Microcontrollers

EE 308: Microcontrollers

Atmel AVR Microcontroller Family - Product Selection Guide

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2323 AT90LS2323 AT90S2343 AT90S/LS2323. Features.

Atmel AVR Microcontroller Family - Product Selection Guide

ECE 375 Computer Organization and Assembly Language Programming Winter 2018 Solution Set #2

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313

Module 8: Atmega32 Stack & Subroutine. Stack Pointer Subroutine Call function

AVR Microcontrollers Architecture

INSTRUCTION SET OF 8085

10-1 C D Pearson Education, Inc. M. Morris Mano & Charles R. Kime LOGIC AND COMPUTER DESIGN FUNDAMENTALS, 4e

Grundlagen Microcontroller Processor Core. Günther Gridling Bettina Weiss

!" # Today Class administration, overview of course web, and logistics What is an embedded system? What will we be doing in this class?

ECED 3204 Microprocessor Midterm Reference Solution

INSTRUCTION SET AND EXECUTION

TABLE 9-1. Symbolic Convention for Addressing Modes. Register indirect LDA (R1) ACC M[ R1] Refers to Figure 9-4. Addressing mode. Symbolic convention

AVR Assembler v Addendum to on-line help. Beta

8051 Overview and Instruction Set

Microprocessors 1. The 8051 Instruction Set. Microprocessors 1 1. Msc. Ivan A. Escobar Broitman

SOEN228, Winter Revision 1.2 Date: October 25,

INSTRUCTION SET ARCHITECTURE

ARM Assembly Language. Programming


Table 1: Mnemonics Operations Dictionary. Add Accumulators Add B to Y. Add with carry to B. Add Memory to B. Add 16-bit to D And B with Memory

(2) Explain the addressing mode of OR What do you mean by addressing mode? Explain diff. addressing mode for 8085 with examples.

DESIGN NOTE #032. AVR Boot Loader. Introduction. Overview AUTHOR: MARIANO BARRÓN RUIZ KEYWORDS: BOOT LOADER, SPM, SELF-PROGRAMMING

Lecture 20: AVR Programming, Continued. AVR Program Visible State (ones we care about for now)

The Assembly Language of the Boz 5

Programming of 8085 microprocessor and 8051 micro controller Study material

Assembly Language Programming of 8085

8-bit Microcontroller with 2K Bytes of Flash. ATtiny28L ATtiny28V. Summary

COMP2121: Microprocessors and Interfacing. Instruction Set Architecture (ISA)

AVR Assembler Examples

8085 INSTRUCTION SET INSTRUCTION DETAILS

CHW 469 : Embedded Systems

ATmega128 Assembly Language Programming

Features Utilizes the AVR Enhanced RISC Architecture AVR - High Performance and Low Power RISC Architecture 118 Powerful Instructions - Most Single Cl

Atmel AVR Microcontroller Family - Product Selection Guide

Assembly AVR Boot loader

68HC11 PROGRAMMER'S MODEL

Chapter 15. ARM Architecture, Programming and Development Tools

ENE 334 Microprocessors

MAHALAKSHMI ENGINEERING COLLEGE TIRUCHIRAPALLI

3.1 DATA MOVEMENT INSTRUCTIONS 45

8-bit Microcontroller with 2K Bytes of In-System Programmable Flash AT90S2313

Memory organization Programming model - Program status word - register banks - Addressing modes - instruction set Programming examples.

5K - 40K Gates of AT40K FPGA with 8-bit Microcontroller, up to 36K Bytes of SRAM and On-chip JTAG ICE

ST7 MICROCONTROLLER TRAINING

COSC 243. Instruction Sets And Addressing Modes. Lecture 7&8 Instruction Sets and Addressing Modes. COSC 243 (Computer Architecture)

Today s Menu. >Use the Internal Register(s) >Use the Program Memory Space >Use the Stack >Use global memory

ECE 471 Embedded Systems Lecture 5


Digital Blocks Semiconductor IP

Assembly Language Programming of 8085

Transcription:

By: Dr. Hamed Saghaei

The AVR RISC Microcontroller supports powerful and efficient addressing modes for access to the program memory (Flash) and data memory (SRAM). This section describes the different addressing modes supported by the AVR architecture and all of them are divided to 3 modes: Immediate Addressing Direct Addressing Indirect Addressing

Immediate Addressing Example 1: LDI R16, $55 OP.CODE OPERAND SUBI Rd, k Rd belong to {R0,,R31} k belong to {0,,$FF}

Direct Addressing Direct Register Addressing 1) Direct Single Register Addressing 2)Direct Two Registers Addressing I/O Direct Addressing Direct Data Addressing

1-Direct Register Addressing The operand is contained in register d (Rd). Example2: INC Rd INC R11 DEC R13

2-Direct Two Registers Addressing Operands are contained in register r (Rr) and d (Rd). The result is stored in register d (Rd). Example3: ADD Rd,Rr MOV R10,R11

Direct Data Addressing A 16-bit Data Address is contained in the 16 LSBs of a two-word instruction. Rd/Rr specify the destination or source register. Example5: LDS Rd,k STS k,rr

Data Indirect Addressing Data Indirect Addressing in SRAM 1) Constant Data Indirect Addressing 2) Data Indirect Addressing with Displacement 3) Data Indirect With Pre-Decrement 4) Data Indirect With Post-Increment Indirect Addressing in Flash (Code Memory) 1) Code Memory Constant Addressing 2) Code Memory Indirect With Post-Increment 3) Relative Program Addressing

1) Constant Data Indirect Addressing Operand address is the contents of the X, Y or the Z-register. Example6: LD Rd,X LD Rd,Y LD Rd,Z ST X,Rr ST Y,Rr ST Z,Rr

2) Data Indirect with Displacement Operand address is the result of the Y or Z-register contents added to the address contained in 6 bits of the instruction word. Example 7: LDD Rd,Z+a STD Z+a,Rr LDD R1,Z+1

3) Data Indirect With Pre-Decrement The X, Y or the Z-register is decremented before the operation. Operand address is the decremented contents of the X, Y or the Z-register. Example 8: LD Rd,-X ST -Y,Rr

4) Data Indirect With Post-Increment The X, Y or the Z-register is incremented after the operation. Operand address is the content of the X, Y or the Z-register prior to incrementing. Example9: LD Rd,X+ LD Rd,Y+ LD Rd,Z+ ST X+,Rr ST Y+,Rr ST Z+,Rr

1) Code Memory Constant Addressing Constant byte address is specified by the Z-register contents. The 15 MSBs select word address, the LSB selects low byte if cleared (LSB = 0) or high byte if set (LSB = 1). Example10: LPM Rd,Z ELPM Rd,Z 2) Code Memory Indirect With Post-Increment LPM Rd,Z+ ELPM Rd,Z+

3) Relative Program Memory Addressing Program execution continues at address PC + k + 1. The relative address k is -2048 to 2047. For RJMP and RCALL

HAMED SAGHAEI

The Assembler accepts mnemonic instructions from the instruction set. A summary of the instruction set mnemonics and their parameters is given here. For a detailed description of the Instruction set, refer to the AVR Data Book. INSTRUCTION In AVR: 1) ARITHMETIC & LOGIC INSTRUCTIONS 2) DATA TRANSFER INSTRUCTIONS 3) BRANCH INSTRUCTIONS 4) BIT AND BIT-TEST INSTRUCTIONS

ARITHMETIC INSTRUCTIONS Instructions Op.code &Operands ADD Rd, Rr Description Operation Flags(SRE G) Add without Carry Cycle Rd Rd + Rr Z,C,N,V,H 1 ADC Rd, Rr Add with Carry Rd Rd + Rr + C Z,C,N,V,H 1 ADIW Rd, K Add Immediate to Word Rd+1:Rd Rd+1:Rd + K Z,C,N,V 2 SUB Rd, Rr SUBI Rd, K Subtract without Carry Subtract Immediate Rd Rd - Rr Z,C,N,V,H 1 Rd Rd - K Z,C,N,V,H 1

ARITHMETIC INSTRUCTIONS Instructions Op.code &Operands SBC Rd, Rr SBCI Rd, K SBIW Rd, K MUL Rd,Rr Description Operation Flags(SREG) Cycle Subtract with Carry Subtract Immediate with Carry Subtract Immediate from Word Multiply Unsigned Rd Rd - Rr - C Z,C,N,V,H 1 Rd Rd - K - C Z,C,N,V,H 1 Rd+1:Rd Rd+1:Rd - K Z,C,N,V 2 R1, R0 Rd. Rr C 1 * INC Rd Increment Rd Rd + 1 Z,N,V 1

ARITHMETIC & LOGIC INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags(SREG) Cycle DEC Rd Decrement Rd Rd - 1 Z,N,V 1 OR Rd, Rr Logical OR Rd Rd v Rr Z,N,V 1 ORI Rd, K Logical OR with Immediate Rd Rd v K Z,N,V 1 EOR Rd, Rr Exclusive OR Rd Rd xor Rr Z,N,V 1 COM Rd NEG Rd One's Complement Two's Complement Rd $FF - Rd Z,C,N,V 1 Rd $00 - Rd Z,C,N,V,H 1

ARITHMETIC & LOGIC INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags(SRE G) CLR Rd Clear Register Rd Rd xor Rd Z,N,V 1 SER Rd Set Register Rd $FF None 1 SBR Rd,K CBR Rd,K TST Rd Set Bit(s) in Register Rd Clear Bit(s) in Register Test for Zero or Minus Cycle Rd Rd v K Z,N,V 1 Rd Rd ($FFh - K) Z,N,V 1 Rd Rd Rd Z,N,V 1

Instructions Op.code &Operands Description Operation Flags(SR EG) RJMP k Relative Jump PC PC + k + 1 None 2 IJMP Indirect Jump to (Z) PC Z None 2 JMP k Jump PC k None 3 RCALL k Relative Call Subroutine Cycle PC PC + k + 1 None 3 CALL k Call Subroutine PC k None 4 RET Subroutine Return PC STACK None 4 RETI Interrupt Return PC STACK I 4 CPSE Rd,Rr BRANCH INSTRUCTIONS Compare, Skip if Equal if (Rd = Rr) PC PC + 2 or 3 None 1 / 2 / 3

Instructions Op.code &Operands BRANCH INSTRUCTIONS Description Operation Flags(SRE G) Cycle CP Rd,Rr Compare Rd - Rr Z,C,N,V,H 1 CPC Rd,Rr Compare with Carry Rd - Rr - C Z,C,N,V,H 1 CPI Rd,K SBRC Rr, b SBRS Rr, b SBIC P, b SBIS P, b Compare with Immediate Skip if Bit in Register Cleared Skip if Bit in Register Set Skip if Bit in I/O Register Cleared Skip if Bit in I/O Register Set Rd - K Z,C,N,V,H 1 if (Rr(b)=0) PC PC + 2 or 3 if (Rr(b)=1) PC PC + 2 or 3 if(i/o(p,b)=0) PC PC + 2 or 3 if(i/o(p,b)=1) PC PC + 2 or 3 None 1 / 2 / 3 None 1 / 2 / 3 None 1 / 2 / 3 None 1 / 2 / 3

Instructions Op.code &Operands BRANCH INSTRUCTIONS Description Operation Flags(S REG) Cycle BRBS s, k BRBC s, k Branch if Status Flag Set Branch if Status Flag Cleared if (SREG(s) = 1) then PC PC+k + 1 if (SREG(s) = 0) then PC PC+k + 1 BREQ k Branch if Equal if (Z = 1) then PC PC + k + 1 BRNE k Branch if Not Equal if (Z = 0) then PC PC + k + 1 BRCS k Branch if Carry Set if (C = 1) then PC PC + k + 1 BRCC k BRSH k Branch if Carry Cleared Branch if Same or Higher if (C = 0) then PC PC + k + 1 if (C = 0) then PC PC + k + 1 None 1 / 2 None 1/2 None 1/2 None 1/2 None 1 / 2 None 1 / 2 None 1 / 2

DATA TRANSFER INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags(S REG) Cycle MOV Rd, Rr Copy Register Rd Rr None 1 LDI Rd, K Load Immediate Rd K None 1 LDS Rd, k Load Direct from SRAM Rd (k) None 3 LD Rd, X Load Indirect Rd (X) None 2 LD Rd, X+ LD Rd, -X LDD Rd,Y+q Load Indirect and Post-Increment Load Indirect and Pre-Decrement Load Indirect with Displacement Rd (X), X X + 1 None 2 X X - 1, Rd (X) None 2 Rd (Y + q) None 2

DATA TRANSFER INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags( SREG) Cycle STS k, Rr Store Direct to SRAM (k) Rr None 3 ST X, Rr Store Indirect (X) Rr None 2 ST X+, Rr ST -X, Rr Store Indirect and Post-Increment Store Indirect and Pre-Decrement (X) Rr, X X + 1 None 2 X X - 1, (X) Rr None 2 STD Y+q,Rr LPM Store Indirect with Displacement Load Program Memory (Y + q) Rr None 2 R0 (Z) None 3 IN Rd, P In Port Rd P None 1

DATA TRANSFER INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags( SREG) Cycle OUT P, Rr Out Port P Rr None 1 PUSH Rr POP Rd Push Register on Stack Pop Register from Stack STACK Rr None 2 Rd STACK None 2

BIT AND BIT-TEST INSTRUCTIONS Instructions Op.code &Operands Description Operation Flags( SREG) LSL Rd Logical Shift Left Rd(n+1) Rd(n), Rd(0) 0, C Rd(7). LSR Rd Logical Shift Right Rd(n) Rd(n+1), Rd(7) 0, C Rd(0) ROL Rd ROR Rd ASR Rd Rotate Left Through Carry Rotate Right Through Carry Arithmetic Shift Right Rd(0) C, Rd(n+1) Rd(n), C Rd(7) Rd(7) C, Rd(n) Rd(n+1), C Rd(0) Rd(n) Rd(n+1), n=0..6 Z,C,N,V, H Cycle Z,C,N,V 1 Z,C,N,V, H Z,C,N,V 1 Z,C,N,V 1 SWAP Rd Swap Nibbles Rd(3..0) Rd(7..4) None 1 1 1

BIT AND BIT-TEST INSTRUCTIONS Instructions Op. code &Operands Description Operation Flags( SREG) BSET s Flag Set SREG(s) 1 SREG(s) 1 Cycle BCLR s Flag Clear SREG(s) 0 SREG(s) 1 SBI P, b Set Bit in I/O Register I/O(P, b) 1 None 2 CBI P, b Clear Bit in I/O Register I/O(P, b) 0 None 2 BST Rr, b BLD Rd, b Bit Store from Register to T Bit load from T to Register T Rr(b) T 1 Rd(b) T None 1

BIT AND BIT-TEST INSTRUCTIONS Instructions Op. code &Operands Description Operation Flags( SREG) SEC Set Carry C 1 C 1 Cycle CLC Clear Carry C 0 C 1 (SEI, SES SEV, SET SHE. SEN) NOP No Operation None 1 SLEEP Sleep None 1 WDR Watchdog Reset None 1