12.07.2015 Views

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

TASKING VX-toolset for ARM User Guide

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C Language.L2:mov r0,#0xffldr r1,.L2str r0,[r1,#0]bx lr.size main,$-main.align 4.dwoutExample 3: using input parametersAssign a variable to a register. A register is chosen <strong>for</strong> the parameter because of the constraint r; thecompiler decides which register is best to use. The %0 in the instruction template is replaced with thename of this register.The compiler generates code to move the input variable to the input register. Becausethere are no output parameters, the output parameter list is empty. Only the colon has to be present.int in;void initreg( void ){__asm( "MOV R0,%0":: "r" (in) );}Generated assembly code:.L2:ldr r0,.L2ldr r0,[r0,#0]MOV R0,r0bx lr.size initreg,$-initreg.align 4.dwinExample 4: using input and output parametersAdd two C variables and assign the result to a third C variable. Registers are used <strong>for</strong> the input and outputparameters (constraint r, %0 <strong>for</strong> out, %1 <strong>for</strong> in1, %2 <strong>for</strong> in2 in the instruction template). The compilergenerates code to move the input expressions into the input registers and to assign the result to the outputvariable.int in1, in2, out;void add32( void ){__asm( "add %0, %1, %2": "=r" (out): "r" (in1), "r" (in2) );}7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!