How to write assemble programs in IDE without loop.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to write assemble programs in IDE without loop.

739 Views
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 Kudos
Reply
1 Reply

618 Views
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 Kudos
Reply