@@ -122,14 +122,16 @@ bigint_subtract_raw ( const uint64_t *subtrahend0, uint64_t *value0,
122
122
*
123
123
* @v value0 Element 0 of big integer
124
124
* @v size Number of elements
125
+ * @ret out Bit shifted out
125
126
*/
126
- static inline __attribute__ (( always_inline )) void
127
+ static inline __attribute__ (( always_inline )) int
127
128
bigint_shl_raw ( uint64_t * value0 , unsigned int size ) {
128
129
bigint_t ( size ) __attribute__ (( may_alias )) * value =
129
130
( ( void * ) value0 );
130
131
uint64_t * discard_value ;
131
132
uint64_t discard_value_i ;
132
133
unsigned int discard_size ;
134
+ int carry ;
133
135
134
136
__asm__ __volatile__ ( "cmn xzr, xzr\n\t" /* clear CF */
135
137
"\n1:\n\t"
@@ -141,40 +143,43 @@ bigint_shl_raw ( uint64_t *value0, unsigned int size ) {
141
143
: "=r" ( discard_value ),
142
144
"=r" ( discard_size ),
143
145
"=r" ( discard_value_i ),
146
+ "=@cccs" ( carry ),
144
147
"+m" ( * value )
145
- : "0" ( value0 ), "1" ( size )
146
- : "cc" ) ;
148
+ : "0" ( value0 ), "1" ( size ) );
149
+ return carry ;
147
150
}
148
151
149
152
/**
150
153
* Shift big integer right
151
154
*
152
155
* @v value0 Element 0 of big integer
153
156
* @v size Number of elements
157
+ * @ret out Bit shifted out
154
158
*/
155
- static inline __attribute__ (( always_inline )) void
159
+ static inline __attribute__ (( always_inline )) int
156
160
bigint_shr_raw ( uint64_t * value0 , unsigned int size ) {
157
161
bigint_t ( size ) __attribute__ (( may_alias )) * value =
158
162
( ( void * ) value0 );
159
163
uint64_t * discard_value ;
160
- uint64_t discard_value_i ;
161
- uint64_t discard_value_j ;
164
+ uint64_t discard_high ;
162
165
unsigned int discard_size ;
166
+ uint64_t low ;
163
167
164
- __asm__ __volatile__ ( "mov %3 , #0\n\t"
168
+ __asm__ __volatile__ ( "mov %2 , #0\n\t"
165
169
"\n1:\n\t"
166
170
"sub %w1, %w1, #1\n\t"
167
- "ldr %2 , [%0, %1, lsl #3]\n\t"
168
- "extr %3 , %3 , %2 , #1\n\t"
169
- "str %3 , [%0, %1, lsl #3]\n\t"
170
- "mov %3 , %2 \n\t"
171
+ "ldr %3 , [%0, %1, lsl #3]\n\t"
172
+ "extr %2 , %2 , %3 , #1\n\t"
173
+ "str %2 , [%0, %1, lsl #3]\n\t"
174
+ "mov %2 , %3 \n\t"
171
175
"cbnz %w1, 1b\n\t"
172
176
: "=r" ( discard_value ),
173
177
"=r" ( discard_size ),
174
- "=r" ( discard_value_i ),
175
- "=r" ( discard_value_j ),
178
+ "=r" ( discard_high ),
179
+ "=r" ( low ),
176
180
"+m" ( * value )
177
181
: "0" ( value0 ), "1" ( size ) );
182
+ return ( low & 1 );
178
183
}
179
184
180
185
/**
0 commit comments