Author Topic: Random numbers in NASM  (Read 16680 times)

nobody

  • Guest
Random numbers in NASM
« on: December 31, 2008, 12:37:59 AM »
Hello,
I need help with generating random numbers. I'm programming good old classic game Space Invaders :) and most of my code is done, I just need to generate some random numbers, maybe from 1 to 100, to determine when the ufo is going to appear or if the aliens are going to shoot back. I'm using NASM in WinXP. Any help would be nice so I could finish this during the holidays. Thanks in advance.

nobody

  • Guest
Re: Random numbers in NASM
« Reply #1 on: December 31, 2008, 02:54:59 AM »
Google showed me this:

http://www.literatecode.com/get/sapparot2.pdf

Examined it with the new Ollydbg:

CPU Disasm
Address   Hex dump          Command                                  Comments
00401330  /$  55            PUSH EBP                                 ; cprng.00401330(guessed void)
00401331  |.  89E5          MOV EBP,ESP
00401333  |.  A1 10404000   MOV EAX,DWORD PTR DS:[404010]
00401338  |.  0105 30404000 ADD DWORD PTR DS:[404030],EAX
0040133E  |.  A1 20404000   MOV EAX,DWORD PTR DS:[404020]
00401343  |.  89C1          MOV ECX,EAX
00401345  |.  C1E9 1B       SHR ECX,1B
00401348  |.  D305 30404000 ROL DWORD PTR DS:[404030],CL
0040134E  |.  A1 10404000   MOV EAX,DWORD PTR DS:[404010]
00401353  |.  01C0          ADD EAX,EAX
00401355  |.  0305 20404000 ADD EAX,DWORD PTR DS:[404020]
0040135B  |.  8D50 01       LEA EDX,[EAX+1]
0040135E  |.  A1 20404000   MOV EAX,DWORD PTR DS:[404020]
00401363  |.  C1C0 05       ROL EAX,5
00401366  |.  31D0          XOR EAX,EDX
00401368  |.  A3 20404000   MOV DWORD PTR DS:[404020],EAX
0040136D  |.  812D 10404000 SUB DWORD PTR DS:[404010],61C88647
00401377  |.  C105 10404000 ROL DWORD PTR DS:[404010],7
0040137E  |.  8B15 10404000 MOV EDX,DWORD PTR DS:[404010]
00401384  |.  A1 20404000   MOV EAX,DWORD PTR DS:[404020]
00401389  |.  A3 10404000   MOV DWORD PTR DS:[404010],EAX
0040138E  |.  8915 20404000 MOV DWORD PTR DS:[404020],EDX
00401394  |.  A1 20404000   MOV EAX,DWORD PTR DS:[404020]
00401399  |.  3305 30404000 XOR EAX,DWORD PTR DS:[404030]
0040139F  |.  3305 10404000 XOR EAX,DWORD PTR DS:[404010]
004013A5  |.  5D            POP EBP
004013A6  \.  C3            RETN

Nathan.