From: Dag Arne Osvik <da@osvik.no>
To: Joachim Fritschi <jfritschi@freenet.de>
Cc: Dag Arne Osvik <da@osvik.no>,
linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org,
herbert@gondor.apana.org.au
Subject: Re: [PATCH 4/4] Twofish cipher - x86_64 assembler
Date: Tue, 06 Jun 2006 00:28:17 +0200 [thread overview]
Message-ID: <4484B001.3010503@osvik.no> (raw)
In-Reply-To: <200606051218.16125.jfritschi@freenet.de>
Joachim Fritschi wrote:
> On Sunday 04 June 2006 23:01, Dag Arne Osvik wrote:
>> Andi Kleen wrote:
>>> On Sunday 04 June 2006 15:16, Joachim Fritschi wrote:
>>>> This patch adds the twofish x86_64 assembler routine.
>>>>
>>>> +/* Defining a few register aliases for better reading */
>>> Maybe you can read it now better, but for everybody else it is extremly
>>> confusing. It would be better if you just used the original register
>>> names.
>> I'd agree if you said this code could benefit from further readability
>> improvements. But you're arguing against one.
>>
>> Too bad AMD kept the old register names when defining AMD64..
>
> I'd agree that the original register names would only complicate things.
>
> Can you give me any hint what to improve or maybe provide a suggestion on how
> to improve the overall readabilty.
It looks better on second reading, but I have some comments:
Remove load_s - it's needless and (slightly) confusing
There are some cases of missing ## D
Why semicolon after closing parenthesis in macro definitions?
Try to align operands in columns
It would be nice to have some explanation of macro parameter names
Btw, why do you keep zeroing tmp registers when you don't need to?
32-bit ops zero the top half of the destination register.
Here's an example of a modified macro (modulo linewrapping by my mail
client):
#define
encrypt_round(a,b,olda,oldb,newa,newb,ctx,round,tmp1,tmp2,key1,key2) \
load_round_key(key1,key2,ctx,round);\
movzx a ## B, newa ## D;\
movzx a ## H, newb ## D;\
ror $16, a ## D;\
xor s0(ctx,newa,4), tmp1 ## D;\
xor s1(ctx,newb,4), tmp1 ## D;\
movzx a ## B, newa ## D;\
movzx a ## H, newb ## D;\
xor s2(ctx,newa,4), tmp1 ## D;\
xor s3(ctx,newb,4), tmp1 ## D;\
ror $16, a ## D;\
movzx b ## B, newa ## D;\
movzx b ## H, newb ## D;\
ror $16, b ## D;\
xor s1(ctx,newa,4), tmp2 ## D;\
xor s2(ctx,newb,4), tmp2 ## D;\
movzx b ## B, newa ## D;\
movzx b ## H, newb ## D;\
xor s3(ctx,newa,4), tmp2 ## D;\
xor s0(ctx,newb,4), tmp2 ## D;\
ror $15, b ## D;\
add tmp2 ## D, tmp1 ## D;\
add tmp1 ## D, tmp2 ## D;\
add tmp1 ## D, key1 ## D;\
add tmp2 ## D, key2 ## D;\
mov olda ## D, newa ## D;\
mov oldb ## D, newb ## D;\
mov a ## D, olda ## D;\
mov b ## D, oldb ## D;\
xor key1 ## D, newa ## D;\
xor key2 ## D, newb ## D;\
ror $1, newa ## D
At least a little bit more readable, right?
--
Dag Arne
next prev parent reply other threads:[~2006-06-05 22:28 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-06-04 13:16 [PATCH 4/4] Twofish cipher - x86_64 assembler Joachim Fritschi
2006-06-04 19:10 ` Andi Kleen
2006-06-04 21:01 ` Dag Arne Osvik
2006-06-05 10:18 ` Joachim Fritschi
2006-06-05 22:28 ` Dag Arne Osvik [this message]
2006-06-05 22:44 ` Dag Arne Osvik
2006-06-07 19:16 ` Joachim Fritschi
2006-06-05 10:06 ` Joachim Fritschi
2006-06-05 17:44 ` dean gaudet
2006-06-05 19:46 ` Joachim Fritschi
2006-06-05 23:35 ` Andi Kleen
2006-06-07 19:21 ` Joachim Fritschi
2006-06-07 19:38 ` Joachim Fritschi
2006-06-16 12:00 ` Joachim Fritschi
2006-06-17 10:38 ` Joachim Fritschi
2006-06-19 14:13 ` Joachim Fritschi
2006-06-20 11:14 ` Herbert Xu
-- strict thread matches above, loose matches on Subject: below --
2006-06-08 7:13 linux
2006-06-08 17:35 ` Joachim Fritschi
2006-06-09 1:13 ` linux
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4484B001.3010503@osvik.no \
--to=da@osvik.no \
--cc=herbert@gondor.apana.org.au \
--cc=jfritschi@freenet.de \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox