C and Assembly Timing problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

C and Assembly Timing problem

511件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Alainbs on Tue May 28 09:40:17 MST 2013
I have a project where i have C files and ASM files (LPC1114 xpresso board and lpcxpresso IDE). 

From C i call an assembly function where i read a GPIO and acquire the bits, after that i return again to C.
The problem is that when i add or delete lines of code in C the sampling time in assembly change.
.
Does the compiler optimize also my assembly code? What can i do?


[COLOR=royalblue]From my C code i make a call to the assembly function and got the last RAM address:[/COLOR]
unsigned int *lastRAMaddr;
[COLOR=black][/COLOR]
[COLOR=black]lastRAMaddr = (unsigned int*)asmfunction();[/COLOR]
.........
here process the data i got from sampling
........
[COLOR=#3f7f5f][COLOR=#3f7f5f][/COLOR][/COLOR][COLOR=royalblue]Sampling part look like this:[/COLOR]
[SIZE=2][/SIZE]
[SIZE=2]asmfunction:[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]movs   r0,#150[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2][COLOR=darkred]readpin:[/COLOR][/SIZE]
[SIZE=2]ldr       r2,[r3]   //Read GPIO r3 hold the address of the gpio[/SIZE]
[SIZE=2]stm     r1!,{r2} //Store Bit in Ram and increment address[/SIZE]
[SIZE=2]subs    r0,#1    [/SIZE]
[SIZE=2]bne     [COLOR=darkred]readpin[/COLOR][/SIZE]
[SIZE=2][COLOR=black]movs  r0,#0[/COLOR][/SIZE]
[SIZE=2]orrs    r0,r1      //Get last RAM address
bx     lr[SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f]
[/COLOR][/SIZE][/COLOR][/SIZE][/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]

[/SIZE][SIZE=2][COLOR=#3f7f5f][SIZE=2][COLOR=#3f7f5f][/COLOR][/SIZE][/COLOR][/SIZE]
0 件の賞賛
返信
2 返答(返信)

498件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by R2D2 on Wed May 29 07:06:13 MST 2013

Quote: Alainbs
What can i do?


Look in your assembler output :)

Add

Quote:
arm-none-eabi-objdump -S ${BuildArtifactFileName} >${BuildArtifactFileBaseName}.lss;

to your project 'Post-build steps'.
0 件の賞賛
返信

498件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed May 29 06:49:39 MST 2013
No, the C compiler it does not optimize your assembler.

Most likely cause is that you are spanning two different flash-cache lines and your loop is causing two flash-lines to be fetched. There has been a lot of discussion in this forum about this as it can cause changes in performance.
0 件の賞賛
返信