I have a couple of probably simple questions for you all regarding disassembly from C code to assembly code. I am using Keil uVision as a programmer and debugger with a TIVA TM4C123GXL microcontroller development board, which uses an ARM Cortex M4 microprocessor. I am single stepping through the code while in debugging mode and I don't understand a few things. Here is a screenshot of the C code I am referring too:

C code

And here is the dissembled code I am referring too:

Dissembled C code

I should say I have not got an image of the registers to go with this during debug.

  1. However, so my understanding is the values down the left-hand side (0x00000534) for example are the memory address locations that holds the current instruction. So 0x00000534 stores a branch instruction. The rightest value is then the contents of that memory address which is an immediate which points to the next address 0x0000054C?

  2. What is the 4-digit hex value shown in the disassembly window? I assume it is the instruction and opcode. So for example, in the instruction at memory location 0x0000053A, there is an add instruction. Is the instruction and opcode for this 1C40?

  3. Finally why does the program addresses start at 0x00000534? Is this because the microprocessor has a lot of initialising to do upon re-boot as it is a microcontroller with lots of programmable features, unlike say a bare metal microprocessor like a 6502?

  • 1
    \$\begingroup\$ Texas Instruments says the TIVA series is Cortex M4. What led you thinking it was Cortex M0? ARM has a sizeable vector table and C has the crt (C run time) code. To compare this with a 6502 and machine code is not a sensible comparison, ‘bare metal’ withstanding. \$\endgroup\$
    – Kartman
    Sep 30, 2022 at 10:01
  • \$\begingroup\$ @Kartman Yes you are correct, it is an ARM M4. I will edit the question. Thank you. I realise now it is not a fair comparison. \$\endgroup\$
    – David777
    Sep 30, 2022 at 10:24
  • \$\begingroup\$ Look at the map file generated by the linker to see what is located in memory before main(). There is likely a vector table and C runtime startup code. The C runtime startup code performs initialization (e.g., stack pointer and variable initialization) that is required before main() can be called. \$\endgroup\$
    – kkrambo
    Sep 30, 2022 at 17:28

2 Answers 2


You are correct.

  1. Yes, those are the addresses.
  2. Yes, those are the memory contents at those addresses: normally the opcodes.
  3. Because there is some kind of initialisation code which is in front of main(). (Ie, at a lower address.)

unlike say a bare metal microprocessor like a 6502?

You're mistaken in this. All CPUs have to do a lot of startup for whatever IO devices they have, whether they are on-chip or implemented off-chip.

For terminology: "bare-metal" normally means "without operating system". In this sense, a microcontroller is usually much "barer" than a 6502, Z80 or whatever. but it's not really an absolute concept, as there are often libraries and similar "cushions". For a working definition of "completely bare", ask: "Do I have to program the reset vector? Do I have access to supervisor mode? Interrupt vectors?" Your C program on a microcontroller could be made to work with nothing more; on a Unix computer there's a whole operating system in the way.

And you say "instruction and opcode". The opcode is binary form of the instruction. You see 2802 for cmp r0, #2: 28 is the opcode, 02 is the operand, an immediate one in this case. Together they form the instruction stream. Many people use "opcodes" for the whole instruction stream, and don't make much distinction between which bytes are really coding instruction and which are encoding operands, because often they are completely intermingled. (For example, it's not easy to see the r0 in the 28.) And whether the addressing mode forms part of the opcode or is a separate thing can be very messy. (For a clear example, look at VAX bytestream.)

  1. Yes

  2. Yes

  3. No, because the main() function is not the first and only thing a C program needs to run. For example it must initialize varibles to non-zero initial value or zero out uninitialized variables, and a lot of other things, before the startup code runs to execute the main() function.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.