A92: Re: placing data into C variables from ASM(" ") constructs


[Prev][Next][Index][Thread]

A92: Re: placing data into C variables from ASM(" ") constructs




> l can use the following code to put values into an ASM(" ") construct like
> this...
> function(x)
> int x;
> {
> move.w 8(%sp),%d0   // puts 'x' into d0
> }

void function(int x)
{
  asm(" ...asm code involving %0... " : : "d" (x) : "0");
}

Will let you use %0 instead of %%d0, which gives gcc a little more flexibility
(and possibly saves a little space).

>
> But how do l get values out of an asm construct? (like register d0 into 'x')

void function(void)
{
  asm("...asm code putting return value in %0..." : "=d" (x));
}

Assuming that x is an int or long int.

 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF Quote follows:

"I'm not going to ride on a magic carpet!" he hissed.
"I'm afraid of grounds."
"You mean heights," said Conina. "And stop being silly."
"I know what I mean! It's the grounds that kill you!"
        -- (Terry Pratchett, Sourcery)




References: