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

Re: [f-cpu] RC5, last test


Michael Riepe wrote:
> On Mon, Apr 15, 2002 at 05:46:09AM +0200, cedric wrote:
> > Hi every body,
> >
> >       I am currently finalising my code for the RC5 DNETC core, but I have a
> > problem. At the end of the process I must test every chunck of two register
> > to know if I have found the solution.
> >
> >       The solution is easy if I know the number of the chunk, and not their size.
> > Because during all the process I only use 32 bits chunks. So I know that
> > every chunk has been computed well, but I don't know how to test each chunck
> > and return the number of the chunck (to determine the key that decrypt the
> > message).
> >
> >       So my question is easy ;-) How can I do a test on each chunk to find the
> > one that is null ?
> For a quick test whether *any* of the chunks of <register> is zero, use
> one of these:
>         scmple.32 r0, <register>, r1
>         scmpli.32 $1, <register>, r1
> After that, you can use lsb1/msb1 to find the first/last chunk.
> Another option is to tear the chunks apart and test them separately,
> e.g. via and, mix/expand or shift instructions, whatever fits your needs.

with 8-bit chunks, there is also a way to do this, using the "combine"
option of the ROP2 unit. but the critical datapath of ROP2 is too tight to
allow 32-bit version of this.

However the idea is simple : for each chunk, mask out the corresponding
field and do a conditional jump. in the current case, the masks are less
straight-forward so i'll simply shift ...
  r1 = SIMD input (2*32)
  move r1, r2;
  shli 32, r1, r3;
  shri 32, r2, r4;
  if r3==0 jmp [rX];  (cjump)
  if r4==0 jmp [rX];  

yes, it's far easier with the combine instructions but it's just a matter of time
and efforts before it is implemented. It would simply look like 

  and.or.32 r0,r1,r2;   // i'm not sure about the syntax
  // 1 or 2 cycle stall (depends on the operand size)
  if r2==0 jmp [rX];

but the target of the jump would have to test each chunk individually.

>  Michael "Tired" Riepe <Michael.Riepe@stud.uni-hannover.de>
To unsubscribe, send an e-mail to majordomo@seul.org with
unsubscribe f-cpu       in the body. http://f-cpu.seul.org/