Labels by Inline ASM

Segher Boessenkool segher@kernel.crashing.org
Fri Mar 19 11:08:00 GMT 2004


On 19-mrt-04, at 9:17, Eugene wrote:

> Hi !
> Please, help me.
> I need _quickly_ add two  _unsigned_
> long and test carry flag.
>
> For Example:
> ////////////////////////////////////////////////
>
> int AddULong(ulong a, ulong b, ulong *c)
> {
>    *c = a + b;
>     asm volatile("jc  La1");
>         return 0;   // carry == 0
> La1:  return 1;  //  carry == 1
> }

You cannot jump out from an inline assembly block.
Also, an assembler label is not the same as a C label.

But why bother...  just:


int add_ulong(unsigned long a, unsigned long b, unsigned long *c)
{
	return (*c = a + b) < a;
}

...and it's portable, too!


Segher



More information about the Gcc-help mailing list