line assembly help

Marc Salem msalem at cse.unsw.edu.au
Sun Jun 17 06:21:37 UTC 2001


You are missing the constaints part of the asm statement. See the
'info gcc' pages, under "C extensions", and "extended asm".

Or a http version of the same:
http://www.psc.edu/general/software/packages/gcc/manual/gcc_85.html

Basically you need to tell gcc how the assembly code should get at the
data. I am blissfully ignorant of the intel instruction set, so i
can't really help with the details.

Here is an example using the ARM swap instruction, which is similar:

INLINE dword_t 
swap (dword_t * addr, dword_t val) {

  __asm__ __volatile__ ("\tswp	%0, %0, [%1]    \n"
		  : "=r" (val)
		  : "r" (addr), "0" (val)
		  );

  return val; /* Now containing original value */
}




On Sat, Jun 16, 2001 at 09:27:18PM -0000, Heamanth  Kumar wrote:
> Hello,
>        I'm trying to compile some code with a small bit of assembly for byte swaping with gcc. I get linking errors. I'm new to Assembly Can any body help.
>    
> the code is 
>    xchg(us) \
>     __asm__("
>         mov us,%ax
>         xchg %al,%ah
>         mov %ax,us 
>         ");
> 
> 
> When I call this function to swap I get a link error like 
> (.text+)x8): undefined reference to 'us'
> 
> ld returned 1 exit status
> 
> Any help would be appreated..
> My host is RH Linux for i386 target..
> 
> Heamanth
> 
> 
> 
> 
>   
> 
>   
> 
> _____________________________________________________
> Buy Lagaan & Yaadein music for 30% less.
> Avail this special offer at http://shopping.rediff.com/shopping/music/offerrediffmailer.htm 
> 
> 

-- 

Marc Salem
m.salem at unsw.edu.au
0416 033 180 

UNSW Solar Racing Team          School Of Computer Science & Engineering
http://www.sunswift.com/        http://www.cse.unsw.edu.au/




More information about the users mailing list