Looking for AVR Opcode Table

Go To Last Post
27 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does anyone know where I can find a table of AVR instructions listed by opcode? I'm trying to do some manual dissassembly of a hex dump here at work and Atmel's AVR Instruction set pdf lists the opcodes in binary throughout the text.

Thanks

Andrew Beard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search the Atmel site: www.atmel.com

Real men don't use backups, they post their stuff on a public ftp server and let the rest of the world make copies.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The closest thing I've been able to come up with so far on Atmel's site has been their instruction set PDF. Unfortunatly, this doesn't have an opcode table, just an instruction mnemonic table with no opcodes.

Andrew Beard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Look in the Internet to REAVR. (Disassembler)
Also you can use Studio and Dissassembler window to get Opcodes

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When you read through that document you'll discover there are quite some instructions with the same opcode and are really aliases ;)

I've never seen an opcode matrix for the AVR like there is for the Z80, 6502 etc. I guess this is because the opcode format is not really structured and a matrix would be too difficult to use then. And a list of 65536 opcodes is no fun either.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Assemble all possible opcodes, parse the list file into a spreadsheet, sort it.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What a tedious, mind numbing job :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

download the AVR instruction reference from atmels site.
Products->AVR->Ducumentation->other documents

User Guide AVR Instruction Set (148 pages, updated 8/02)

it containes the opcodes for all AVR instructions...

Best regards:
Magnus

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

I've never seen an opcode matrix for the AVR like there is for the Z80, 6502 etc.

Quote:

Assemble all possible opcodes, parse the list file into a spreadsheet, sort it.

Quote:

What a tedious, mind numbing job

Almost all of the above is true. I >>have<< seen an instruction matrix for AVRs. Someone did the work of creating it, and posted it in a thread a year or two ago. IIRC, it was in relation to either which instructions had aliases, or whether 0xffff opcode was really equivalent to NOP. For the life of me, I cannot search out the thread.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since the only hammer I have is C, I would attack this nail by writing a c program that generated a hex file full of hex opcodes, and feed that thru the assembler. Not so mindnumbing really.... the computer does all the work... no typing or anything, except for the C program, which is my hammer of choice.

Imagecraft compiler user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Try this: www.atmel.com/dyn/resources/prod...

You can load an Intel hex file in to AVR Studio and see and step through a disassembled listing.

Hope this helps.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Almost all of the above is true. I >>have<< seen an instruction matrix for AVRs. Someone did the work of creating it, and posted it in a thread a year or two ago. IIRC, it was in relation to either which instructions had aliases, or whether 0xffff opcode was really equivalent to NOP. For the life of me, I cannot search out the thread.

Lee

Yeah, there is so much good information here but it is difficult to get to. A wiki would really help to put an end to asking the same questions over and over again. Actually, if it were possible to search a phrase using "phrase text", that would help too.

The forum is great but, there are some better tools to answering the repeat questions and organize information. No one likes to answer the same question more than twice.

Is there a wiki out there that caters to the AVR?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
AVR opcodes by Jeremy Brandon

Most are single 16 bit words; four marked * have a second word
to define an address or address extension (kkkk kkkk kkkk kkkk)

  d  bits that specify an Rd (0..31 or 16..31 or 16..23 or 24..30)
  r  bits that specify an Rr ( - ditto - )
  k  bits that specify a constant or an address
  q  bits that specify an offset
  -  bit that specifies pre-decrement mode: 0=no, 1=yes
  +  bit that specifies post-decrement mode: 0=no, 1=yes
  x  bit of any value
  s  bits that specify a status bit (0..7)
  A  bits that specify i/o memory
  b  bits that define a bit (0..7)

Note: all bits shown as . are the same as in the row above.

0000 0000 0000 0000  NOP
.... 0001 dddd rrrr  MOVW
.... 0010 dddd rrrr  MULS
.... 0011 0ddd 0rrr  MULSU
.... .... 0... 1...  FMUL
.... .... 1... 0...  FMULS
.... .... 1... 1...  FMULSU
.... 01rd dddd rrrr  CPC
.... 10.. .... ....  SBC
.... 11.. .... ....  ADD
0001 00.. .... ....  CPSE
.... 01.. .... ....  CP
.... 10.. .... ....  SUB
.... 11.. .... ....  ADC
0010 00.. .... ....  AND
.... 01.. .... ....  EOR
.... 10.. .... ....  OR
.... 11.. .... ....  MOV
0011 kkkk dddd kkkk  CPI
0100 .... .... ....  SBCI
0101 .... .... ....  SUBI
0110 .... .... ....  ORI
0111 .... .... ....  ANDI
1000 000d dddd 0000  LD Z
.... .... .... 1...  LD Y
10q0 qq0d dddd 0qqq  LDD Z
.... .... .... 1...  LDD Y
.... ..1. .... 0...  STD Z
.... .... .... 1...  STD Y
1001 000d dddd 0000  LDS *
.... .... .... 00-+  LD –Z+
.... .... .... 010+  LPM Z
.... .... .... 011+  ELPM Z
.... .... .... 10-+  LD –Y+
.... .... .... 11-+  LD X
.... .... .... 1111  POP
.... 001r rrrr 0000  STS *
.... .... .... 00-+  ST –Z+
.... .... .... 01xx  ???
.... .... .... 10-+  ST –Y+
.... .... .... 11-+  ST X
.... ...d dddd 1111  PUSH
.... 010d dddd 0000  COM
.... .... .... 0001  NEG
.... .... .... 0010  SWAP
.... .... .... 0011  INC
.... .... .... 0100  ???
.... .... .... 0101  ASR
.... .... .... 0110  LSR
.... .... .... 0111  ROR
.... .... .... 1010  DEC
.... 0100 0sss 1000  BSET
.... .... 1... ....  BCLR
.... .... 0000 1001  IJMP
.... .... ...1 ....  EIJMP
.... 0101 0000 1000  RET
.... .... .... 1001  ICALL
.... .... 0001 1000  RETI
.... .... .... 1001  EICALL
.... .... 1000 1000  SLEEP
.... .... 1001 ....  BREAK
.... .... 1010 ....  WDR
.... .... 1100 ....  LPM
.... .... 1101 ....  ELPM
.... .... 1110 ....  SPM
.... .... 1111 ....  ESPM
.... 010k kkkk 110k  JMP *
.... .... .... ..1.  CALL *
.... 0110 kkdd kkkk  ADIW
.... 0111 .... ....  SBIW
.... 1000 AAAA Abbb  CBI
.... 1001 .... ....  SBIC
.... 1010 .... ....  SBI
.... 1011 .... ....  SBIS
.... 11rd dddd rrrr  MUL
1011 0AAd dddd AAAA  IN
.... 1..r rrrr ....  OUT
1100 kkkk kkkk kkkk  RJMP
1101 .... .... ....  RCALL
1110 kkkk dddd kkkk  LDI
1111 00kk kkkk ksss  BRBS
.... 01.. .... ....  BRBC
.... 100d dddd 0bbb  BLD
.... 101. .... ....  BST
.... 110r rrrr 0bbb  SBRC
.... 111. .... ....  SBRS
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You found it, Izotech!

I tried searching again using the "hints" from your quote, and >>still<< cannot find the original post.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks Izotech, that's perfect. A copy of this one's going up on my cube wall.

Andrew Beard

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

there are some instructions with the same OPCode.
SBR is done with ORI (Which is exactly the same)
CBR is done with ANDI (but with 255-value)
CLR is done with EOR rd, rd
maybe there are others.

Klaus
********************************
Look at: www.megausb.de (German)
********************************

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Andrew,
Out of curiosity, did you graduate from Urbana High? I went to school with a guy named Andrew Beard who I could easily see getting into embedded systems, and I'm wondering if you're him. If not, sorry for the bother.

Cheers,
Ryan Spicer

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You are responding to a 9 year old thread.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I know. But look what the answer :-) !

Maybe someone else is looking for. Might be useful.

Last Edited: Mon. Sep 29, 2014 - 04:36 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks, that's a useful looking resource (especially for those writing instruction simulators or disassemblers etc).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Search using the keywords (AVR, Jeremy, Brandon) and you'll find several hits for a concise numerical listing of the AVR instruction set.

Don Kinzer
ZBasic Microcontrollers
http://www.zbasic.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Found a hypertext-rendition at http://lyons42.com/AVR/Opcodes/AVRAllOpcodes.html.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

abeard wrote:

... I'm trying to do some manual dissassembly of a hex dump here at work ....

 

Try this ?

 

https://www.avrfreaks.net/forum/h...

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a ten year old thread that was picked up last year with a useful link and that link reposted today.  Can I suggest people read the thread before posting?

 

David

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

I'd post on that thread but need to wait a few years for comedic timing.

 

David