incrementing after a cast

Gregory Smith greg at utcsri.UUCP
Sat Dec 13 04:59:13 AEST 1986


In article <190 at haddock.UUCP> karl at haddock.ISC.COM.UUCP (Karl Heuer) writes:
>>(This has to be done anyway when figuring out how to store the stuff.  For
>>example, if you push a byte on the 68000 stack a whole word is used.)
>
>I don't think this is relevant.  If the architecture requires (or the compiler
>prefers) the stack pointer to always be aligned, then push(byte) may have to
>be compiled into movb(byte, *--sp) and clrb(*--sp), but here the adjustment is
>by a constant amount known at compile-time.

On the 68000 ( and PDP-11 ), (sp)+ and -(sp) add or subtract 2 to/from the
sp for byte operands. The 'clrb' method would be non-atomic. So the 'fix'
is done in microcode.
 Whether the odd byte is cleared on a write is a different matter.
It isn't on the PDP-11; movb ...,-(sp) must be followed by clrb -1(sp)
to do that. I seem to recall that a 68000 does a 1-byte write, too,
but you can't then change it to a word by clearing the high byte since
the byte write occurs into the high byte ( confounded bigendians :-)).

As you say, this is irrelevant to the C pointer debate.

-- 
----------------------------------------------------------------------
Greg Smith     University of Toronto      UUCP: ..utzoo!utcsri!greg
Have vAX, will hack...



More information about the Comp.lang.c mailing list