drand48_sub proc near iterations = dword ptr 4 mov edx, [esp+iterations] cmp edx, 100h push esi push edi mov esi, ecx jnb short morethan255 ; jumps when not carry mov eax, [esi+4] mov ecx, [esi] shl edx, 4 push eax mov edi, edx mov edx, dword ptr (seedTable+4)[edi] mov eax, dword ptr seedTable[edi] ; contains 1 push ecx push edx push eax call __allmul add eax, dword ptr (seedTable+8)[edi] adc edx, dword ptr (seedTable+0Ch)[edi] ; contains 5DEECE66D (drand48 multiplier) pop edi mov [esi+4], edx mov [esi], eax pop esi retn 4 ; --------------------------------------------------------------------------- morethan255: ; CODE XREF: drand48_sub+Ej test edx, edx ; clears carry, zero = edx==0 mov eax, [esi] mov ecx, [esi+4] jbe short return ; jumps on carry or zero mov edi, edx rand48_loop: ; CODE XREF: drand48_sub+69j push 5 push 0DEECE66Dh ; drand48 multiplier push ecx push eax call __allmul add eax, 0Bh adc edx, 0 sub edi, 1 mov ecx, edx jnz short rand48_loop return: ; CODE XREF: drand48_sub+4Cj pop edi mov [esi+4], ecx mov [esi], eax pop esi retn 4 drand48_sub endp