Hi there guys,
Im looking to generate random numbers on demand, and I suppose the IPC Link is able to do this, by issuing the RAND_CMD (http://sinclairql.net/downloads/1984-00 ... d-SQPP.pdf, page 142); but I find no documentation as how to form the IPC command.
Is anyone able to point me into the right direction?
Regards,
Wietze
IPC Command RAND_CMD ($14)
- janbredenbeek
- Super Gold Card
- Posts: 673
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: IPC Command RAND_CMD ($14)
From Andrew Pennell's QDOS Companion:spkr wrote:Hi there guys,
Im looking to generate random numbers on demand, and I suppose the IPC Link is able to do this, by issuing the RAND_CMD (http://sinclairql.net/downloads/1984-00 ... d-SQPP.pdf, page 142); but I find no documentation as how to form the IPC command.
"This command is $E 0 ? ? ? ? 2 which returns a pseudo-random number. It is best to use only the lowest four bits though, as the highest bits tend to be zero most of the time. This is not a very good way of generating random numbers, and it's better either to read the system variable SV.RAND, or to generate your own with the floating point maths routines."
Regards, Jan.
Re: IPC Command RAND_CMD ($14)
Thanks for the reply, yeah it seems that getting 4 bits of randomness is a bit meh. Thanks, Ill read the system variable once to use as a seed and implement some pseudorandom number generation based on that.
-
- Aurora
- Posts: 889
- Joined: Mon Nov 24, 2014 2:03 pm
Re: IPC Command RAND_CMD ($14)
Hi,
Yes Jan, we can write our own 9-digit integer random number routines.
But the main problem is how to SEED the generator : Quite easy on a QL emulator, but very hard on a non-multitasking QL !
(I have used a few methods, but none are fully satisfying).
Randomness is a subject of continued research by specialists...
Steve.
PS: if you want BIG random integers, the easiest solution is to concatenate QL ones yourself.
Yes Jan, we can write our own 9-digit integer random number routines.
But the main problem is how to SEED the generator : Quite easy on a QL emulator, but very hard on a non-multitasking QL !
(I have used a few methods, but none are fully satisfying).
Randomness is a subject of continued research by specialists...
Steve.
PS: if you want BIG random integers, the easiest solution is to concatenate QL ones yourself.
- XorA
- Site Admin
- Posts: 1631
- Joined: Thu Jun 02, 2011 11:31 am
- Location: Shotts, North Lanarkshire, Scotland, UK
Re: IPC Command RAND_CMD ($14)
Not really, anything made in last decade has hardware randomness, PN junction noise and other such simple techniques.stevepoole wrote: Randomness is a subject of continued research by specialists...
- janbredenbeek
- Super Gold Card
- Posts: 673
- Joined: Wed Jan 21, 2015 4:54 pm
- Location: Hilversum, The Netherlands
- Contact:
Re: IPC Command RAND_CMD ($14)
I believe SV.RAND uses a better random generator algorithm on SMSQ/E than on QDOS/Minerva, which just increments it on every scheduler loop.
- NormanDunbar
- Forum Moderator
- Posts: 2470
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Buckie, Scotland
- Contact:
Re: IPC Command RAND_CMD ($14)
I did some randomisation stuff in the somewhat irregular ePeriodical on assembly language, Issue 8. Available at https://github.com/NormanDunbar/QLAssem ... ag/Issue_8, it all kicks off on page 47.
If it's of any use? Basically it is pretty much a blatant rip off of the SMSQ code!
Cheers,
Norm.
If it's of any use? Basically it is pretty much a blatant rip off of the SMSQ code!
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.