Forum Discussion
Altera_Forum
Honored Contributor
20 years agoAsm code and C imme
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...
Altera_Forum
Honored Contributor
20 years agoMaybe 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));