AVRdis, the disassembler for Atmel AVR processors

AVRdis is a Free disassembler, published under the rules of the GPL. It was started in order to get familiar with the AVR opcodes and processors and to test the (then) new Mocka 0608m compiler. Both targets were met. AVRdis proved to be a reliable and flexible disassembler that will meet any processor related to the Atmel AVR line.
AVRdis consists of two parts:

  1. a universal section that dissects opcodes into mnemonics
  2. a set of configuration files, tailored for each AVR processor
The disassembler can be operated from any part of the disk, as long as the executable is in the search path. The configuration files are expected to reside in one and only one place on the disk: "/usr/local/AVR". Only root can place files there so you either need to be system administrator or at least know the root password.
The syntax of the disassembler is as follows:
    AVRdis Sourcefile -t ProcessorType -v
   
in which: AVRdis then acts as follows:
  1. set up the linked lists
  2. process the command line
  3. tell the user what's coming up (source file and target processor)
  4. try to open the requested processor specific configuration file
  5. if that fails: open ATmega8515 (the default)
  6. if that fails: abort
  7. process the parameters in the configuration file
  8. open the source and destination files
  9. process the source line by line
  10. registers use the form 'Rxx'
  11. ports are referred to by name
  12. IO port bits are referred to by name, if significant
  13. AVRdis analyzes registerpairs to determine the right one for the ambiguous mnemonics (eor versus clr)
The results are written to the destination file which has the same name as the sourcefile, but with '.lst' added.

Configuration file

AVRdis is based upon processor specific configuration files. These files have names which are as specific as possible and they are stored in one specific directory on the filesystem: "/usr/local/AVR". The layout of the files is as follows:

The keywords which are in use, are the following:

Keyword Does
FLASH The amount of Flash ROM on the AVR processor, measured in 8 bit bytes, even though the processor treats it's Flash memory as 16 bit words. This was done to remain compatible with Atmel datasheets.
EEPROM The number of bytes of EEPROM data space on the AVR processor.
SRAM The amount of bytes in the on board static RAM chip. Note, that this is the raw number, as mentioned on the datasheet. In practice there will be less bytes, since the SRAM overlaps the processor registers and ports.
PORTS A list of port numbers and port names.
BITS A list with port names, followed by (unambiguous) bit-names. Each line must have 9 entries:
  1. The port name (case sensitive) as it appears in the list above
  2. Bit 7 name
  3. Bit 6 name
  4. Bit 5 name
  5. Bit 4 name
  6. Bit 3 name
  7. Bit 2 name
  8. Bit 1 name
  9. Bit 0 name
The bit names are all uppercase. If a bit is not defined, it is represented by a dash ('-').
COMPILER A set of parameters that are processor specific, but not used by AVRdis.

The sections 'PORTS', 'BITS' and 'COMPILER' are similar to 'compound statements': their end needs to be marked by the keyword 'END'. If the END is missing, the outcome of the configuration process is not defined.

Configuration file nomenclature

Configuration files are named after their target processor. For the Atmel AT90S8515, the file is called 'AT90S8515', simple as that. Please keep in mind that Unix is case sensitive. So there is a big difference between entering 'atMEGA16' and 'ATmega16'. The way Atmel calls their processors today (October 2006) is decisive.

An example: ATmega8515

And some source codefor the processor specific file

This file contains the processor specific data for the disassembler system.

Target processor   : ATmega8515
Author 		   : Jan Verhoeven
E-mail		   : jan272@gmail.com
Date		   : October 14, 2006


BEGIN

FLASH	8192
EEPROM	512
SRAM	512

PORTS

 04	 OSCCAL
 05	 PINE
 06	 DDRE
 07	 PORTE
 08	 ACSR
 09	 UBRRL
 0A	 UCSRB
 0B	 UCSRA
 0C	 UDR
 0D	 SPCR
 0E	 SPSR
 0F	 SPDR
 10	 PIND
 11	 DDRD
 12	 PORTD
 13	 PINC
 14	 DDRC
 15	 PORTC
 16	 PINB
 17	 DDRB
 18	 PORTB
 19	 PINA
 1A	 DDRA
 1B	 PORTA
 1C	 EECR
 1D	 EEDR
 1E	 EEARL
 1F	 EEARH
 20	 UBRRH/UCSRC
 21	 WDTCR

 24	 ICR1L
 25	 ICR1H

 28	 OCR1BL
 29	 OCR1BH
 2A	 OCR1AL
 2B	 OCR1AH
 2C	 TCNT1L
 2D	 TCNT1H
 2E	 TCCR1B
 2F	 TCCR1A
 30	 SFIOR
 31	 OCR0
 32	 TCNT0
 33	 TCCR0
 34	 MCUCSR
 35	 MCUCR
 36	 EMCUCR
 37	 SPMCR
 38	 TIFR
 39	 TIMSK
 3A	 GIFR
 3B	 GICR

 3D	 SPL
 3E	 SPH
 3F	 SREG

END

BITS

 ACSR		ACD	ACBG	ACO	ACI	ACIE	ACIC	ACIS1	ACIS0
 UCSRB		RXCIE	TXCIE	UDRIE	RXEN	TXEN	UCSZ2	RXB8	TXB8
 UCSRA		RXC	TXC	UDRE	FE	DOR	PE	U2X	MPCM
 SPCR		SPIE	SPE	DORD	MSTR	CPOL	CPHA	SPR1	SPR0
 SPSR		SPIF	WCOL	-	-	-	-	-	SPI2X
 EECR		-	-	-	-	EERIE	EEMWE	EEWE	EERE
 UCSRC		URSEL	UMSEL	UPM1	UPM0	USBS	UCSZ1	UCSZ0	UCPOL
 WDTCR		-	-	-	WDCE	WDE	WDP2	WDP1	WDP0
 TCCR1B		ICNC1	ICES1	-	WGM13	WGM12	CS12	CS11	CS10
 TCCR1A		COM1A1	COM1A0	COM1B1	COM1B0	FOC1A	FOC1B	WGM11	WGM10
 SFIOR		-	XMBK	XMM2	XMM1	XMM0	PUD	-	PSR10
 TCCR0		FOC0	WGM00	COM01	COM00	WGM01	CS02	CS01	CS00
 MCUCSR		-	-	SM2	-	WRDF	BORF	EXTRF	PORF
 MCUCR		SRE	SRW10	SE	SM1	ISC11	ISC10	ISC01	ISC00
 EMCUCR		SM0	SRL2	SRL1	SRL0	SRW01	SRW00	SRW11	ISC2
 SPMCR		SPMIE	RWWSB	-	RWWSRE	BLBSET	PGWRT	PGERS	SPMEN
 TIFR		TOV1	OCF1A	OCF1B	-	ICF1	-	TOV0	OCF0
 TIMSK		TOIE1	OCIE1A	OCIE1B	-	TICIE1	-	TOIE0	OCIE0
 GIFR		INTF1	INTF0	INTF2	-	-	-	-	-
 GICR		INT1	INT0	INT2	-	-	-	IVSEL	IVCE
 SREG		I	T	H	S	V	N	Z	C

END

COMPILER
END

END
   
The sections before the initial 'BEGIN' and after the final 'END' are ignored by the configuration processors. These spaces can be used for placing comments and other information which is only relevant to humans.

Ambiguous bitnames

All bits in the port register file of the Atmel AVR line of processors have names. Most of them are extreme abbreviations of the role they play in the processor architecture. But some of the names are less descriptive than their actual bitnumber. Two examples below:

Unambiguous:    EMCUCR         SM0     SRL2    SRL1    SRL0    SRW01   SRW00   SRW11   ISC2

Ambiguous  :    PORTB          PORTB7  PORTB6  PORTB5  PORTB4  PORTB3  PORTB2  PORTB1  PORTB0
   
Let's be honest: 'sbi   PORTB, PORTB7' is less logical than 'sbi   PORTB, 7'.
Stronger still: 'sbi   PORTB, PORTB7' would indicate that 'sbi   PORTA, PORTB7' could be legal as well.

Page created on 27 October 2006 and

Page equipped with GoogleBuster technology