RdRand.exe: Robust random numbers for Batch files

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: RdRand.exe: Robust random numbers for Batch files

#16 Post by foxidrive » 22 Oct 2016 07:45

She no go here.

Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz

Windows 8.1 32 bit
Is 32 bit an issue? I wouldn't have thought so.

Code: Select all

c:\Files>rdrand

c:\Files>echo %errorlevel%
0

c:\Files>rdrand

c:\Files>echo %errorlevel%
0



Downloaded second copy to compare.

Code: Select all

Comparing files C:\FILES\RdRand.zip and C:\FILES\RDRAND(1).ZIP
FC: no differences encountered


It's possible I have the first version from an ISP cache...


RdRand.exe 1,536 21/10/2016 00:19 -a--


Help! 8) Just stirring


Code: Select all

 INFO.BAT version 1.2
--------------------------------------------------------------------------------
Windows version        :  Microsoft Windows [Version 6.3.9600]
Product name           :  Windows 8.1 Pro with Media Center, 32 bit
Performance indicators :  Processor Cores: 8      Visible RAM: 3390692 kilobytes

Date/Time format       :  (dd/mm/yy)  Sun 23/10/2016   0:47:34.27
__APPDIR__             :  C:\WINDOWS\system32\
ComSpec                :  C:\WINDOWS\system32\cmd.exe
PathExt                :  .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Extensions             :  system: Enabled   user: Enabled
Delayed expansion      :  system: Disabled  user: Disabled
Locale name            :  en-AU       Code Pages: OEM  850    ANSI 1252
DIR  format            :  22/10/2016  00:59     3,484,418,048 pagefile.sys
Permissions            :  Elevated Admin=Yes, Admin group=Yes


einstein1969
Expert
Posts: 763
Joined: 15 Jun 2012 13:16
Location: Italy, Rome

Re: RdRand.exe: Robust random numbers for Batch files

#17 Post by einstein1969 » 22 Oct 2016 09:02

On my old intel celeron I aspect 0.

But my "Avira antivir" found a "HEUR/APC (Cloud)' model.

All work fine without antivirus active (ERRORLEVEL=0)

Great utility! I think at Montecarlo methods for graphics generation :)

einstein1969

ShadowThief
Expert
Posts: 908
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: RdRand.exe: Robust random numbers for Batch files

#18 Post by ShadowThief » 22 Oct 2016 09:11

foxidrive wrote:She no go here.

Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz

Windows 8.1 32 bit
Is 32 bit an issue? I wouldn't have thought so.

Looks like your processor predates the Ivy Bridge entropy chip.

Aacini
Expert
Posts: 1615
Joined: 06 Dec 2011 22:15
Location: México City, México

Re: RdRand.exe: Robust random numbers for Batch files

#19 Post by Aacini » 22 Oct 2016 11:22

SirJosh3917 wrote:Can you point me towards the direction of AMD & Intel's guide for assembly?

You may download the Intel documents from this site. I never had required to review a specific AMD document, but a quick google search gives me this AMD link.



penpen wrote:Actually your "RdRand.exe" returns 0 if the RDRAND instruction is not supported, which i think should be a bug.
You better should return a number outside the range of the generated random numbers [0 : 65535] for indicating RDRAND is not supported (for example -2).

The random numbers generated by RDRAND instructions are greater than zero. From the documentation: "Table 3. - Destination register valid. Non-zero random value available at time of execution. Result placed in register". I changed the range in the description at first post of this thread.



misol101 wrote:Why are you looping? Is the random instruction only working on random occasions? :D

the documentation wrote:After invoking the RDRAND instruction, the caller must examine the carry flag (CF) to determine whether a random value was available at the time the RDRAND instruction was executed. As Table 3 shows, a value of 1 indicates that a random value was available and placed in the destination register provided in the invocation. A value of 0 indicates that a random value was not available.

4.2.1 Retry Recommendations

It is recommended that applications attempt 10 retries in a tight loop in the unlikely event that the RDRAND instruction does not return a random number. This number is based on a binomial probability argument: given the design margins of the DRNG, the odds of ten failures in a row are astronomically small and would in fact be an indication of a larger CPU issue.




@foxidrive: The documentation specify that there is not any restriction that may prevent RdRand.exe from work in any computer that support RDRAND instruction, and it seems that your Core i7 processor should support it. Sorry, but I have no idea of what may happen in your computer... :cry:


@all: thanks for the reports! :D


Antonio

foxidrive
Expert
Posts: 6033
Joined: 10 Feb 2012 02:20

Re: RdRand.exe: Robust random numbers for Batch files

#20 Post by foxidrive » 22 Oct 2016 21:52

ShadowThief wrote:
foxidrive wrote:She no go here.

Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz

Windows 8.1 32 bit
Is 32 bit an issue? I wouldn't have thought so.

Looks like your processor predates the Ivy Bridge entropy chip.


Is that a bit like the TARDIS chamelon circuit?? ;)

My CPU might not support the feature it uses but I thought I saw some older units mentioned here reporting that it works.

Aacini wrote:@foxidrive: The documentation specify that there is not any restriction that may prevent RdRand.exe from work in any computer that support RDRAND instruction, and it seems that your Core i7 processor should support it. Sorry, but I have no idea of what may happen in your computer... :cry:

Antonio


Not to worry Antonio.
It's a cool and very tiny utility. Easy to encode into batch scripts.

Post Reply