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++
12748 Discussions

variable reference in assembly

Altera_Forum
Honored Contributor II
1,086 Views

Hello! 

 

I would like to know how to get the location of an external variable in asm code so that I have access to reading or writing to that variable. For eg. 

 

extern int x; 

 

asm ( 

 

// I want to move the address of int x to r2 for reading or writing to x 

 

 

Any and all help is greatly appreciated 

Thanx
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
405 Views

oops! I should have combed through the instruction set more closely. I suppose the instruction "movia" comes in handy as follows 

 

extern int x; 

 

asm ( 

" movia r2, x \n\t" 

"..." 

)
0 Kudos
Reply