A89: Re: Adding to addresses


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

A89: Re: Adding to addresses




> Why is it that if I add to an address, I can't seem to add a number greater
> than 62?  Here's the code I'm using (I know it's inefficient.  I started
> making it simpler while trying to find the problem.)  I want to use it to get
> a byte stored in an array with dimentions 124 by 124 (map is the address of
> the array).  The x coordinate is d6; the y coordinate is d7.  (The upper left
> corner is 0,0)  It works as long as I only get as far as d6=62, d7=0.  After
> that, it just returns 0.  (Most of the array is 0's, so it might just be
> reading the wrong byte...)
>
>     clr.l   d3
>     move.b  d7,d3
>     mulu.w  #124,d3
You should use 128 in width, but I assume that's covered by what you said.

>     add.w   d6,d3

>     add.w   #0,d3
Why?

>     move.l  map,a0
"map" is a longword data containing the address, right? Not a label?

>     add.l   d3,a0
>     clr.l   d3
>     move.b  (a0),d3

Have you checked the data at both ends? Does all the data get included into the
program/variable? Does the code read the data up to th 62/0 point correctly?

 / Niklas Brunlid
Check out Prosit for the TI-89 / TI-92+ at http://prosit.ticalc.org
Random PQF Quote follows:

In Reading [England] there is this thing called the IDR, short for "Inner
Distribution Road", which is bureaucratese for "Big thing that cost a lot
of money and relieves traffic problems, provided all your traffic wants to
orbit the town centre permanently". It's a 2-3 lane dual carriageway that
goes round the town centre. It has lots of roundabouts, an overhead
section, a couple of spare motorway-like exits (that's British motorways --
y'know, the roundabout with the main road going under it), and a thing
called the Watlington Street Gyratory, where you have to get in lane for
your intended destination about three years and two corners before you get
there *with no signposting*. I used to cycle along it every day to get to
school, before I fell off at 35 mph. [Kids! Don't try this at home!]  I
know it well. I believe it is impossible to leave Reading heading west.
        -- (Terry Pratchett, alt.fan.pratchett)





References: