home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / crypt / crypt.s300.S < prev    next >
Encoding:
Text File  |  1992-09-02  |  2.3 KB  |  109 lines

  1.  #
  2.  # UFC-crypt: ultra fast crypt(3) implementation
  3.  # Copyright (C) 1991, 1992, Free Software Foundation, Inc.
  4.  #
  5.  # This library is free software, you can redistribute it and/or
  6.  # modify it under the terms of the GNU Library General Public
  7.  # License as published by the Free Software Foundation, either
  8.  # version 2 of the License, or (at your option) any later version.
  9.  #
  10.  # This library is distributed in the hope that it will be useful,
  11.  # but WITHOUT ANY WARRANTY, without even the implied warranty of
  12.  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.  # Library General Public License for more details.
  14.  #
  15.  # You should have received a copy of the GNU Library General Public
  16.  # License along with this library, if not, write to the Free
  17.  # Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  #
  19.  # @(#)crypt.s300.S    2.9 5/28/92
  20.  #
  21.  # MC680x0/Hp9000 s300/s400 assembly code
  22.  #
  23.  
  24. #define L1    %d0
  25. #define L2    %d1
  26. #define R1    %d2
  27. #define R2    %d3
  28. #define SCR1    %d4
  29. #define SCR2    %d5
  30.  
  31. #define I    %d7
  32. #define ITR    24(%a6)
  33.  
  34. #define SB0    %a0
  35. #define SB1    %a1
  36. #define SB2    %a2
  37. #define SB3    %a3
  38. #define KPTR    %a4
  39.     
  40. #define F(I,O1,O2,SBX,SBY)                        \
  41.     mov.l     (KPTR)+,SCR1 ;        eor.l     I,SCR1 ;        \
  42.     mov.l    0(SBX,SCR1.w),SCR2 ;     eor.l    SCR2,O1 ;        \
  43.     mov.l    4(SBX,SCR1.w),SCR2 ;    eor.l    SCR2,O2 ;        \
  44.     swap.w    SCR1 ;                            \
  45.     mov.l    0(SBY,SCR1.w),SCR2 ;    eor.l    SCR2,O1 ;        \
  46.     mov.l    4(SBY,SCR1.w),SCR2 ;    eor.l    SCR2,O2 ;
  47.  
  48. #define G(I1,I2,O1,O2)            \
  49.     F(I1,O1,O2,SB1,SB0) F(I2,O1,O2,SB3,SB2)
  50.  
  51. #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2)
  52.  
  53.     data
  54.     byte  "UFC-crypt crypt.sun3.S, @(#)crypt.s300.S    2.9 5/28/92\0"
  55.     even
  56.  
  57.     bss
  58.     lalign 4
  59. _ary:
  60.     space 4*4
  61.         
  62.     text
  63.     global __ufc_doit
  64. __ufc_doit:
  65.  #
  66.  # Preamble
  67.  #
  68.     link    %a6,&-56
  69.     movem.l &15612,(%sp)
  70.  
  71.     mov.l   20(%a6),R2 
  72.     mov.l   16(%a6),R1 
  73.     mov.l   12(%a6),L2 
  74.     mov.l    8(%a6),L1
  75.  #
  76.  # Setup address registers with sb pointers
  77.  #
  78.     mov.l    &__ufc_sb0,SB0 ; mov.l &__ufc_sb1,SB1 
  79.     mov.l   &__ufc_sb2,SB2 ; mov.l &__ufc_sb3,SB3
  80.  #
  81.  # And loop...
  82.  #
  83. Lagain:    
  84.     mov.l    &__ufc_keytab,KPTR
  85.     moveq    &8,I
  86. Lagain1:
  87.     H
  88.     subq.l    &1,I
  89.     bne    Lagain1
  90.  # Permute
  91.     mov.l L1,SCR1 ; mov.l R1,L1 ; mov.l SCR1,R1
  92.     mov.l L2,SCR1 ; mov.l R2,L2 ; mov.l SCR1,R2
  93.  #
  94.     subq.l    &1,ITR
  95.     tst.l    ITR
  96.     bne    Lagain
  97.  #
  98.  # Postamble
  99.  #
  100.     mov.l    L1, _ary
  101.     mov.l    L2, _ary+0x4
  102.     mov.l    R1, _ary+0x8
  103.     mov.l    R2, _ary+0xc
  104.     mov.l    &_ary,%d0
  105.     movem.l    (-56)(%a6),&15612 ; unlk %a6 ; rts
  106.  
  107.  
  108.  
  109.