- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
In my project, I define a imme in *.c file: #define SPI_0_BASE 0x00800980 In one of my asm routine, I wanna use this imme, how could I do? asm("movhi r15,%hi(SPI_0_BASE)"); I have tried the expression above, but compiling error occur and told me that SPI_0_BASE was undefined. Thanks any help, DavidLink Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by david_cai@Dec 27 2005, 06:47 AM #define spi_0_base 0x00800980
in one of my asm routine, i wanna use this imme, how could i do?
asm("movhi r15,%hi(spi_0_base)");
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=11793)
--- quote end ---
--- Quote End --- It does not work because the symbol is inside " "... I do not know any escape unless you either substitute the symbol by hand or you rewrite the statement in C ... bye PJ
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe try like this example :
#define CUSTOM_INSTRUCTION_TEST 6
//expand the contents of val to "xxx"# define _str_(val)# val# define __str__(val) _str_(val)
__asm__ volatile ("custom " __str__(CUSTOM_INSTRUCTION_TEST) ", r0, r0, r0");
This generates : custom 6,r0,r0,r0
For your problem, maybe this should work in the same way __asm__ volatile ("movhi r15,%hi" __str__(SPI_0_BASE));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi svhb,
I have tried your method, but the following error occurred: {standard input}:241: Error: badly formed expression near %hi0x00800980 http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try with brackets around the value?
__asm__ volatile ("movhi r15,%hi(" __str__(SPI_0_BASE) ")");
Stefaan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
check gcc document for the inline asm's args format, there are input regs, and output regs.
search the linux-2.6.x/include/asm-nios2nommu for some example.- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- Quote Start --- originally posted by hippo@Jan 6 2006, 08:37 PM check gcc document for the inline asm's args format, there are input regs, and output regs.
search the linux-2.6.x/include/asm-nios2nommu/io.h for some example.
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=12010)
--- quote end ---
--- Quote End ---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
An excellent description of gcc inline assembly can be found here:
http://www.ibiblio.org/gferg/ldp/gcc-inlin...mbly-howto.html (http://www.ibiblio.org/gferg/ldp/gcc-inline-assembly-howto.html) also, check the nios2.h file. --wolf
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page