Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!cornell!uw-beaver!uw-june!uw-entropy!uw-apl!grace!ben
From: ben@grace.UUCP (Ben Henwood)
Newsgroups: comp.sys.m68k
Subject: Re: Why does addq.w #n,sp work?
Summary: C Compiler
Keywords: C asm addq
Message-ID: <138@grace.UUCP>
Date: 8 Dec 88 17:00:04 GMT
References: <5005@bsu-cs.UUCP>
Distribution: na
Organization: UW Applied Physics, Seattle
Lines: 19



From postnews Thu Dec  8 08:48:24 1988
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 and am puzzled to 
> find that it sometimes uses, for example, the instruction addq.w #8,sp.  
> I know that this clears the arguments pushed on the stack for a subroutine
> call.  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?

When an "addq" instruction affects an address register (A7 in this
case), the entire destination address register is used, regardless
of the operation size.

So even though the assembler instruction specifies 16-bits, which
would be a bug, the instruction will use 32-bits since it's dealing
with the SP.