Re: LZ-Adv: matrices


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

Re: LZ-Adv: matrices



>         Lets say I have a defined matrix at the bottom of a prog. that
> will not be changed but values will be take from it to calculate stuff in
> the prog depending on variable. In other words, a 5 by 50 matrix with
> preset values. How do i load the value of MATX (refering to 5) and MATY
> (refering to  50) posision in matrix into register a? in other words for
> values of MATX and MATY how do I load the appropriate value of the matrix
> into a?

Okay, right now you have:

[Code]

MatrixStart:
.db 6,2,5,2,6
.db 2,5,3,6,4
.db 7,2,5,8,4
(and so on)

here's the code you would use to load the value of a position in the
matrix into A. I use MatRow and MatCol for ease of interpretation.

   ld    b, (your MatRow)
   ld    c, (your MatCol)
CALL_(Ld_To_A)


-------  Somewhere else in the code

Ld_To_A:
   ld    a,b
   shl   a 
   shl   a
   add   b                ; This multiplies row (b) by 5 and puts it in
                          ; A, via a=4b+b and is much faster code than
                          ; multiplying

   add  c                 ; a=5b+c

   ld   de,(prog_Start)
   ld   bc,MatrixStart
   add  bc,de             ;bc=absolute address of beginning of matrix 

   ld   de,a
   add  bc,de             ;bc=address of (beginning + offset)

   ld   a,(bc)            ; a= value of memory location BC


This probably contains some syntax errors and the like,  but it should
give you a general idea.


>  How do I define it at the bottom of the screen?

huh???

> What about memory allocation, i won't have to define it at the top will I?

No. the bottom's okay.

>                         Will Stokes

Hope this helps,
Jason Wenger

+-------------------------------------------------+
| Jason C. Wenger       www.clinton.net/~jwenger/ |
| 'Thursday' on Kali          jwenger@clinton.net |
| Illegitimi no carborundum      jwenger@juno.com |
+-------------------------------------------------+
|    So... So you think you can tell              |
|    Heaven from Hell?  Blue skies from pain?     |
|    Can you tell a green field                   |
|    From a cold steel rail?                      |
|    A smile from a veil?                         |
|    Do you think you can tell?                   |
|      "Wish You Were Here" - Pink Floyd          |
+---BEGIN GEEK CODE BLOCK-------------------------+
|                                                 |
| G>CS/>E d-? s: a- C++>++++ U? P? L? E? W++>+++  |
| N++ o? K? w+>+++++ O? M--- V? PS+ PE+ Y? PGP- t |
| 5? X? R tv-(--) B++++ DI+ D- (DESCENT2++++++) G |
| e-* h! r-- !y-                                  |
|                                                 |
+--END GEEK CODE BLOCK----------------------------+


References: