13.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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>ARM</strong> <strong>User</strong> <strong>Guide</strong>Example 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) );}Generated assembly code:.L2:ldr r0,.L2ldr r1,[r0,#0]ldr r0,[r0,#4]add r0, r1, r0ldr r1,.L2str r0,[r1,#8]bx lr.size add32,$-add32.align 4.dw in1.section .bss.global in1.align 4in1: .type object.size in1,4.ds 4.global in2.align 4in2: .type object.size in2,4.ds 4.global out.align 4out: .type object.size out,4.ds 4.endsec8

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

Saved successfully!

Ooh no, something went wrong!