Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12597 Discussions

How to write 32bits constant into r2

Altera_Forum
Honored Contributor II
991 Views

Hi all, 

 

I'm using inline asm and hope to write a 32bits constant which is defined in *.c file into register r2. I have tried the following instruction, but compiler report error: 

 

asm("movhi r2, %hiadj(%0)" :: "i" (0x1000000)); 

asm("addi r2, r2, %lo(%0)" :: "i" (0x1000000));  

 

ERROR: error: invalid `asm': operand number missing after %-letter 

 

Anybody help? 

David
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
271 Views

you need an extra '%' : 

 

<span style="color:red">--- asm("movhi r2, %hiadj(%0)" :: "i" (0x1000000)); 

--- asm("addi r2, r2, %lo(%0)" :: "i" (0x1000000));  

 

+++ asm("movhi r2, %%hiadj(%0)" :: "i" (0x1000000)); 

+++ asm("addi r2, r2, %%lo(%0)" :: "i" (0x1000000));  

</span> 

 

Regards, 

--Scott
0 Kudos
Altera_Forum
Honored Contributor II
271 Views

Thanks very much, Scott... 

 

Can you guide me how to find the related information? 

 

Thanks again, 

David
0 Kudos
Altera_Forum
Honored Contributor II
271 Views

Hi David, 

 

> Can you guide me how to find the related information? 

 

See the gcc manual. 

 

Regards, 

--Scott
0 Kudos
Reply