Re: A86: Array


[Prev][Next][Index][Thread]

Re: A86: Array




This might work but its probably not the fastest way to do it.  Also 
they'res no telling what registers it destroys and I have no idea how to 
fin out except by asking Dux).

Start_Filling:
 ld d,b
 ld b,40 
 ld hl,Array
 jp Call_Area
First_Recursion:
 ld a,2    ;your number is >=0 and also <A so a should = 2
 call Random
 ld (Array),a

Rest_Of_The_Recursions:
 ld a,2
 call Random
 ld (Array+1),a
 djnz Rest_Of_The_Recursions


Random: 	       ; Creates a random number 0 <= x < A
 push bc
 push de
 push hl
 ld b,a
 ld a,r
 add a,a
 ld hl,0
 ld d,0
 ld e,a
RMul:
 add hl,de
 djnz RMul
 ld a,h
 pop hl
 pop de
 pop bc
 ret

Call_Area:
 ld b,24
 call Start_Filling
 ld b,d
 inc hl
 djnz Call_Area


Array:
 .db 0,0,0,0,0,0,0,0 ;make 24 .db's each having 40 0's all seperated
                     ;by commas like shown there
                      


I think this should work for filling your array.  I'm kinda shaky about 
how I swapped the counters (since the only easy way to fill 24 lines of 
40 was two recursions I made one recursion (the one cycling the .db's) 
call the second (the one that fills each .db) and the second saved the 
first's counter   then upon return to the first cycle its counter is 
restored).  And I'm not sure if it will move to the next .db when it's 
done filling the first but it should.  I would test it but my calc is 
dead and TI won't respond telling where to send it for CPR ::grumble::.  
I'm pretty faithful in it though.  As for reading your array I'll post 
that in a different email Cuz this one's getting long.

Hope That Does What Ya Wanted,

Matt



>Date: Sat, 03 Oct 1998 22:23:53 -0700
>To: assembly-86@lists.ticalc.org
>From: Dave VanEe <dvanee@dowco.com>
>Subject: A86: Array
>Reply-To: assembly-86@lists.ticalc.org
>
>
>How would I make an array of 40x24 where each cell is only a 1 or 0? 
Also,
>how could I access this?
>
>Thanx,
>Dave
>
>


______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com