Content originally posted in LPCWare by micrio on Mon Jun 07 06:47:42 MST 2010
[FONT=Courier New]I get some weird code coming from the inline assembler. [/FONT]
[FONT=Courier New]I have the following source;[/FONT]
[FONT=Courier New][B][COLOR=#7f0055][COLOR=#7f0055]#define [/COLOR][/COLOR][/B]DOUBLE_TOGGLE [B][COLOR=#7f0055][COLOR=#7f0055]__asm[/COLOR][/COLOR][/B]( \[/FONT]
[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %0, %[on_dly]\n\t"[/COLOR][/COLOR]\ [/FONT]
[LEFT][FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %1, %[mux_addr]\n\t"[/COLOR][/COLOR]\[/FONT][/LEFT]
[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %2, %[bit_pat]\n\t"[/COLOR][/COLOR]\[/FONT]
[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]mov[/U] %3, %[off_dly]\n\t"[/COLOR][/COLOR]\[/FONT]
[FONT=Courier New][COLOR=#2a00ff][COLOR=#2a00ff]"[U]str[/U] %2, [%1, #0]\n\t"[/COLOR][/COLOR] \[/FONT]
[LEFT][FONT=Courier New]...[/FONT][/LEFT]
[FONT=Courier New]The resulting code is; [/FONT]
[LEFT][FONT=Courier New]ldr r3, [pc, #92] (0x544 <dly_428+20>)[/FONT]
[FONT=Courier New]ldr r0, [r4, #0][/FONT]
[FONT=Courier New]ldr r1, [r3, #12][/FONT]
[FONT=Courier New]ldr r3, [pc, #88] (0x548 <dly_428+24>)[/FONT]
[FONT=Courier New]ldr r2, [r3, #0][/FONT][/LEFT]
[FONT=Courier New]ldr r3, [pc, #88] (0x54c <dly_428+28>)[/FONT]
[FONT=Courier New]adds r0, r0, #0[/FONT]
[FONT=Courier New]adds r3, r3, #0[/FONT]
[FONT=Courier New]adds r1, r1, #0[/FONT]
[FONT=Courier New]adds r2, r2, #0[/FONT]
[FONT=Courier New]str r1, [r3, #0][/FONT]
[FONT=Courier New]The MOV opcodes get translated to LDR which is OK. The loaded values are correct. [/FONT]
[FONT=Courier New]The STR opcode is unchanged. However what are the ADDS opcodes for?[/FONT]
[SIZE=2][FONT=Courier New][SIZE=3]They serve to test the incoming values but are not needed. [/SIZE][/FONT]
[FONT=Courier New][SIZE=3]I am trying to save every machine cycle and this is just a waste. [/SIZE][/FONT]
[FONT=Courier New][SIZE=3]Is there some way that I can eliminate them?[/SIZE][/FONT]
(I can't explain the odd formatting of this message, there must be some invisible char messing things up!)
[/SIZE]