home *** CD-ROM | disk | FTP | other *** search
/ Serving the Web / ServingTheWeb1995.disc1of1.iso / linux / slacksrce / d / libc / libc-4.6 / libc-4 / libc-linux / ufc / crypt.sparc.S < prev    next >
Encoding:
Text File  |  1992-02-12  |  2.5 KB  |  117 lines

  1. !
  2. ! UFC-crypt: ultra fast crypt(3) implementation
  3. ! Copyright (C) 1991, 1992, Michael Glad, email: glad@daimi.aau.dk
  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.sparc.S    2.5 12/30/91
  20. !
  21. ! Assembly code for SPARC architecture machines
  22. !
  23.  
  24. #define I    %i3
  25. #define ITR    %i4
  26.  
  27. #define L1    %o0
  28. #define L2    %o1
  29. #define R1    %o2
  30. #define R2    %o3
  31.  
  32. #define KPTR    %g1
  33. #define MASK    %g2
  34. #define SCR1a    %g3
  35. #define SCR1b    %g4
  36. #define SCR1    %g5
  37. #define SCR2    %g6
  38. #define SCR3    %g7
  39.  
  40. #define SB0a    %l0
  41. #define SB0b    %l1
  42. #define SB1a    %l2
  43. #define SB1b    %l3
  44. #define SB2a    %l4
  45. #define SB2b    %l5
  46. #define SB3a    %l6
  47. #define SB3b    %l7
  48.  
  49. #define ASSIGN(reg,value) sethi %hi(value),reg ; or %lo(value),reg,reg ;
  50.  
  51.  
  52. #define F(I,O1,O2,SBX1,SBX2,SBY1,SBY2)                \
  53.     ld     [KPTR],SCR1 ;                    \
  54.     xor    SCR1,I,SCR1 ;                     \
  55.      and    SCR1,MASK,SCR1a ;                \
  56.                                 \
  57.     ld    [SBX1+SCR1a],SCR2 ;    inc    4,KPTR ;    \
  58.      srl    SCR1,16,SCR1b ;                    \
  59.     ld    [SBX2+SCR1a],SCR3 ;    xor    SCR2,O1,O1 ;    \
  60.                                 \
  61.     ld    [SBY1+SCR1b],SCR2 ;    xor     SCR3,O2,O2 ;    \
  62.     ld    [SBY2+SCR1b],SCR3 ;    xor     SCR2,O1,O1 ;    \
  63.                                 \
  64.     xor     SCR3,O2,O2 ;
  65.  
  66. #define G(I1,I2,O1,O2)            \
  67.     F(I1,O1,O2,SB1a,SB1b,SB0a,SB0b) F(I2,O1,O2,SB3a,SB3b,SB2a,SB2b)
  68.  
  69. #define H G(R1,R2,L1,L2) ; G(L1,L2,R1,R2)
  70.  
  71.     .seg    "text"
  72.     .global    _ufc_doit
  73.  
  74. _ufc_doit:
  75. !
  76. ! Preamble
  77. !
  78.     save    %sp,-104,%sp
  79.     mov %i0,L1 ;    mov %i1,L2
  80.     mov %i2,R1 ;    mov %i3,R2
  81. !
  82. ! Set up sb pointers
  83. !
  84.     ASSIGN(SB0a,_ufc_sb0) ; add SB0a,4,SB0b
  85.     ASSIGN(SB1a,_ufc_sb1) ; add SB1a,4,SB1b 
  86.     ASSIGN(SB2a,_ufc_sb2) ; add SB2a,4,SB2b
  87.     ASSIGN(SB3a,_ufc_sb3) ; add SB3a,4,SB3b
  88. !
  89.     ASSIGN(MASK,0xffff)
  90. !
  91. ! Loop
  92. !
  93. Lagain:
  94.     ASSIGN(KPTR,_ufc_keytab)
  95.     ASSIGN(I, 8)
  96. Lagain1:
  97.     H
  98.     deccc    I
  99.     bnz     Lagain1
  100.     nop
  101. ! Permute
  102.     mov L1,SCR1 ; mov R1,L1 ; mov SCR1,R1
  103.     mov L2,SCR1 ; mov R2,L2 ; mov SCR1,R2
  104. !
  105.     deccc     ITR
  106.     bnz     Lagain
  107.     nop
  108. !
  109. ! Output conversion
  110. !
  111.     call    _ufc_dofinalperm,4
  112.     nop
  113. !
  114. ! Postamble
  115. !
  116.     ret ; restore %g0,%o0,%o0
  117.