A89: Re: Back to arrays... =(


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

A89: Re: Back to arrays... =(




Oh, thank you!!!!  My ISP is really acting up, so I've had a lot of offline
time today to do nothing, so I decided to start programming again, and well,
I got stuck on this and couldn't wait to get back online to ask about it.

Now, one more question: Is the 'array+2' meathod better than the '2(a6)'
meathod?  It is faster on the calc since it doesn't have to add it while
running, correct?

-Miles Raymond      EML: m_rayman@bigfoot.com
ICQ: 13217756       IRC: Killer2        AIM: KilIer2 (kilier2)
http://www.bigfoot.com/~m_rayman/

----- Original Message -----
From: Zoltan Kocsi <zoltan@bendor.com.au>
To: <assembly-89@lists.ticalc.org>
Sent: Wednesday, July 28, 1999 12:51 AM
Subject: A89: Back to arrays... =(


>  >     move.w    #4,2(array)
>  >     move.w    #4,4(array)
>  >     lea       array,a6
>  >     ...
>  > array
>  >     ds.b      20
>  >     ...
>  >
>  > and the program won't compile.  So I tried:
>  >
>  >     ...
>  >     lea       array,a6
>  >     move.w    #4,2(a6)
>  >     move.w    #4,4(a6)
>  >     ...
>  > array
>  >     ds.b      20
>  >     ...
>  >
>  > and that works.  I just want to know why I have to use a register for
it to
>  > work.  Thanks.
>
> Well, the first form you ask the processor to do this:
>
> write '4' to the word of which the address is 2 more than that of the
> address of 'array'. This is a totally legal request, only you used a
> wrong syntax. From the CPU's point of view the offset (2) and the base
> address (array) are both constants. The 68k can not add two constants
> when calculating an effective address. Therefore you have to ask the
> assembler to calculate the result (which it can, since both components
> are constants) and tell the CPU to write the 4 to the addres of
> 'array+2' (storead a single constant).
>
> Try this:
>
>    move.w #4,array+2
>    move.w #4,array+4
>
> When you say move.w #4,2(a6) you ask the CPU to store the 4 in a word
> of which the address the content of a6 plus 2. The 68K supports this
> construct directly, it is a valid thing to do. On the other hand, the
> assembler could not help here for the assembler have no idea what will
> be in a6 when you actually execute the insn.
>
> Regards,
>
> Zoltan



Follow-Ups: References: