Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!cs.utexas.edu!oakhill!mikes
From: mikes@oakhill.UUCP (Mike Schultz)
Newsgroups: comp.sys.m68k
Subject: Re: Why does addq.w #n,sp work?
Keywords: C asm addq
Message-ID: <1733@oakhill.UUCP>
Date: 9 Dec 88 15:00:46 GMT
References: <5005@bsu-cs.UUCP>
Reply-To: mikes@oakhill.UUCP (Mike Schultz)
Distribution: na
Organization: Motorola Inc., Austin Tx.
Lines: 17

In article <5005@bsu-cs.UUCP> jbwaters@bsu-cs.UUCP (J. Brian Waters) writes:
>
>I have been looking at the assembly output of a C compiler ...
>.....  What I do not understand is why it is not a addq.l #8,sp as I thought
>the sp was a 32 bit counter.  Why does it use the addq.w form rather then
>the addq.l?

First, as others have pointed out, the immediate word value is sign extended
when dealing with address registers, so it really is adding a 32 bit value 
to the 32 bit register.

Second, the timing tables in appendix F show that the word version of the addq
takes 4 clocks, while the long version takes 8.  I don't know, but I suspect
that the hardware adder is optimized for word adds.

Mike Schultz
..!uunet!cs.utexas.edu!oakhill!mikes