views:

110

answers:

3

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
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
Also, will crash the program eventually (if not right away). There's memory protection on ARM, y'know.
Seva Alekseyev
If you stay in your application's memory you won't have problems with that.
codymanix
Still sounds pretty sketchy to me...
zdav
I don't doubt this :)
codymanix
@codymanix: still no guarantee, you may hit an unallocated address or an execute-only, no-read page. Or a guard page.
Seva Alekseyev
+1  A: 

Go to Wikipedia, find the easiest random number generation algorithm, reimplement in assembly :)

Seva Alekseyev