Turbo Pascal
From Kenny Root
Turbo Pascal was written by Borland way back when I first started programming. I played a game back then called Trade Wars 2002 and I recently rediscovered it. I read some forums about how certain days seem to be "better" for trading than others and it smacked of a crappy random number generator.
I disassembled a program written in Turbo Pascal and here is the assembly for the random functions:
; Randomize(void) @Randomize$qv proc far mov ah, 2Ch int 21h ; DOS - GET CURRENT TIME ; Return: CH = hours, CL = minutes, DH = seconds ; DL = hundredths of seconds mov word ptr RandSeed, cx mov word ptr RandSeed+2, dx retf @Randomize$qv endp ; Random(Word) @Random$q4Word proc far call permuteSeed mov bx, sp mov cx, dx mul word ptr ss:[bx+4] mov ax, cx mov cx, dx mul word ptr ss:[bx+4] add ax, cx adc dx, 0 mov ax, dx retf 2 @Random$q4Word endp ; PermuteSeed(void) PermuteSeed proc near mov ax, word ptr RandSeed mov bx, word ptr RandSeed+2 mov cx, ax mul cs:word_1DA26 ; dw 8405h shl cx, 1 shl cx, 1 shl cx, 1 add ch, cl add dx, cx add dx, bx shl bx, 1 shl bx, 1 add dx, bx add dh, bl mov cl, 5 shl bx, cl add dh, bl add ax, 1 adc dx, 0 mov word ptr RandSeed, ax mov word ptr RandSeed+2, dx retn permuteSeed endp
