13.07.2015 Views

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 User Guide

TASKING VX-toolset for 8051 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.

<strong>TASKING</strong> <strong>VX</strong>-<strong>toolset</strong> <strong>for</strong> <strong>8051</strong> <strong>User</strong> <strong>Guide</strong>When you use the "d" constraint a pseudo-register might also be used. GPRs will be prefixed with an "A"automatically:__data char in, out;void m_inc2( void ){__asm( "MOV %0,%1\n\t""INC %0": "=r"(out): "d"(in) );}Generated assembly code is the same.Example 6: reserving registersSometimes an instruction knocks out certain specific registers. The most common example of this is afunction call, where the called function is allowed to do whatever it likes with some registers. If this is thecase, you can list specific registers that get clobbered by an operation after the inputs.Same as Example 4, but now register R0 is a reserved register. You can do this by adding a reservedregister list (: "R0"). As you can see in the generated assembly code, register R0 is not used (the firstregister used is R1).__data char in1, in2, out;void add2( void ){__asm( "MOV A, %1\n\t""ADD A, %2\n\t""MOV %0, A": "=r" (out): "r" (in1), "r" (in2): "R0" );}void main(void){in1 = 3;in2 = 4;add2( );}Generated assembly code:_add2:; Code generated by C compilermov R1,_in2mov R2,_in1; __asm statement expansionMOV A, R2ADD A, R116

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

Saved successfully!

Ooh no, something went wrong!