How to write assemble programs in IDE without loop.

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

How to write assemble programs in IDE without loop.

779件の閲覧回数
v_a_kulkarni
Contributor I

Hi, I have executed following code.

int main(void) {
__asm(
"MOV R1,#0X00\n\r"
"loop: AND R1,R1,#0xFFFFFFFF\n\r"
" NOP\n\r"
" NOP\n\r"
"BL loop"

I want to execute only 04 instructions MOV AND NOP NOP. How to do this? With loop instruction, program will be executed repeatedly. I want to stop after executing 04 instructions. With this I can measure average current taken to execute these 04 instructions.

0 件の賞賛
返信
1 返信

658件の閲覧回数
converse
Senior Contributor V

To stop execution, set a breakpoint on the BL instruction. An alternative may be to use a WFI instruction, which will 'sleep' the processor (until an interrupt).

However, I think what you are trying to do is a waste of time, unless you have some very very expensive measuring  equipment - assuming your core is running at a sensible speed (25MHz, 100MHz?) then the 4 instructions you are trying to measure will execute so quickly, you will will not see anything measurable (at 100MHz, 4 instructions will take 40nS.

0 件の賞賛
返信