A86: Re: Randomness...
[Prev][Next][Index][Thread]
A86: Re: Randomness...
One bug (aside from the case being wrong on most of the calls), it should be
_OP2toOP1, not the other way around. But it's smaller to just use the
_setXXOPn and load the number from A. Also, since you defined the 25 in
hex, it would return numbers from 1h to 25h. To do 1 to 25 decimal, this
worked fine for me (first time I've ever used OPS for anything besides
scratch ram):
ld a,1 ;random number between 1 and 25 is needed
call _SetXXOP1 ;a --> OP1
ld a,25
call _SetXXOP2 ;a --> OP2
call _randint ;rand(OP1,OP2) --> OP1
call _CONVOP1 ;OP1 --> A
P.S. Anyone have the t-states for that? That is a nice way of getting
random numbers, but might be way to slow to be useful.
-----Original Message-----
From: Cassady Roop <croop@oregontrail.net>
To: assembly-86@lists.ticalc.org <assembly-86@lists.ticalc.org>
Date: Friday, November 13, 1998 7:16 PM
Subject: A86: Randomness...
>
>Will this give me a random number, from 1 to 25, in A?
>
>ld hl, $0001 ;random number between 1 and 25 is needed
>call _setxxxxOP2 ;hl --> OP2
>call _OP1toOP2 ;OP2 --> OP1
>ld hl, $0025
>call _setxxxxOP2 ;hl --> OP2
>call _randint ;rand(OP1,OP2) --> OP1
>call _convOP1 ;OP1 --> A
>
>thanks,
>
>Cassady Roop
>Slightly Immoral Technologies