1

I was surprised when I couldn't find an old post where someone asked this question. Seems like a natural beginner, uh excuse me, "newbie" question, but then I'm a throw-back to the days when a home computer came with 3,583 bytes (three-thousand, five-hundred eighty-three). So again, as seen in the title, can I "list" my sketch? I'm pretty sure the answer is NO since if it were a good question someone would have asked it already. It just strikes me as odd that my old VIC-20 could do something this phenomenal techno-marvel can't. Not much of an accomplishment for the dinosaurs, but HEY! We're on the scoreboard now! [nothing's worse than that miserable goose-egg :( ]

5
  • What is the problem you are trying to solve? You have an Arduino and you want to "list" its contents? Jan 15, 2017 at 16:48
  • I was surprised when I couldn't find an old post where someone asked this question. -- How about the first in the "Related" list...?
    – Majenko
    Jan 15, 2017 at 16:56
  • Sorry about that, I really hate posting nuisance threads. I almost always prefer to find a good answer and be on my way. I so don't want to be the that type of person who wont put in any effort. I know I can't see you or will ever meet you, but I find it embarrassing, unpleasant, uncomfortable, unnerving, and unsettling when I bring down the room or step on someone's leisure. I should have dug more, and not been so hasty when going through the search results. But most annoying to me, was dropping the ball when trying to articulate what I wanted, which wasn't LIST or PRINT, but DOWNLOAD! sorry
    – user16841
    Jan 15, 2017 at 19:03
  • If you can't find your answer whilst searching it is often easier to start typing out your question. While you are doing so the system is constantly analysing what you are asking and offers you suggestions. Because you put so much more detail into a question than you do into a search box those can often be far better results than a simple search. Especially when search really relies on you knowing what to search for in the first place, which isn't always the case.
    – Majenko
    Jan 15, 2017 at 23:06
  • And anyway, when I'm around the room can't get any lower ;)
    – Majenko
    Jan 15, 2017 at 23:11

1 Answer 1

3

No. the code burned in an Arduino is compiled not interpreted like Basic.

Basically your C language sketch is compiled into AVR assembly language. The resulting hexadecimal is what is burned to the Arduino.

Yes you could disassemble the hex like we used to do in the good old days, but as before it is highly unpredictable and most of the time not very useful.

Just a quick example. The following simple Arduino sketch that just sets a pin in output and then sets it HIGH:

void setup() {
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
}

void loop() {
}

The resulting hex file is 3.5Kb.This include various sections of data and code. One would have to analyse the section, convert the hex (op-code) to assembly language and find which part correspond to the C code.

It is possible, and there are probably tools that do a fairly good job. Would the C language generated by the decompilation once recompile perform exactly like the original compiled cole. I doubt it.

4
  • Hmmm, I'm intrigued! I love a fool's errand (sometimes). Just out of curiosity then, could you briefly outline the disassembly process, and perhaps some idea in broad terms what makes this unpredictable and the obstacles that prevent useful results. I have not Idea what I'm asking of you, so please forgive me if this is an imposition. I know I'd be less than receptive to someone wanting to know what the average mass of a fastener was in my collection of old machine screws!
    – user16841
    Jan 15, 2017 at 18:35
  • Well, you have to take the hex codes (called op-code) and convert that to assembly language. Then you have to match the part of assembly language and find what they would represent in C. Jan 15, 2017 at 19:14
  • edited my answer to provide more details. Jan 15, 2017 at 19:23
  • Regarding the disassembly process see my answer here.
    – Nick Gammon
    Jan 15, 2017 at 21:30