flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
asmdemon 24 May 2008, 01:23
http://support.microsoft.com/kb/28150 this is the official article from microsoft on the formula they used in quick basic. It's a simple linear-congruential type of RNG.
Code: x1 = ( x0 * a + c ) MOD 2^16 Code: example: mov ax, [seed] mul ax, [a_value] adc ax, [carry] mov [carry], dx mov [seed], ax ax = output rnd number... optional loop to repeat process "MOD" part not needed because ax is 16 bit so output will be 0 to (2^16)-1 the trick however is choosing the a_value and seed value to produce apperant random numbers. http://en.wikipedia.org/wiki/Linear_congruential_generator this list's microsoft's a_value and carry starting values. |
|||
![]() |
|
Dark Dude 24 May 2008, 03:17
Snap, ok, that's great, and it's pretty much entirely answered my main point...
However, I see most main algorithms using the timestamp as the seed... How do you get this timestamp in 8086? I've looked everywhere, and all I'm told is to use the MS-DOS Get System Timer, but I dont wish to use this, as I wont have access to MS-DOS on this system... |
|||
![]() |
|
f0dder 24 May 2008, 04:12
1) Microsoft don't really apply anti-disasm except to the core that handles validation.
2) you DO NOT use time as a seed, unless you want to be prisonbait. Using time as seed opens you to SO many attacks... iirc, asprotect was broken because of something similar to srand(time(0)). 3) use proper crypto, and forget 16bit unless you HAVE to for a course or whatever. |
|||
![]() |
|
roboman 25 May 2008, 17:03
http://www.ctyme.com/intr/int-1a.htm
is a list of BIOS interrupts for time functions. |
|||
![]() |
|
DOS386 01 Jun 2008, 22:22
> but my disassembler crashes when trying to follow the procedure tree
Bad disassembler ![]() > I see most main algorithms using the timestamp as the seed... > How do you get this timestamp in 8086? 8086 regrettably doesn't have RDTSC ![]() ![]() > I've looked everywhere, and all I'm told is to use > the MS-DOG Get System Timer, but I dont wish to use this, > as I wont have access to MS-DOG on this system... What OS do you have ? Quote: 2) you DO NOT use time as a seed, unless you want to be prisonbait. Using time as seed opens you to SO many attacks... iirc, asprotect was broken because of something similar to srand(time(0)). 3) use proper crypto Nice, but topic starter didn't request high-end crypto security ![]() > and forget 16bit unless you HAVE to for a course or what I can confirm that the MUL algo works. You perfectly can use Mersenne Twister or whatever on 8086 also, just registers are 16-bit in size only and there is the 64 KiB limit. See also: http://board.flatassembler.net/topic.php?t=8690 |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2023, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.