Re: A86: random numbers
[Prev][Next][Index][Thread]
Re: A86: random numbers
In a message dated 5/5/99 8:05:52 PM Eastern Daylight Time,
akdjr@SoftHome.net writes:
> hi
> sorry to bother everyone with random numbers again, its just that i
recently
> lost all of my email (plus 40 or so other programs because of
Half-life....)
> including the ones on random numbers.
> i was looking for a routine that could generate a random (or pseudorandom)
> number that would generate a number between a lower bound and an upper
bound.
> for example- if 1 is in a and 14 is in b, then the routine should generate
a
> number between 1 and 14 inclusive. does anyone know of such a routine? or
> does someone know how i could make one? (i would need help step by step
> though.....). also if it involves ops, then i would need help on those as
> well.
> thanks a million
well, if you don't want to use the r register (which doesn't give very random
stuff), then the ops are a good way of doing it.
this is a routine which returns in a a random number between a and b. it
uses the system call _randint which returns in OP1 a random integer between
OP1 and OP2.
_randint equ $5544
Rand:
call _SetXXOP1 ;OP1=a (lower bound)
ld a,b
call _SetXXOP2 ;OP2=a (upper bound)
call _randint ;get random number between OP1 and OP2
jp _convOP1 ;put random number in a and return
Follow-Ups: