This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

use c variables in inline assembly

main()
{ char a[10]="srikanth";

//----assembly code starts.....

//--------asm ends.........
// c code

}

Parents
  • Inline assembly is a very specific nonstandard feature of a toolchain. You have specified none as your MCU.

    If you are using C51, for example, there is really not such thing as an 'inline assembler' like in other compilers. When you use the ASM/ENDASM directives the compiler simply includes the text into the source listing generated with the SRC directive, to be assembled by the A51 assembler. That is messy and dangerous. I totally agree with Erik in that you should always use separate .A51 assembly routines callable as C functions, in which case you would access the C data objects using the EXTERN assembler directive, and the access method will depend on the data object storage class.

    If you are using ARM RVCT, for example, then you have a true optimizing inline assembler, and you can access C variables directly by their names.

    Whatever the case may be, the integration with C is described in the toolchain manuals.

Reply
  • Inline assembly is a very specific nonstandard feature of a toolchain. You have specified none as your MCU.

    If you are using C51, for example, there is really not such thing as an 'inline assembler' like in other compilers. When you use the ASM/ENDASM directives the compiler simply includes the text into the source listing generated with the SRC directive, to be assembled by the A51 assembler. That is messy and dangerous. I totally agree with Erik in that you should always use separate .A51 assembly routines callable as C functions, in which case you would access the C data objects using the EXTERN assembler directive, and the access method will depend on the data object storage class.

    If you are using ARM RVCT, for example, then you have a true optimizing inline assembler, and you can access C variables directly by their names.

    Whatever the case may be, the integration with C is described in the toolchain manuals.

Children
No data