This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Mixing C and assembly

I have written one code in the assembly language for mixing C and assembly. The compiler is not properly generating the code for one instruction. I have written the following code,

LDR r0,[pc, #74]

here I want to load a word value from the PC+offset. Here I want the 16 bit LDR instruction should be used by the compiler. But compiler is taking LDR.W instruction, which is general instruction for +/- offset and which is 32 bit. But I want to instruct the compiler for the usage of the 16 bit instructions, how to do this?
Also if I want to use the LDR.W instruction I will write the same, but why the compiler is generating a different instruction, although syntax of both instruction is different?

Parents
  • Mukund Kumbhar:

    www.keil.com/.../armcc_chr1359124249383.htm

    The inline assembler provides no direct access to the physical registers of an ARM processor. If an ARM register name is used as an operand in an inline assembler instruction it becomes a reference to a variable of the same name, and not the physical ARM register.

    The compiler implicitly declares registers R0 to R12 and r0 to r12 as auto signed int local variables, regardless of whether or not they are used. If you want to declare them to be of a different data type, you can do so. For example,

Reply
  • Mukund Kumbhar:

    www.keil.com/.../armcc_chr1359124249383.htm

    The inline assembler provides no direct access to the physical registers of an ARM processor. If an ARM register name is used as an operand in an inline assembler instruction it becomes a reference to a variable of the same name, and not the physical ARM register.

    The compiler implicitly declares registers R0 to R12 and r0 to r12 as auto signed int local variables, regardless of whether or not they are used. If you want to declare them to be of a different data type, you can do so. For example,

Children