Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

AVR Moving Data

ST - LD ( )

STACK

POP R2

MOV R16,R20
MOVW R17:R16,R21:R20

LD R20,X //also Y,Z


LD R20,X+ // same
LD R20,-X //same
LD R20,Y+2 //also Z

PUSH R4
MOV R0,R20
MOVW ...
R0

SRAM
:
R16-R25,
R26:R27 X
R28:R29 Y
R30:R31 Z

ST X,R20 //also Y,Z


ST X+,R20 // same
ST -X,R20 //same
ST Y+2,R20 //also Z
LDS R20,$F5FF

LPM //
LDI R20,$F5
PROGRAM
MEMORY

LPM R20,Z
LPM R20,Z+

IMMEDIATE
(NUMBER)
OUT PORTB,R21
OUT DDRB,R3
IN R2,PINA
I/O REGISTERS
DDRA/B/C/D
SP
etc

MOV Rb,Rn
MOVW Rb+1:Rb,Rn+1:Rn

Any Rb, Any Rn; Copy data from Rn to Rb


Rn and Rn+1 must be neighboors, same for Rb ; Copy data from Rn:Rn+1 to Rb:Rb+1

POP Rb
PUSH Rb

Any Rb; Copy data from pointed by SP address to Rb


Any Rb; Copy data from Rb to pointed by SP address

LPM
LPM Rb,Z
LPM Rb,Z+

Copy data from pointed by Z address of Program Memory to R0


Any Rb ; Copy data from pointed by Z address of Program Memory to Rb
Any Rb ; Copy data from pointed by Z address of Program Memory to Rb, increase Z after

OUT PORTA/B/C/D,Rb
OUT DDRA/B/C/D,Rb
IN Rb,PINA/B/C/D

Any Rb, Any Port ; Copy data from Rb to I/O Resgister


Any Rb, Any Port Sreg ; Copy data from Rb to I/O status Resgister
Any Rb, Any Port ; Copy data from I/O Resgister to Rb

LD Rb,X/Y/Z
LD Rb,X/Y/Z+
LD Rb,-X/Y/Z
LD Rb,Y/Z+#number

Any Rb, any pointer ; Copy data from pointed by pointer address to Rb
Any Rb, any pointer ; Copy data from pointed by pointer address to Rb, increase pointer after
Any Rb, any pointer ; Copy data from pointed by pointer address to Rb, decrease pointer before
Any Rb, pointers Y and Z ; Copy data from pointed by (pointer + #number) address to Rb ; pointer
doesnt change

ST X/Y/Z,Rb
ST X/Y/Z+,Rb
ST -X/Y/Z,Rb
ST Y/Z+#number,Rb

Any Rb, any pointer ; Copy data from Rb to pointed by pointer address
Any Rb, any pointer ; Copy data from Rb to pointed by pointer address, increase pointer after
Any Rb, any pointer ; Copy data from Rb to pointed by pointer address, decrease pointer before
Any Rb, pointers Y and Z ; Copy data from Rb to (pointed by pointer address + #number), pointer
doesnt change

LDS Rb,#number

Any Rb, #number is 16-bit ; Copy #number address of Ram to Rb

LDI Rb,#number

Rb: R16-R31,#number is 8-bit ; Copy the value of #number to Rb (immidiate)

Registers and Actions

Registers
R0
R1

LPM

MUL

...

I/O
0

R16

...

...

CBI $12,3
SBI $02,1
SBIC $10,4
SBIS $1A,2

31

R23
R24

...

SUBI R20,$3F
SBCI R17,$2A
ANDI R24,$FE
ORI R18,$01
CPI R22,$2C
LDI R20,$2A
SBR R28,$FE
CBR R30,$10
SER R31
MULS R21,R17

MULSU R23,R20
FMUL R21,R22
FMULS R21,R22
FMULSU R21,R22

R25
R26
X
R27

63
ADIW Zh:Zl,$01
SBIW R25:R24,$02

R28
R29

R30
R31

SUBI Rb,#number
SBCI Rb,#number

Rb 16-31, #number 8-bit; Rb #number ; Rb


Rb 16-31, #number 8-bit; Rb #number ; Rb

ANDI Rb,#number
ORI Rb,#number

Rb 16-31, #number 8-bit; AND Rb #number ; Rb


Rb 16-31, #number 8-bit; OR Rb #number ; Rb

CPI Rb,#number
LDI Rb,#number
SBR Rb,#number

Rb 16-31, #number 8-bit; Rb #number ; !


Rb 16-31, #number is 8-bit ; Copy the value of #number to Rb (immidiate)
Rb 16-31, #number 8-bit; Sets bits of Rb according to #number ; Rb

CBR Rb,#number
SER Rb
MULS Rb,Rn

Rb 16-31, #number 8-bit; Clear bits of Rb according to #number ; Rb


Rb 16-31; Sets all bits of Rb ; Rb
Rb 16-31, Rn 16-31; Multiplies (signed) Rn*Rb ; R1:R0

MULSU Rb,Rn
FMUL Rb,Rn

Rb 16-23(sign), Rn 16-23(unsign); Multiplies (signed) Rn*Rb ; R1:R0


Rb 16-23(uns 1.7), Rn 16-23(uns 1.7);Fractional multiplies (uns 1.15) Rn*Rb ;
R1:R0

FMULS Rb,Rn

Rb 16-23(sig 1.7), Rn 16-23(sig 1.7);Fractional multiplies (sig 1.15) Rn*Rb ;


R1:R0
Rb 16-23(sig 1.7), Rn 16-23(uns 1.7);Fractional multiplies (sig 1.15) Rn*Rb ;
R1:R0

FMULSU Rb,Rn
ADIW Rb+1:Rb,#number
SBIW Rb+1:Rb,#number
CBI #num1,#num2

Rb 24-31, #number 8-bit; Add word Rb+1:Rb with #number ; Rb+1:Rb


Rb 24-31, #number 8-bit; Sub word from Rb+1:Rb the #number ; Rb+1:Rb
#num1 0-31, #num2 is 8-bit ; Clear bits of #num1 I/O according to #num2;

SBI #num1,#num2

#num1 0-31, #num2 is 8-bit ; Set bits of #num1 I/O according to #num2;

SBIC #num1,#num2
SBIS #num1,#num2

#num1 0-31, #num2 is 8-bit ; Skips a command if #num1 I/O bits (according to #num2) are cleared
#num1 0-31, #num2 is 8-bit ; Skips a command if #num1 I/O bits (according to #num2) are set

Jump Conditions

SREG
I

BRHC
BRHS

BRIE
BRTS

Condition

BRGE
BRLT

BRTC
BRTS

Rd > Rs

BRVC

BRNE
BREQ

Signed

no:
yes:

BREQ no
BRGE yes
jump out

Unsigned

no:
yes:

BREQ no
BRSH yes
jump out

Rd >= Rs

BRGE yes

BRSH yes
or
BRCC yes

Rd == Rs

BREQ yes

BREQ yes

Rd != Rs

BRNE yes

BRNE yes

BRLT yes
BREQ yes
jump out

Rd <= Rs
yes:
Rd <Rs

BRLO yes
BREQ yes
jump out
yes:

BRLT yes

BRLO yes
or
BRCS yes

You might also like