Borland Turbo C 2.0 for Atari 68000 machines: ODD behavior
Checkpoint Technologies
ckp at grebyn.com
Mon Apr 8 23:33:07 AEST 1991
In article <1991Apr6.091013.26131 at daffy.cs.wisc.edu> carter at cs.wisc.edu (Gregory Carter) writes:
> (unsigned int)(*((unsigned int *)0x00ff8e20L)) = 0x03;
> MOVE.W #$0003, $00ff8e20
>...
> (unsigned int)(*((unsigned int *)0xffff8e20L)) = 0x03;
> MOVE.W #$0003, $8e20
>
>This is obviously not correct.
This may not be obvious, but it *is* correct. The compiler is doing you a
favor.
The 68K has "absolute short" and "absolute long" addressing. Absolute
long means that a whole 32 bit absoluet address follows.
Absolute short means that only a 16 bit word follows, and it should be
*sign extended* to 32 bits before being used.
The value $8E20, when sign extended into a full 32 bit address becomes
$FFFF8E20. This is just what you asked for, and the compiler found a
briefer way to code it.
--
ckp at grebyn.com
[brychcy at informatik.tu-muenchen.dbp.de (Till Brychcy) also pointed this out.
-John]
--
Send compilers articles to compilers at iecc.cambridge.ma.us or
{ima | spdcc | world}!iecc!compilers. Meta-mail to compilers-request.
More information about the Comp.lang.c
mailing list