Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(570)

Side by Side Diff: src/pkg/crypto/rc4/rc4_386.s

Issue 7547050: code review 7547050: crypto/rc4: faster amd64, 386 implementations (Closed)
Patch Set: diff -r ff779e477085 https://code.google.com/p/go/ Created 12 years ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/pkg/crypto/rc4/rc4_amd64.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Go Authors. All rights reserved. 1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // func xorKeyStream(dst, src *byte, n int, state *[256]byte, i, j *uint8) 5 // func xorKeyStream(dst, src *byte, n int, state *[256]byte, i, j *uint8)
6 TEXT ·xorKeyStream(SB),7,$0 6 TEXT ·xorKeyStream(SB),7,$0
7 » MOVQ dst+0(FP), DI 7 » MOVL dst+0(FP), DI
8 » MOVQ src+8(FP), SI 8 » MOVL src+4(FP), SI
9 » MOVQ n+16(FP), CX 9 » MOVL state+12(FP), BP
10 » MOVQ state+24(FP), R8
11 10
12 » MOVQ xPtr+32(FP), AX 11 » MOVL xPtr+16(FP), AX
13 » MOVBQZX (AX), AX 12 » MOVBLZX (AX), AX
14 » MOVQ yPtr+40(FP), BX 13 » MOVL yPtr+20(FP), BX
15 » MOVBQZX (BX), BX 14 » MOVBLZX (BX), BX
15 » CMPL n+8(FP), $0
16 » JEQ done
16 17
17 loop: 18 loop:
18 » CMPQ CX, $0 19 » // i += 1
19 » JE done
20
21 » // c.i += 1
22 INCB AX 20 INCB AX
23 21
24 » // c.j += c.s[c.i] 22 » // j += c.s[i]
25 » MOVB (R8)(AX*1), R9 23 » MOVBLZX (BP)(AX*1), DX
26 » ADDB R9, BX 24 » ADDB DX, BX
25 » MOVBLZX BX, BX
27 26
28 » MOVBQZX (R8)(BX*1), R10 27 » // c.s[i], c.s[j] = c.s[j], c.s[i]
28 » MOVBLZX (BP)(BX*1), CX
29 » MOVB CX, (BP)(AX*1)
30 » MOVB DX, (BP)(BX*1)
29 31
30 » MOVB R10, (R8)(AX*1) 32 » // *dst = *src ^ c.s[c.s[i]+c.s[j]]
31 » MOVB R9, (R8)(BX*1) 33 » ADDB DX, CX
34 » MOVBLZX CX, CX
35 » MOVB (BP)(CX*1), CX
36 » XORB (SI), CX
37 » MOVBLZX CX, CX
38 » MOVB CX, (DI)
32 39
33 » // R11 = c.s[c.i]+c.s[c.j] 40 » INCL SI
34 » MOVQ R10, R11 41 » INCL DI
35 » ADDB R9, R11 42 » DECL n+8(FP)
43 » JNE loop
36 44
37 MOVB (R8)(R11*1), R11
38 MOVB (SI), R12
39 XORB R11, R12
40 MOVB R12, (DI)
41
42 INCQ SI
43 INCQ DI
44 DECQ CX
45
46 JMP loop
47 done: 45 done:
48 » MOVQ xPtr+32(FP), R8 46 » MOVL xPtr+16(FP), CX
49 » MOVB AX, (R8) 47 » MOVB AX, (CX)
50 » MOVQ yPtr+40(FP), R8 48 » MOVL yPtr+20(FP), CX
51 » MOVB BX, (R8) 49 » MOVB BX, (CX)
52 50
53 RET 51 RET
OLDNEW
« no previous file with comments | « no previous file | src/pkg/crypto/rc4/rc4_amd64.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b