3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #define S32_1(x) ( (SHR32((x), 1)) ^ \
25 #define S32_2(x) ( (SHR32((x), 2)) ^ \
30 #define S32_3(x) ( (SHR32((x), 2)) ^ \
35 #define S32_4(x) ( (SHR32((x), 1)) ^ (x))
37 #define S32_5(x) ( (SHR32((x), 2)) ^ (x))
40 $s32_0_lut = [ 1, 3, 4, 13]
41 $s32_1_lut = [ 1, 2, 8, 9]
42 $s32_2_lut = [ 2, 1, 12, 7]
43 $s32_3_lut = [ 2, 2, 15, 3]
45 $s32_lut = [$s32_0_lut, $s32_1_lut, $s32_2_lut, $s32_3_lut]
47 def s32_0(fout, select, reg0, reg1)
49 fout.puts("\tmov %s, %s", reg1, reg0)
50 fout.puts("\tlsrs %s, %s, #%d", reg0, reg0, $s32_lut[select][0])
51 fout.puts("\teor %s, %s, %s, lsl #%d", reg0, reg0, reg1, $s32_lut[select][1])
52 fout.puts("\teor %s, %s, %s, ror #%d", reg0, reg0, reg1, 32-$s32_lut[select][2])
53 fout.puts("\teor %s, %s, %s, ror #%d", reg0, reg0, reg1, $s32_lut[select][3])
55 fout.puts("\teor %s, %s, %s, ror #%d", reg0, reg0, reg0, 1) if select==4
56 fout.puts("\teor %s, %s, %s, ror #%d", reg0, reg0, reg0, 2) if select==5