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

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>8051</strong> <strong>User</strong> <strong>Guide</strong>movmov@R1,A_result,R1However, when the inline assembly would have been as given below, the compiler would have assumedthat %1 (par1) and %2 (par2) were read-only. Because of the inline keyword the compiler knows thatpar1 and par2 both contain 100. There<strong>for</strong>e the compiler can optimize and assign the same register to%1 and %2. This would have given an unexpected result.__asm("dec %1\n\t""mov A,%2\n\t""add A,%1\n\t""mov A%0,%3\n\t""mov @%0,A": "=&s" (retvalue): "r" (par1), "r" (par2), "r" (par3));Generated assembly code:movmovR0,#_parmR2,#100dec R2 ; R2 contains 99mov A,R2 ; A contains 99add A,R2 ; same register R2, but is expected read-onlymov AR1,R0mov @R1,Amov_result,R1 ; contains unexpected result1.4. AttributesYou can use the keyword __attribute__ to specify special attributes on declarations of variables,functions, types, and fields.Syntax:__attribute__((name,...))or:__name__The second syntax allows you to use attributes in header files without being concerned about a possiblemacro of the same name. For example, you may use __noreturn__ instead of__attribute__((noreturn)).18

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

Saved successfully!

Ooh no, something went wrong!