Pages: [1]   Go Down
Author Topic: converting hex code to assembly  (Read 3729 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm interesting in converting the Hex code which is produced when I compile a program into assembly, I've heared that you need some kind of disassembly for the exact microcontroller that is being programmed. in my arduino i have atmega168. anyone knows where i can find a disassembly program for this chip?

Thanks.
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are looking to view the assembler produced by the arduino compiler, see this thread: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1207951658
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I think i got a problem:

C:\Documents and Settings\Dragonuv\Desktop\arduino-0010\hardware\tools\avr\bin>avr-objdump.exe -S c:\Blink.hex > test.txt
avr-objdump.exe: Can't disassemble for architecture UNKNOWN!

Why does this happen ?
Will the output file be seen as cpp? Can I make it be seen as assembly?

Thanks smiley
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Its the .elf file that you dump, not the hex file. The elf file contains lots of information that avr-objdump uses to mix assembly with the C source code.
« Last Edit: April 25, 2009, 06:13:53 am by mem » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 87
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Works great, thanks.

But it still leads me to the question: what does the .hex file include?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The hex file contains the runtime machine code, it's what Arduino will get when you upload a sketch. But the hex file has all of the high level information stripped out so even if you had a dissassembler you would find the output much more difficult to interpret than the output from avr-objdump.
« Last Edit: April 25, 2009, 08:28:05 am by mem » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

someone of you can tell me why when I apply the avr-objdump. exe to the .elf file it generates an empty txt file? :-?
any suggestion?
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6255
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

try running it from the command line to see if you get the exptected output:
  avr-objdump.exe -S  mysketch.elf


Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 37
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I follow your instructions in the post linked above. that's what you're suggesting me I presume, but the result is a blank txt file
Logged

Pages: [1]   Go Up
Jump to: