hi , i want to generate random number to use it in my iphone project by Inlining in my objective-c code some assembly , is this possible with arm-assembly ?! Thank you to help ..
+1
A:
Look up lfsr on google, linear feedback shift register. Not a true random number generator but you can make pretty good random numbers with maybe three or four lines of assembler.
dwelch
2010-08-18 13:33:27
A:
Jost load a variable from an uninitialized memory address. At every access, increment address to get new random numbers. Voila, guarenteed random, but not well distributed.
codymanix
2010-08-18 13:36:43
Also, will crash the program eventually (if not right away). There's memory protection on ARM, y'know.
Seva Alekseyev
2010-08-18 13:47:08
If you stay in your application's memory you won't have problems with that.
codymanix
2010-08-18 14:18:28
Still sounds pretty sketchy to me...
zdav
2010-08-18 15:50:38
I don't doubt this :)
codymanix
2010-08-19 08:56:20
@codymanix: still no guarantee, you may hit an unallocated address or an execute-only, no-read page. Or a guard page.
Seva Alekseyev
2010-08-21 14:30:17
+1
A:
Go to Wikipedia, find the easiest random number generation algorithm, reimplement in assembly :)
Seva Alekseyev
2010-08-18 13:50:32