Re: A83: Random Number
[Prev][Next][Index][Thread]
Re: A83: Random Number
Register A is 1 byte long, a byte can be 0-255
IonRandom can only work with bytes.
If you need bigger numbers, try this
first get the random range in hl...
Then 'call truRand'
then ld bc,<minimum>
then add hl,bc
hl will hold result
truRand routine:
begin asm code[
;Necessary equates for TI83 and TI83+
#ifdef TI83P
_Round = 40A8h
_Random = 4B79h
#else
_RANDOM = 50B6h
_ROUND = 40DAh
#endif
truRand:
push hl ;secure hl for later
bcall(_random) ;random decimal between 0 and .99999999, returned to op1
pop hl ;get back hl
bcall(_setxxxxop2);set op2 = hl == upper bound
bcall(_fpMult) ;multiply op1 by op2
ld d,0 ;the decimal places to round to (zero)
bcall(_round) ;round op1 to d decimal places
bcall(_convop1) ;set de = op1
ex de,hl ;exchange the values for de and hl
ret ;return to calling function
] end asm code
>what?
>whats the hieghest it can go?
>
>is there anbyway i can make it higher?
>i am going to need even higher numbers in my upcoming prog
>
>like random numbers in between 16000-20000
>
>
>>From: "D Weiss" <dwedit@hotmail.com>
>>Reply-To: assembly-83@lists.ticalc.org
>>To: assembly-83@lists.ticalc.org
>>Subject: Re: A83: Random Number
>>Date: Mon, 05 Jun 2000 15:16:24 CDT
>>
>>
>>Yes, that works, but A can't go that high :)
>>
>>>so this would be my code?
>>>
>>> ld a,1000 ;upper boundry
>>> ld b,100 ;lower boundry
>>> sub b
>>> call ionRandom
>>> add a,b
>>>
>>>ythat wuld leave "a" being my random number?
>>>
>>>
>>>>From: Mike3465@aol.com
>>>>Reply-To: assembly-83@lists.ticalc.org
>>>>To: assembly-83@lists.ticalc.org
>>>>Subject: Re: A83: Random Number
>>>>Date: Mon, 5 Jun 2000 15:26:26 EDT
>>>>
>>>>
>>>>heres a way to do that
>>>>take your max number, subtract that by your min number, find the rand
>>>>number,
>>>>then just add your min number and theres your answer
>>________________________________________________________________________
>>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>>
>>
>
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com