| 1240 | AS2( lea ebx, [ebx+4*esi]) // ebx is end of B |
| 1241 | |
| 1242 | AS2( sar eax, 1) // unit of eax is now dwords; this also |
| 1243 | // clears the carry flag |
| 1244 | AS1( jz loopendAdd) // if no dwords then nothing to do |
| 1245 | |
| 1246 | AS1(loopstartAdd:) |
| 1247 | AS2( mov esi,[edx]) // load lower word of A |
| 1248 | AS2( mov ebp,[edx+4]) // load higher word of A |
| 1249 | |
| 1250 | AS2( mov edi,[ebx+8*eax]) // load lower word of B |
| 1251 | AS2( lea edx,[edx+8]) // advance A and C |
| 1252 | |
| 1253 | AS2( adc esi,edi) // add lower words |
| 1254 | AS2( mov edi,[ebx+8*eax+4]) // load higher word of B |
| 1255 | |
| 1256 | AS2( adc ebp,edi) // add higher words |
| 1257 | AS1( inc eax) // advance B |
| 1258 | |
| 1259 | AS2( mov [edx+ecx-8],esi) // store lower word result |
| 1260 | AS2( mov [edx+ecx-4],ebp) // store higher word result |
| 1261 | |
| 1262 | AS1( jnz loopstartAdd) // loop until eax overflows and becomes zero |
| 1263 | |
| 1264 | AS1(loopendAdd:) |
| 1265 | AS2( adc eax, 0) // store carry into eax (return result register) |
| 1266 | |
| 1267 | AddEpilogue |
| 1268 | } |
| 1269 | |
| 1270 | TAOCRYPT_NAKED word PentiumOptimized::Subtract(word *C, const word *A, |
| 1271 | const word *B, unsigned int N) |
| 1272 | { |
| 1273 | AddPrologue |
| 1274 | |
| 1275 | // now: ebx = B, ecx = C, edx = A, esi = N |
| 1276 | AS2( sub ecx, edx) // hold the distance between C & A so we |
| 1277 | // can add this to A to get C |
| 1278 | AS2( xor eax, eax) // clear eax |
| 1279 | |
| 1280 | AS2( sub eax, esi) // eax is a negative index from end of B |
| 1281 | AS2( lea ebx, [ebx+4*esi]) // ebx is end of B |
| 1282 | |
| 1283 | AS2( sar eax, 1) // unit of eax is now dwords; this also |
| 1284 | // clears the carry flag |
| 1285 | AS1( jz loopendSub) // if no dwords then nothing to do |
| 1286 | |
| 1287 | AS1(loopstartSub:) |
| 1288 | AS2( mov esi,[edx]) // load lower word of A |
| 1289 | AS2( mov ebp,[edx+4]) // load higher word of A |
| 1290 | |
| 1291 | AS2( mov edi,[ebx+8*eax]) // load lower word of B |
| 1292 | AS2( lea edx,[edx+8]) // advance A and C |
| 1293 | |
| 1294 | AS2( sbb esi,edi) // subtract lower words |
| 1295 | AS2( mov edi,[ebx+8*eax+4]) // load higher word of B |
| 1296 | |
| 1297 | AS2( sbb ebp,edi) // subtract higher words |
| 1298 | AS1( inc eax) // advance B |
| 1299 |
no test coverage detected