Re: A92: A stupid question...
[Prev][Next][Index][Thread]
Re: A92: A stupid question...
Grutsch Alexander wrote:
>
> At 11:58 24.03.1999 +0100, you wrote:
> >
> >I was wondering why when I compile a prog I made, there's an error like :
> >
> >" add.b #1,a0"
> > ^
> > L wrong size operand.
> >
> >Because when I read any guide about 68k asm, it's written that the length of
> >the data can be :
> >a byte, a word, a longword.
> >
> >I really don't see why. Does anyone have an explanation ?
> >I just want to know, because when I replace my ".b" by a ".w" everything
> >goes well, and I could just do like this each time, but I would really like
> >to understand.
> >
> >Thanks.
> >
> >VIVES Fabien
> >vives@NOSPAMwanadoo.fr
> >( Enlevez NOSPAM pour me repondre )
> >( Get NOSPAM off to answer me )..
> >ICQ : 16950211
> >
>
> You should use adda.w #1,a0 or lea 1(a0),a0
>
> --
> MXM-TriX
> http://mxm.ticalc.org/
Since you knew how to fix the problem but asked for an expanation, here it is.
The address register in the 68000 is a 32-bit register. However, as another
writer (almost correctly) pointed out, the architecture of the 68000 only uses
the least significant 24 bits (or least significant 3 bytes) which effectively
limits the 68000's address range to around 16MB of memory.
Now, the 68000 provides a short-hand for addressing the lowest 64K of memory.
Since only 16-bits are needed to address 64K, the 68000 allows the use of (.W)
word-sized operations involving an address register...very similar to the
concept of using absolute short addressing (only 16-bits are used). This saves
code space by not having to provide two bytes of zeros for the upper two bytes
of the address, and saves time because the processor only has to fetch two bytes
for an address instead of four.
Additionally, the architecture supports the use of address registers as 16-bits
(word sized) because address registers can be used as indexes. For example,
move.l (A0,A1.W),D0 ; useful to accessing +/- 32K from where A0 points
An extra note, other 68000 family processors do use the full 32-bit address bus
and, therefore, you should always keep that one most-significant byte of your
address set to zero.
There are a couple of other methods you can use to increment an address
register which are smaller than ADDA or LEA.
tst.b (A0)+ ; will increment A0 by 1
tst.w (A0)+ ; will increment A0 by 2
tst.l (A0)+ ; will increment A0 by 4
addq.w #1,A0 ; you can add from 1 to 8 in only 2-bytes of code
Like using ADDA, the ADDQ instruction does not affect any condition codes
when the destination operand is an address register. Also, when ADDA.W is used,
all 32-bits are always affected...I'm not actually sure if this is the case
with the ADDQ.W instruction or if only 16-bits are affected.
Hope I helped...
Keith Kirton
References: