salsa2020_amd64.s 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. // Copyright 2012 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build amd64,!appengine,!gccgo
  5. // This code was translated into a form compatible with 6a from the public
  6. // domain sources in SUPERCOP: http://bench.cr.yp.to/supercop.html
  7. // func salsa2020XORKeyStream(out, in *byte, n uint64, nonce, key *byte)
  8. // This needs up to 64 bytes at 360(SP); hence the non-obvious frame size.
  9. TEXT ·salsa2020XORKeyStream(SB),0,$456-40 // frame = 424 + 32 byte alignment
  10. MOVQ out+0(FP),DI
  11. MOVQ in+8(FP),SI
  12. MOVQ n+16(FP),DX
  13. MOVQ nonce+24(FP),CX
  14. MOVQ key+32(FP),R8
  15. MOVQ SP,R12
  16. MOVQ SP,R9
  17. ADDQ $31, R9
  18. ANDQ $~31, R9
  19. MOVQ R9, SP
  20. MOVQ DX,R9
  21. MOVQ CX,DX
  22. MOVQ R8,R10
  23. CMPQ R9,$0
  24. JBE DONE
  25. START:
  26. MOVL 20(R10),CX
  27. MOVL 0(R10),R8
  28. MOVL 0(DX),AX
  29. MOVL 16(R10),R11
  30. MOVL CX,0(SP)
  31. MOVL R8, 4 (SP)
  32. MOVL AX, 8 (SP)
  33. MOVL R11, 12 (SP)
  34. MOVL 8(DX),CX
  35. MOVL 24(R10),R8
  36. MOVL 4(R10),AX
  37. MOVL 4(DX),R11
  38. MOVL CX,16(SP)
  39. MOVL R8, 20 (SP)
  40. MOVL AX, 24 (SP)
  41. MOVL R11, 28 (SP)
  42. MOVL 12(DX),CX
  43. MOVL 12(R10),DX
  44. MOVL 28(R10),R8
  45. MOVL 8(R10),AX
  46. MOVL DX,32(SP)
  47. MOVL CX, 36 (SP)
  48. MOVL R8, 40 (SP)
  49. MOVL AX, 44 (SP)
  50. MOVQ $1634760805,DX
  51. MOVQ $857760878,CX
  52. MOVQ $2036477234,R8
  53. MOVQ $1797285236,AX
  54. MOVL DX,48(SP)
  55. MOVL CX, 52 (SP)
  56. MOVL R8, 56 (SP)
  57. MOVL AX, 60 (SP)
  58. CMPQ R9,$256
  59. JB BYTESBETWEEN1AND255
  60. MOVOA 48(SP),X0
  61. PSHUFL $0X55,X0,X1
  62. PSHUFL $0XAA,X0,X2
  63. PSHUFL $0XFF,X0,X3
  64. PSHUFL $0X00,X0,X0
  65. MOVOA X1,64(SP)
  66. MOVOA X2,80(SP)
  67. MOVOA X3,96(SP)
  68. MOVOA X0,112(SP)
  69. MOVOA 0(SP),X0
  70. PSHUFL $0XAA,X0,X1
  71. PSHUFL $0XFF,X0,X2
  72. PSHUFL $0X00,X0,X3
  73. PSHUFL $0X55,X0,X0
  74. MOVOA X1,128(SP)
  75. MOVOA X2,144(SP)
  76. MOVOA X3,160(SP)
  77. MOVOA X0,176(SP)
  78. MOVOA 16(SP),X0
  79. PSHUFL $0XFF,X0,X1
  80. PSHUFL $0X55,X0,X2
  81. PSHUFL $0XAA,X0,X0
  82. MOVOA X1,192(SP)
  83. MOVOA X2,208(SP)
  84. MOVOA X0,224(SP)
  85. MOVOA 32(SP),X0
  86. PSHUFL $0X00,X0,X1
  87. PSHUFL $0XAA,X0,X2
  88. PSHUFL $0XFF,X0,X0
  89. MOVOA X1,240(SP)
  90. MOVOA X2,256(SP)
  91. MOVOA X0,272(SP)
  92. BYTESATLEAST256:
  93. MOVL 16(SP),DX
  94. MOVL 36 (SP),CX
  95. MOVL DX,288(SP)
  96. MOVL CX,304(SP)
  97. ADDQ $1,DX
  98. SHLQ $32,CX
  99. ADDQ CX,DX
  100. MOVQ DX,CX
  101. SHRQ $32,CX
  102. MOVL DX, 292 (SP)
  103. MOVL CX, 308 (SP)
  104. ADDQ $1,DX
  105. SHLQ $32,CX
  106. ADDQ CX,DX
  107. MOVQ DX,CX
  108. SHRQ $32,CX
  109. MOVL DX, 296 (SP)
  110. MOVL CX, 312 (SP)
  111. ADDQ $1,DX
  112. SHLQ $32,CX
  113. ADDQ CX,DX
  114. MOVQ DX,CX
  115. SHRQ $32,CX
  116. MOVL DX, 300 (SP)
  117. MOVL CX, 316 (SP)
  118. ADDQ $1,DX
  119. SHLQ $32,CX
  120. ADDQ CX,DX
  121. MOVQ DX,CX
  122. SHRQ $32,CX
  123. MOVL DX,16(SP)
  124. MOVL CX, 36 (SP)
  125. MOVQ R9,352(SP)
  126. MOVQ $20,DX
  127. MOVOA 64(SP),X0
  128. MOVOA 80(SP),X1
  129. MOVOA 96(SP),X2
  130. MOVOA 256(SP),X3
  131. MOVOA 272(SP),X4
  132. MOVOA 128(SP),X5
  133. MOVOA 144(SP),X6
  134. MOVOA 176(SP),X7
  135. MOVOA 192(SP),X8
  136. MOVOA 208(SP),X9
  137. MOVOA 224(SP),X10
  138. MOVOA 304(SP),X11
  139. MOVOA 112(SP),X12
  140. MOVOA 160(SP),X13
  141. MOVOA 240(SP),X14
  142. MOVOA 288(SP),X15
  143. MAINLOOP1:
  144. MOVOA X1,320(SP)
  145. MOVOA X2,336(SP)
  146. MOVOA X13,X1
  147. PADDL X12,X1
  148. MOVOA X1,X2
  149. PSLLL $7,X1
  150. PXOR X1,X14
  151. PSRLL $25,X2
  152. PXOR X2,X14
  153. MOVOA X7,X1
  154. PADDL X0,X1
  155. MOVOA X1,X2
  156. PSLLL $7,X1
  157. PXOR X1,X11
  158. PSRLL $25,X2
  159. PXOR X2,X11
  160. MOVOA X12,X1
  161. PADDL X14,X1
  162. MOVOA X1,X2
  163. PSLLL $9,X1
  164. PXOR X1,X15
  165. PSRLL $23,X2
  166. PXOR X2,X15
  167. MOVOA X0,X1
  168. PADDL X11,X1
  169. MOVOA X1,X2
  170. PSLLL $9,X1
  171. PXOR X1,X9
  172. PSRLL $23,X2
  173. PXOR X2,X9
  174. MOVOA X14,X1
  175. PADDL X15,X1
  176. MOVOA X1,X2
  177. PSLLL $13,X1
  178. PXOR X1,X13
  179. PSRLL $19,X2
  180. PXOR X2,X13
  181. MOVOA X11,X1
  182. PADDL X9,X1
  183. MOVOA X1,X2
  184. PSLLL $13,X1
  185. PXOR X1,X7
  186. PSRLL $19,X2
  187. PXOR X2,X7
  188. MOVOA X15,X1
  189. PADDL X13,X1
  190. MOVOA X1,X2
  191. PSLLL $18,X1
  192. PXOR X1,X12
  193. PSRLL $14,X2
  194. PXOR X2,X12
  195. MOVOA 320(SP),X1
  196. MOVOA X12,320(SP)
  197. MOVOA X9,X2
  198. PADDL X7,X2
  199. MOVOA X2,X12
  200. PSLLL $18,X2
  201. PXOR X2,X0
  202. PSRLL $14,X12
  203. PXOR X12,X0
  204. MOVOA X5,X2
  205. PADDL X1,X2
  206. MOVOA X2,X12
  207. PSLLL $7,X2
  208. PXOR X2,X3
  209. PSRLL $25,X12
  210. PXOR X12,X3
  211. MOVOA 336(SP),X2
  212. MOVOA X0,336(SP)
  213. MOVOA X6,X0
  214. PADDL X2,X0
  215. MOVOA X0,X12
  216. PSLLL $7,X0
  217. PXOR X0,X4
  218. PSRLL $25,X12
  219. PXOR X12,X4
  220. MOVOA X1,X0
  221. PADDL X3,X0
  222. MOVOA X0,X12
  223. PSLLL $9,X0
  224. PXOR X0,X10
  225. PSRLL $23,X12
  226. PXOR X12,X10
  227. MOVOA X2,X0
  228. PADDL X4,X0
  229. MOVOA X0,X12
  230. PSLLL $9,X0
  231. PXOR X0,X8
  232. PSRLL $23,X12
  233. PXOR X12,X8
  234. MOVOA X3,X0
  235. PADDL X10,X0
  236. MOVOA X0,X12
  237. PSLLL $13,X0
  238. PXOR X0,X5
  239. PSRLL $19,X12
  240. PXOR X12,X5
  241. MOVOA X4,X0
  242. PADDL X8,X0
  243. MOVOA X0,X12
  244. PSLLL $13,X0
  245. PXOR X0,X6
  246. PSRLL $19,X12
  247. PXOR X12,X6
  248. MOVOA X10,X0
  249. PADDL X5,X0
  250. MOVOA X0,X12
  251. PSLLL $18,X0
  252. PXOR X0,X1
  253. PSRLL $14,X12
  254. PXOR X12,X1
  255. MOVOA 320(SP),X0
  256. MOVOA X1,320(SP)
  257. MOVOA X4,X1
  258. PADDL X0,X1
  259. MOVOA X1,X12
  260. PSLLL $7,X1
  261. PXOR X1,X7
  262. PSRLL $25,X12
  263. PXOR X12,X7
  264. MOVOA X8,X1
  265. PADDL X6,X1
  266. MOVOA X1,X12
  267. PSLLL $18,X1
  268. PXOR X1,X2
  269. PSRLL $14,X12
  270. PXOR X12,X2
  271. MOVOA 336(SP),X12
  272. MOVOA X2,336(SP)
  273. MOVOA X14,X1
  274. PADDL X12,X1
  275. MOVOA X1,X2
  276. PSLLL $7,X1
  277. PXOR X1,X5
  278. PSRLL $25,X2
  279. PXOR X2,X5
  280. MOVOA X0,X1
  281. PADDL X7,X1
  282. MOVOA X1,X2
  283. PSLLL $9,X1
  284. PXOR X1,X10
  285. PSRLL $23,X2
  286. PXOR X2,X10
  287. MOVOA X12,X1
  288. PADDL X5,X1
  289. MOVOA X1,X2
  290. PSLLL $9,X1
  291. PXOR X1,X8
  292. PSRLL $23,X2
  293. PXOR X2,X8
  294. MOVOA X7,X1
  295. PADDL X10,X1
  296. MOVOA X1,X2
  297. PSLLL $13,X1
  298. PXOR X1,X4
  299. PSRLL $19,X2
  300. PXOR X2,X4
  301. MOVOA X5,X1
  302. PADDL X8,X1
  303. MOVOA X1,X2
  304. PSLLL $13,X1
  305. PXOR X1,X14
  306. PSRLL $19,X2
  307. PXOR X2,X14
  308. MOVOA X10,X1
  309. PADDL X4,X1
  310. MOVOA X1,X2
  311. PSLLL $18,X1
  312. PXOR X1,X0
  313. PSRLL $14,X2
  314. PXOR X2,X0
  315. MOVOA 320(SP),X1
  316. MOVOA X0,320(SP)
  317. MOVOA X8,X0
  318. PADDL X14,X0
  319. MOVOA X0,X2
  320. PSLLL $18,X0
  321. PXOR X0,X12
  322. PSRLL $14,X2
  323. PXOR X2,X12
  324. MOVOA X11,X0
  325. PADDL X1,X0
  326. MOVOA X0,X2
  327. PSLLL $7,X0
  328. PXOR X0,X6
  329. PSRLL $25,X2
  330. PXOR X2,X6
  331. MOVOA 336(SP),X2
  332. MOVOA X12,336(SP)
  333. MOVOA X3,X0
  334. PADDL X2,X0
  335. MOVOA X0,X12
  336. PSLLL $7,X0
  337. PXOR X0,X13
  338. PSRLL $25,X12
  339. PXOR X12,X13
  340. MOVOA X1,X0
  341. PADDL X6,X0
  342. MOVOA X0,X12
  343. PSLLL $9,X0
  344. PXOR X0,X15
  345. PSRLL $23,X12
  346. PXOR X12,X15
  347. MOVOA X2,X0
  348. PADDL X13,X0
  349. MOVOA X0,X12
  350. PSLLL $9,X0
  351. PXOR X0,X9
  352. PSRLL $23,X12
  353. PXOR X12,X9
  354. MOVOA X6,X0
  355. PADDL X15,X0
  356. MOVOA X0,X12
  357. PSLLL $13,X0
  358. PXOR X0,X11
  359. PSRLL $19,X12
  360. PXOR X12,X11
  361. MOVOA X13,X0
  362. PADDL X9,X0
  363. MOVOA X0,X12
  364. PSLLL $13,X0
  365. PXOR X0,X3
  366. PSRLL $19,X12
  367. PXOR X12,X3
  368. MOVOA X15,X0
  369. PADDL X11,X0
  370. MOVOA X0,X12
  371. PSLLL $18,X0
  372. PXOR X0,X1
  373. PSRLL $14,X12
  374. PXOR X12,X1
  375. MOVOA X9,X0
  376. PADDL X3,X0
  377. MOVOA X0,X12
  378. PSLLL $18,X0
  379. PXOR X0,X2
  380. PSRLL $14,X12
  381. PXOR X12,X2
  382. MOVOA 320(SP),X12
  383. MOVOA 336(SP),X0
  384. SUBQ $2,DX
  385. JA MAINLOOP1
  386. PADDL 112(SP),X12
  387. PADDL 176(SP),X7
  388. PADDL 224(SP),X10
  389. PADDL 272(SP),X4
  390. MOVD X12,DX
  391. MOVD X7,CX
  392. MOVD X10,R8
  393. MOVD X4,R9
  394. PSHUFL $0X39,X12,X12
  395. PSHUFL $0X39,X7,X7
  396. PSHUFL $0X39,X10,X10
  397. PSHUFL $0X39,X4,X4
  398. XORL 0(SI),DX
  399. XORL 4(SI),CX
  400. XORL 8(SI),R8
  401. XORL 12(SI),R9
  402. MOVL DX,0(DI)
  403. MOVL CX,4(DI)
  404. MOVL R8,8(DI)
  405. MOVL R9,12(DI)
  406. MOVD X12,DX
  407. MOVD X7,CX
  408. MOVD X10,R8
  409. MOVD X4,R9
  410. PSHUFL $0X39,X12,X12
  411. PSHUFL $0X39,X7,X7
  412. PSHUFL $0X39,X10,X10
  413. PSHUFL $0X39,X4,X4
  414. XORL 64(SI),DX
  415. XORL 68(SI),CX
  416. XORL 72(SI),R8
  417. XORL 76(SI),R9
  418. MOVL DX,64(DI)
  419. MOVL CX,68(DI)
  420. MOVL R8,72(DI)
  421. MOVL R9,76(DI)
  422. MOVD X12,DX
  423. MOVD X7,CX
  424. MOVD X10,R8
  425. MOVD X4,R9
  426. PSHUFL $0X39,X12,X12
  427. PSHUFL $0X39,X7,X7
  428. PSHUFL $0X39,X10,X10
  429. PSHUFL $0X39,X4,X4
  430. XORL 128(SI),DX
  431. XORL 132(SI),CX
  432. XORL 136(SI),R8
  433. XORL 140(SI),R9
  434. MOVL DX,128(DI)
  435. MOVL CX,132(DI)
  436. MOVL R8,136(DI)
  437. MOVL R9,140(DI)
  438. MOVD X12,DX
  439. MOVD X7,CX
  440. MOVD X10,R8
  441. MOVD X4,R9
  442. XORL 192(SI),DX
  443. XORL 196(SI),CX
  444. XORL 200(SI),R8
  445. XORL 204(SI),R9
  446. MOVL DX,192(DI)
  447. MOVL CX,196(DI)
  448. MOVL R8,200(DI)
  449. MOVL R9,204(DI)
  450. PADDL 240(SP),X14
  451. PADDL 64(SP),X0
  452. PADDL 128(SP),X5
  453. PADDL 192(SP),X8
  454. MOVD X14,DX
  455. MOVD X0,CX
  456. MOVD X5,R8
  457. MOVD X8,R9
  458. PSHUFL $0X39,X14,X14
  459. PSHUFL $0X39,X0,X0
  460. PSHUFL $0X39,X5,X5
  461. PSHUFL $0X39,X8,X8
  462. XORL 16(SI),DX
  463. XORL 20(SI),CX
  464. XORL 24(SI),R8
  465. XORL 28(SI),R9
  466. MOVL DX,16(DI)
  467. MOVL CX,20(DI)
  468. MOVL R8,24(DI)
  469. MOVL R9,28(DI)
  470. MOVD X14,DX
  471. MOVD X0,CX
  472. MOVD X5,R8
  473. MOVD X8,R9
  474. PSHUFL $0X39,X14,X14
  475. PSHUFL $0X39,X0,X0
  476. PSHUFL $0X39,X5,X5
  477. PSHUFL $0X39,X8,X8
  478. XORL 80(SI),DX
  479. XORL 84(SI),CX
  480. XORL 88(SI),R8
  481. XORL 92(SI),R9
  482. MOVL DX,80(DI)
  483. MOVL CX,84(DI)
  484. MOVL R8,88(DI)
  485. MOVL R9,92(DI)
  486. MOVD X14,DX
  487. MOVD X0,CX
  488. MOVD X5,R8
  489. MOVD X8,R9
  490. PSHUFL $0X39,X14,X14
  491. PSHUFL $0X39,X0,X0
  492. PSHUFL $0X39,X5,X5
  493. PSHUFL $0X39,X8,X8
  494. XORL 144(SI),DX
  495. XORL 148(SI),CX
  496. XORL 152(SI),R8
  497. XORL 156(SI),R9
  498. MOVL DX,144(DI)
  499. MOVL CX,148(DI)
  500. MOVL R8,152(DI)
  501. MOVL R9,156(DI)
  502. MOVD X14,DX
  503. MOVD X0,CX
  504. MOVD X5,R8
  505. MOVD X8,R9
  506. XORL 208(SI),DX
  507. XORL 212(SI),CX
  508. XORL 216(SI),R8
  509. XORL 220(SI),R9
  510. MOVL DX,208(DI)
  511. MOVL CX,212(DI)
  512. MOVL R8,216(DI)
  513. MOVL R9,220(DI)
  514. PADDL 288(SP),X15
  515. PADDL 304(SP),X11
  516. PADDL 80(SP),X1
  517. PADDL 144(SP),X6
  518. MOVD X15,DX
  519. MOVD X11,CX
  520. MOVD X1,R8
  521. MOVD X6,R9
  522. PSHUFL $0X39,X15,X15
  523. PSHUFL $0X39,X11,X11
  524. PSHUFL $0X39,X1,X1
  525. PSHUFL $0X39,X6,X6
  526. XORL 32(SI),DX
  527. XORL 36(SI),CX
  528. XORL 40(SI),R8
  529. XORL 44(SI),R9
  530. MOVL DX,32(DI)
  531. MOVL CX,36(DI)
  532. MOVL R8,40(DI)
  533. MOVL R9,44(DI)
  534. MOVD X15,DX
  535. MOVD X11,CX
  536. MOVD X1,R8
  537. MOVD X6,R9
  538. PSHUFL $0X39,X15,X15
  539. PSHUFL $0X39,X11,X11
  540. PSHUFL $0X39,X1,X1
  541. PSHUFL $0X39,X6,X6
  542. XORL 96(SI),DX
  543. XORL 100(SI),CX
  544. XORL 104(SI),R8
  545. XORL 108(SI),R9
  546. MOVL DX,96(DI)
  547. MOVL CX,100(DI)
  548. MOVL R8,104(DI)
  549. MOVL R9,108(DI)
  550. MOVD X15,DX
  551. MOVD X11,CX
  552. MOVD X1,R8
  553. MOVD X6,R9
  554. PSHUFL $0X39,X15,X15
  555. PSHUFL $0X39,X11,X11
  556. PSHUFL $0X39,X1,X1
  557. PSHUFL $0X39,X6,X6
  558. XORL 160(SI),DX
  559. XORL 164(SI),CX
  560. XORL 168(SI),R8
  561. XORL 172(SI),R9
  562. MOVL DX,160(DI)
  563. MOVL CX,164(DI)
  564. MOVL R8,168(DI)
  565. MOVL R9,172(DI)
  566. MOVD X15,DX
  567. MOVD X11,CX
  568. MOVD X1,R8
  569. MOVD X6,R9
  570. XORL 224(SI),DX
  571. XORL 228(SI),CX
  572. XORL 232(SI),R8
  573. XORL 236(SI),R9
  574. MOVL DX,224(DI)
  575. MOVL CX,228(DI)
  576. MOVL R8,232(DI)
  577. MOVL R9,236(DI)
  578. PADDL 160(SP),X13
  579. PADDL 208(SP),X9
  580. PADDL 256(SP),X3
  581. PADDL 96(SP),X2
  582. MOVD X13,DX
  583. MOVD X9,CX
  584. MOVD X3,R8
  585. MOVD X2,R9
  586. PSHUFL $0X39,X13,X13
  587. PSHUFL $0X39,X9,X9
  588. PSHUFL $0X39,X3,X3
  589. PSHUFL $0X39,X2,X2
  590. XORL 48(SI),DX
  591. XORL 52(SI),CX
  592. XORL 56(SI),R8
  593. XORL 60(SI),R9
  594. MOVL DX,48(DI)
  595. MOVL CX,52(DI)
  596. MOVL R8,56(DI)
  597. MOVL R9,60(DI)
  598. MOVD X13,DX
  599. MOVD X9,CX
  600. MOVD X3,R8
  601. MOVD X2,R9
  602. PSHUFL $0X39,X13,X13
  603. PSHUFL $0X39,X9,X9
  604. PSHUFL $0X39,X3,X3
  605. PSHUFL $0X39,X2,X2
  606. XORL 112(SI),DX
  607. XORL 116(SI),CX
  608. XORL 120(SI),R8
  609. XORL 124(SI),R9
  610. MOVL DX,112(DI)
  611. MOVL CX,116(DI)
  612. MOVL R8,120(DI)
  613. MOVL R9,124(DI)
  614. MOVD X13,DX
  615. MOVD X9,CX
  616. MOVD X3,R8
  617. MOVD X2,R9
  618. PSHUFL $0X39,X13,X13
  619. PSHUFL $0X39,X9,X9
  620. PSHUFL $0X39,X3,X3
  621. PSHUFL $0X39,X2,X2
  622. XORL 176(SI),DX
  623. XORL 180(SI),CX
  624. XORL 184(SI),R8
  625. XORL 188(SI),R9
  626. MOVL DX,176(DI)
  627. MOVL CX,180(DI)
  628. MOVL R8,184(DI)
  629. MOVL R9,188(DI)
  630. MOVD X13,DX
  631. MOVD X9,CX
  632. MOVD X3,R8
  633. MOVD X2,R9
  634. XORL 240(SI),DX
  635. XORL 244(SI),CX
  636. XORL 248(SI),R8
  637. XORL 252(SI),R9
  638. MOVL DX,240(DI)
  639. MOVL CX,244(DI)
  640. MOVL R8,248(DI)
  641. MOVL R9,252(DI)
  642. MOVQ 352(SP),R9
  643. SUBQ $256,R9
  644. ADDQ $256,SI
  645. ADDQ $256,DI
  646. CMPQ R9,$256
  647. JAE BYTESATLEAST256
  648. CMPQ R9,$0
  649. JBE DONE
  650. BYTESBETWEEN1AND255:
  651. CMPQ R9,$64
  652. JAE NOCOPY
  653. MOVQ DI,DX
  654. LEAQ 360(SP),DI
  655. MOVQ R9,CX
  656. REP; MOVSB
  657. LEAQ 360(SP),DI
  658. LEAQ 360(SP),SI
  659. NOCOPY:
  660. MOVQ R9,352(SP)
  661. MOVOA 48(SP),X0
  662. MOVOA 0(SP),X1
  663. MOVOA 16(SP),X2
  664. MOVOA 32(SP),X3
  665. MOVOA X1,X4
  666. MOVQ $20,CX
  667. MAINLOOP2:
  668. PADDL X0,X4
  669. MOVOA X0,X5
  670. MOVOA X4,X6
  671. PSLLL $7,X4
  672. PSRLL $25,X6
  673. PXOR X4,X3
  674. PXOR X6,X3
  675. PADDL X3,X5
  676. MOVOA X3,X4
  677. MOVOA X5,X6
  678. PSLLL $9,X5
  679. PSRLL $23,X6
  680. PXOR X5,X2
  681. PSHUFL $0X93,X3,X3
  682. PXOR X6,X2
  683. PADDL X2,X4
  684. MOVOA X2,X5
  685. MOVOA X4,X6
  686. PSLLL $13,X4
  687. PSRLL $19,X6
  688. PXOR X4,X1
  689. PSHUFL $0X4E,X2,X2
  690. PXOR X6,X1
  691. PADDL X1,X5
  692. MOVOA X3,X4
  693. MOVOA X5,X6
  694. PSLLL $18,X5
  695. PSRLL $14,X6
  696. PXOR X5,X0
  697. PSHUFL $0X39,X1,X1
  698. PXOR X6,X0
  699. PADDL X0,X4
  700. MOVOA X0,X5
  701. MOVOA X4,X6
  702. PSLLL $7,X4
  703. PSRLL $25,X6
  704. PXOR X4,X1
  705. PXOR X6,X1
  706. PADDL X1,X5
  707. MOVOA X1,X4
  708. MOVOA X5,X6
  709. PSLLL $9,X5
  710. PSRLL $23,X6
  711. PXOR X5,X2
  712. PSHUFL $0X93,X1,X1
  713. PXOR X6,X2
  714. PADDL X2,X4
  715. MOVOA X2,X5
  716. MOVOA X4,X6
  717. PSLLL $13,X4
  718. PSRLL $19,X6
  719. PXOR X4,X3
  720. PSHUFL $0X4E,X2,X2
  721. PXOR X6,X3
  722. PADDL X3,X5
  723. MOVOA X1,X4
  724. MOVOA X5,X6
  725. PSLLL $18,X5
  726. PSRLL $14,X6
  727. PXOR X5,X0
  728. PSHUFL $0X39,X3,X3
  729. PXOR X6,X0
  730. PADDL X0,X4
  731. MOVOA X0,X5
  732. MOVOA X4,X6
  733. PSLLL $7,X4
  734. PSRLL $25,X6
  735. PXOR X4,X3
  736. PXOR X6,X3
  737. PADDL X3,X5
  738. MOVOA X3,X4
  739. MOVOA X5,X6
  740. PSLLL $9,X5
  741. PSRLL $23,X6
  742. PXOR X5,X2
  743. PSHUFL $0X93,X3,X3
  744. PXOR X6,X2
  745. PADDL X2,X4
  746. MOVOA X2,X5
  747. MOVOA X4,X6
  748. PSLLL $13,X4
  749. PSRLL $19,X6
  750. PXOR X4,X1
  751. PSHUFL $0X4E,X2,X2
  752. PXOR X6,X1
  753. PADDL X1,X5
  754. MOVOA X3,X4
  755. MOVOA X5,X6
  756. PSLLL $18,X5
  757. PSRLL $14,X6
  758. PXOR X5,X0
  759. PSHUFL $0X39,X1,X1
  760. PXOR X6,X0
  761. PADDL X0,X4
  762. MOVOA X0,X5
  763. MOVOA X4,X6
  764. PSLLL $7,X4
  765. PSRLL $25,X6
  766. PXOR X4,X1
  767. PXOR X6,X1
  768. PADDL X1,X5
  769. MOVOA X1,X4
  770. MOVOA X5,X6
  771. PSLLL $9,X5
  772. PSRLL $23,X6
  773. PXOR X5,X2
  774. PSHUFL $0X93,X1,X1
  775. PXOR X6,X2
  776. PADDL X2,X4
  777. MOVOA X2,X5
  778. MOVOA X4,X6
  779. PSLLL $13,X4
  780. PSRLL $19,X6
  781. PXOR X4,X3
  782. PSHUFL $0X4E,X2,X2
  783. PXOR X6,X3
  784. SUBQ $4,CX
  785. PADDL X3,X5
  786. MOVOA X1,X4
  787. MOVOA X5,X6
  788. PSLLL $18,X5
  789. PXOR X7,X7
  790. PSRLL $14,X6
  791. PXOR X5,X0
  792. PSHUFL $0X39,X3,X3
  793. PXOR X6,X0
  794. JA MAINLOOP2
  795. PADDL 48(SP),X0
  796. PADDL 0(SP),X1
  797. PADDL 16(SP),X2
  798. PADDL 32(SP),X3
  799. MOVD X0,CX
  800. MOVD X1,R8
  801. MOVD X2,R9
  802. MOVD X3,AX
  803. PSHUFL $0X39,X0,X0
  804. PSHUFL $0X39,X1,X1
  805. PSHUFL $0X39,X2,X2
  806. PSHUFL $0X39,X3,X3
  807. XORL 0(SI),CX
  808. XORL 48(SI),R8
  809. XORL 32(SI),R9
  810. XORL 16(SI),AX
  811. MOVL CX,0(DI)
  812. MOVL R8,48(DI)
  813. MOVL R9,32(DI)
  814. MOVL AX,16(DI)
  815. MOVD X0,CX
  816. MOVD X1,R8
  817. MOVD X2,R9
  818. MOVD X3,AX
  819. PSHUFL $0X39,X0,X0
  820. PSHUFL $0X39,X1,X1
  821. PSHUFL $0X39,X2,X2
  822. PSHUFL $0X39,X3,X3
  823. XORL 20(SI),CX
  824. XORL 4(SI),R8
  825. XORL 52(SI),R9
  826. XORL 36(SI),AX
  827. MOVL CX,20(DI)
  828. MOVL R8,4(DI)
  829. MOVL R9,52(DI)
  830. MOVL AX,36(DI)
  831. MOVD X0,CX
  832. MOVD X1,R8
  833. MOVD X2,R9
  834. MOVD X3,AX
  835. PSHUFL $0X39,X0,X0
  836. PSHUFL $0X39,X1,X1
  837. PSHUFL $0X39,X2,X2
  838. PSHUFL $0X39,X3,X3
  839. XORL 40(SI),CX
  840. XORL 24(SI),R8
  841. XORL 8(SI),R9
  842. XORL 56(SI),AX
  843. MOVL CX,40(DI)
  844. MOVL R8,24(DI)
  845. MOVL R9,8(DI)
  846. MOVL AX,56(DI)
  847. MOVD X0,CX
  848. MOVD X1,R8
  849. MOVD X2,R9
  850. MOVD X3,AX
  851. XORL 60(SI),CX
  852. XORL 44(SI),R8
  853. XORL 28(SI),R9
  854. XORL 12(SI),AX
  855. MOVL CX,60(DI)
  856. MOVL R8,44(DI)
  857. MOVL R9,28(DI)
  858. MOVL AX,12(DI)
  859. MOVQ 352(SP),R9
  860. MOVL 16(SP),CX
  861. MOVL 36 (SP),R8
  862. ADDQ $1,CX
  863. SHLQ $32,R8
  864. ADDQ R8,CX
  865. MOVQ CX,R8
  866. SHRQ $32,R8
  867. MOVL CX,16(SP)
  868. MOVL R8, 36 (SP)
  869. CMPQ R9,$64
  870. JA BYTESATLEAST65
  871. JAE BYTESATLEAST64
  872. MOVQ DI,SI
  873. MOVQ DX,DI
  874. MOVQ R9,CX
  875. REP; MOVSB
  876. BYTESATLEAST64:
  877. DONE:
  878. MOVQ R12,SP
  879. RET
  880. BYTESATLEAST65:
  881. SUBQ $64,R9
  882. ADDQ $64,DI
  883. ADDQ $64,SI
  884. JMP BYTESBETWEEN1AND255