I have compiled, uploaded the following sketch and then clicked on "Export Compiled Binary" to get two .hex files (test2.ino.standard.hex, test2.ino.with_bootloader.standard.hex). I have scanned both files frame-by-frame manually; unfortunately, I do not see the expected pattern there. Am I missing anything? Any help would be highly appreciated. It is an academic need.
Let me try this explanation: The compiler takes your code as a 'flow chart' to generate a 'to do' list for the microcontroller. What you call 'byte y1' is converted to an memory address that spans the byte value (8 bits) so, you will not see 'y1' in the compiled code. 0x75 is then stored at that address. I hope this helps a little.
When I use MICROCHIP STUDIO Assembler, I can very well find the data pattern in the generated hex file; where, operand is intermixed with opcode. I have expected similar thing in the hex file produced by Arduino IDE.
If you are looking for the hex code "75" as a data value, you won't find it in the LDI assembler listing, because it is distributed as two nibbles in separate bytes of 16 bit instruction.
1. How have you produced the assembly codes in post #13? 2. Has your hex file been produced by Arduino IDE? 3. Using volatile keywords, I have compiled and uploaded the following sketch in UNO. Now, I can see the data pattern (75, near the end of hex file marked bold) being known that a data byte comes intermixed with other digits of 16-bit instruction of AVR. (Where is other 75?)
For example:
75 is an immediate data; so, I expect immediate addressing mode will be used by the Compiler. The data byte will be stored in the next flash memory location following the opcode. However, in AVR architecture, the 16-bit instruction contains opcode and operand in a different way which I call intermixed.
Therefore, 75 should be somewhere there in the hex file (not as consecutive digit; rather, being intermixed with opcode's digits) which contains the executable binary/machine codes of the sketch.