Re: A89: get a number


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

Re: A89: get a number




How can I get the numbers from the data mathematicaly?
I created the equation
y*elementsize*ywith+x*elementsize.

 lea    map(pc),a1
 addi.w #1,d6   ;d6=x
 cmp.w  #8,d6  ;end of data on line 0
 beq    next
 bra    putmap

next:
 move.w #1,d6   ;restart
 addi.w #1,d7   ;d7=y,  start next line
 cmp.w  #3,d7   ;end of data
 beq    exit

putmap:
 mulu   #16,d7  ;this multiplies the element size and
;ywith to y
 mulu   #2,d6   ;this is the element size times x
 add.w  d7,d6   ;finishes equation y*2*8+x*2
 move.w d6(a1),d0  ;I also tried putting the value in
;d6 to a variable and using move.w var1(a1),d0.

This doesn't work and I don't know why.  Could
somebody help me?

--- Olle Hedman <oh@hem.passagen.se> wrote:
> 
> take the address of the first element, add with
> 
> y*elementsize*ywith+x*elementsize  
> 
> and you get the address of the element you want.
> 
> in your example elementsize is 2 (a word)  and ywith
> is 8
> remember to count the first row as row 0
> 
> y*2*8+x*2
> 
> //Olle
> 
> Ben Rodgers wrote:
> > 
> > I have a quick question. How would I get a value
> from
> > something like this
> > 
> > map:
> > ;           |
> > ;           V
> >  dc.w 1,2,3,4,5,6,4,2
> >  dc.w 3,2,4,2,4,1,2,3  <i want that number
> >  dc.w 2,4,2,4,1,2,3,2
> > 
> > 
> > where I want to get the fourth number in the
> second
> > row.  Thanks.
> > ===
> > Visit my website, Some Assembly Required, at
> > http://meltingpot.fortunecity.com/gilford/908
> > 
> >
>
_________________________________________________________
> > Do You Yahoo!?
> > Get your free @yahoo.com address at
> http://mail.yahoo.com
> 
> 

===
Visit my website, Some Assembly Required, at 
http://meltingpot.fortunecity.com/gilford/908 


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com



Follow-Ups: