🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #2090

'-fforce-addr', '-fforce-mem' problem in GCC 1.32 for 680x0

#2090
From: lmayk!lgm
Date: Sun, 25 Dec 1988 22:12
85 lines
2979 bytes
SYNOPSIS:
The '-fforce-addr' and '-fforce-mem' options cause GCC 1.32 to
generate incorrect memory references on the 680x0 architecture
in certain cases.  In particular, the referencing of the 'char'
or 'short' portion of an 'int' generates assembly language
*without* the necessary offset into the longword (i.e., as if the
68000 were little-endian instead of the big-endian architecture
that it is).

MACHINE AND OS:
AT&T UNIX PC 3B1 (based on Motorola 68010 microprocessor) running
OS Version 3.5 (compatible with UNIX System V Release 2).

CONFIGURATION:
'config.gcc 3b1'

TRANSCRIPT (INPUT FILE, COMMAND LINE, OUTPUT):
_______________________________________
$ cat short.c
extern	int	i;
extern	int	arr[];
extern	short	s;
extern	char	c;

void
f( k )
int	k;
{
	s = i;			/* 'int' => 'short' */
	c = arr[ k ];		/* 'int' => 'char' */
}
$ ../src/stage1/gcc -B../src/stage1/ -v -S -O short.c
gcc version 1.32
 ../src/stage1/cpp -v -undef -D__GNUC__ -Dmc68k -Dunix -Dunixpc -D__mc68k__ -D__unix__ -D__unixpc__ -D__OPTIMIZE__ short.c /tmp/cca26036.cpp
GNU CPP version 1.32
 ../src/stage1/cc1 /tmp/cca26036.cpp -quiet -dumpbase short.c -O -version -o short.s
GNU C version 1.32 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.32.
$ cat short.s				# With '-O' only
	file	"short.c"
text
	even
	global f
f:
	link.w %a6,&0
	mov.w i+2,s			# get 'short' from 'i'
	lea arr,%a0
	mov.l 8(%fp),%d0
	asl.l &2,%d0
	mov.b 3(%a0,%d0.l),c		# get 'char' from 'arr[ k ]'
	unlk %a6
	rts
$ ../src/stage1/gcc -B../src/stage1/ -v -S -O -fforce-mem short.c
gcc version 1.32
 ../src/stage1/cpp -v -undef -D__GNUC__ -Dmc68k -Dunix -Dunixpc -D__mc68k__ -D__unix__ -D__unixpc__ -D__OPTIMIZE__ short.c /tmp/cca26040.cpp
GNU CPP version 1.32
 ../src/stage1/cc1 /tmp/cca26040.cpp -quiet -dumpbase short.c -fforce-mem -O -version -o short.s
GNU C version 1.32 (68k, SGS/AT&T unixpc syntax) compiled by GNU C version 1.32.
$ cat short.s				# With '-fforce-mem'
	file	"short.c"
text
	even
	global f
f:
	link.w %a6,&0
	mov.w i,s		# No offset into 'i'!
	lea arr,%a0
	mov.l 8(%fp),%d0
	asl.l &2,%d0
	mov.b (%a0,%d0.l),c	# No offset into 'arr[ k ]'!
	unlk %a6
	rts
$
_______________________________________

EXPLANATION OF TRANSCRIPT:
'-fforce-mem' seems to be removing the byte offset necessary to
extract a 'char' or 'short' from an 'int' in memory.  Although
not shown here, '-fforce-addr' has the same problem.


	Lawrence G. Mayka
	Aurora, Illinois

	lgm@lmayk.UUCP
	chinet!lmayk!lgm
Technical Details
Message-ID: <8812252247.aa21116@gamma.eecs.nwu.edu>
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!ODDJOB.UCHICAGO.EDU!lmayk!lgm

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!ddsw1!lll-winken!killer!mit-eddie!bloom-beacon!tut.cis.ohio-state.edu!ODDJOB.UCHICAGO.EDU!lmayk!lgm
From: lmayk!lgm@ODDJOB.UCHICAGO.EDU
Newsgroups: gnu.gcc.bug
Subject: '-fforce-addr', '-fforce-mem' problem in GCC 1.32 for 680x0
Message-ID: <8812252247.aa21116@gamma.eecs.nwu.edu>
Date: 25 Dec 88 22:12:33 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 84