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 :( ]
1 Answer
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.
-
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!– user16841Jan 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
-
-
I was surprised when I couldn't find an old post where someone asked this question.
-- How about the first in the "Related" list...?