Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 Jul 2013 04:48:23 +0400
From: Solar Designer <>
Subject: Re: Parallella: bcrypt


On Mon, Jul 22, 2013 at 03:08:37AM +0200, Katja Malvoni wrote:
> Does e-gcc support specifying input, output and modified registers as gcc
> inline assembly does? I couldn't make it work using the following syntax:
> __asm__(
>          ...instructions...
>          : output registers
>          : input registers
>          : clobbered registers
> );

As Yaniv has confirmed, this definitely should work.

> First error I get is for colon.

Maybe you forgot to enclose the instructions in double quotes?

> Is there a way to reference C variable from inline assembly?

Yes.  For your needs, this is best done via those input/output registers

> If not, how can I safely implement part of C code in assembly? (more
> precisely BF_ROUND)

The above is how you do it.

> I tried to do that using macro but the problem is that assembly code around
> macro changes and my implementation is not reliable because e-gcc generated
> code sometimes uses different registers when other C code is changed.

Of course, you must not rely on specific register allocations by the
compiler.  Instead, you use the "%0", etc. placeholders in your inline
assembly, and map those to local variable names (which are actually
registers, since gcc will try to put all it reasonably can in registers).

> How are function arguments passed?

When you use inline assembly, you should not be concerned about that.
(You would be if you were writing the entire function in assembly in a
separate .S or .s file.)  With inline assembly, you simply use the "%0",
etc. placeholders, and gcc takes care of substituting the right register
names into its assembly output.

Actually, I think Yaniv's responses were sufficient, but maybe you'd
find the above helpful as well.


Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.