Docsity

Addressing Modes in Microprocessors: AVR Instructions - Prof. Stephen Kuyath, Study notes of Microprocessors

Partial preview of the text

Download Addressing Modes in Microprocessors: AVR Instructions - Prof. Stephen Kuyath and more Study notes Microprocessors in PDF only on Docsity!

Introduction to Microprocessors

Topic 3

Addressing Modes

Objectives

  • Examine the addressing modes of the AVR
    • Register Direct
      • Single Register
      • Two Registers
    • I/O Direct
    • Immediate
    • Data Direct
    • Data Indirect
    • Indirect Program Addressing
    • Relative Program Addressing
  • Examine some simple instructions of the AVR

Addressing Modes

  • The instructions for a microcontroller can be

categorized in several ways:

  • How the instructions access the data
  • How the instructions operate on the data
  • What is the intention, or purpose, of the instruction:
    • Examples:
      • Adding two numbers
      • Controlling the flow of the program

Source Files/Instruction Format

  • Programmers write assembly (or C) language program
    • Use a text editor
    • Use the IDE
  • In assembly, the source file has four fields to enter

information:

  • Label (optional)
  • Instruction (or Mnemonic)
  • Operand
  • Comment (optional)
  • A space (or tab) character delineates the fields

Register Direct

  • Register Direct (single operand):
    • Instructions can operate on any of the 32 registers
      • The group of 32 registers are referred to as the Register File
    • The microcontroller:
      • Reads the data in the register
      • Operates on the data in the register
      • Stores the results back in the register
    • Format: 15 4 0
Op Code (Operation code) Register
11 bit Op Code 5 bit register ID
16 bit instruction

Register Direct

  • Examples:
result: com r4 ; compliment the contents of r
inc r15 ; increment the contents of r15 by 1
clr r2 ; clear the contents of r2- all 0s in r
poodu: lsl r9 ; shift the contents of r9 1 position to the left

Note that some examples have labels, some do not (labels are optional); and there is only one operand in each of these instructions

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

Program Counter points to
the instruction to be
executed (the instruction is
in Flash Program
Memory).
Instruction: COM r

Select Register

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The Control Register
instructs the Flash
Program Memory to pass
the information in that
address to the Instruction
Register (Remember, this
is just a group of 1s and
0s, so it can be called data,
although in this case the
โ€œdataโ€ is an
instruction)
Instruction: COM r

Select Register

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The Instruction Register
passes the instruction to
the Instruction Decoder
Instruction: COM r

Select Register

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The instruction decoder
initiates the correct micro-
code program to execute
the instruction.
Instruction: COM r

Select Register

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

In this case, the Micro-
Code instructs the Control
Register to select r2 and
pass the contents of r2 to
the ALU
Instruction: COM r

Select Register

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The data is passed to the
ALU
Instruction: COM r

Select Register

ALU

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The ALU compliments the
data โ€ฆ.
Instruction: COM r

Select Register

ALU

ALU

Executing Instructions

Flash Program Memory

PC

Instruction Register

Instruction Decoder

Data Registers

CCR

Control Register

Micro-code Program Area

Accumulator

The ALU compliments the
data and stores the results
in the Accumulator.
The CCR bits are SET or
RESET according to the
result.
Instruction: COM r

Select Register