Re: A89: get a number


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

Re: A89: get a number




I'm not sure what you're doing here but what you want to do (if this is
supposed be a sort of matrix) is write a routine that will get the data from
a row and column
if d0 is the row and d1 is the column then:

getData:
 lea map(pc),a0
 lsl #4,d0                            ;d0 * 16 (the # of bytes in a row)
 lsl #1,d1                            ;d1 * 2 (because 2 bytes for each
data)
 add d1,d0                        ; d0 becomes data offset
 move.w 0(d0,a0),d0        ;d0.w holds the data
 rts

 then call it like this:

 move #2,d0                    ;the data you want is at row 2, column 8 in
the matrix
 move #8,d1
 bsr getData                    ;data -> d0.w



>
> 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
> >
> > file://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
>
>
>



References: