Re: QUERY : ARM mode inline instructions in C Thumb mode file?
- From: "Wilco Dijkstra" <Wilco.removethisDijkstra@xxxxxxxxxxxx>
- Date: Wed, 27 Aug 2008 21:57:14 +0100
"adsouzp" <adsouzp@xxxxxxxxx> wrote in message news:APqdnc54RY_X4ijVnZ2dnUVZ_rHinZ2d@xxxxxxxxxxxxxxx
Nick Clifton said:
There are two problems with the above code:
1. You do not switch back to thumb mode at the end of the ARM code
fragment. Gcc passes the contents of the asm() directory on to the
assembler - it does not try to parse it and discover that you are
sneakily switching into ARM mode...
2. You have the .arm directive without a nearby label to hang it on.
The .arm (and .thumb) directives need a label because the changes
between instruction sets is encoded into attributes of the labels, thus
allowing the linker and disassembler to know when instruction sets have
changed.
ie. please try this:
void function_f( void )
{
asm volatile
(
".align \n"
"__f_into_arm:\n\t"
".arm \n\t"
"mrs r0, cpsr \n\t"
"msr cpsr_c, r0 \n\t"
"pop { r0 } \n"
"__f_from_arm:\n\t"
".thumb"
);
}
i tried the above code but it still did not work! here is the code
generated.
00008194 <function_f>:
8194: b580 push {r7, lr}
8196: af02 add r7, sp, #8
00008198 <__f_into_arm>:
8198: 0000 lsls r0, r0, #0
819a: e10f b.n 83bc <wrap+0x10>
819c: f000 e121 blx 4083e0 <_stack+0x3883e0>
81a0: 0001 lsls r1, r0, #0
81a2: e8bd 46bd ldmia.w sp!, {r0, r2, r3, r4, r5, r7, r9, sl, lr}
000081a4 <__f_from_arm>:
81a4: b08246bd strlth r4, [r2], sp
81a8: bc01bc80 stclt 12, cr11, [r1], {128}
81ac: 00004700 andeq r4, r0, r0, lsl #14
That's because you need to first use .arm and then define the label.
The label uses the current instruction set, and doesn't look at whatever
comes afterwards. The disassembly is what I'd expect it to be.
Wilco
.
- Prev by Date: Xilinx bitstream encryption
- Next by Date: Re: Prodrive MCCB-3
- Previous by thread: Re: QUERY : ARM mode inline instructions in C Thumb mode file?
- Next by thread: Helpful :)
- Index(es):
Relevant Pages
|