[comp.sys.atari.st] MWC Bug

exodus@mfgfoc.UUCP (06/29/88)

Path: mfgfoc!exodus
From: exodus@mfgfoc.UUCP (Greg Onufer)
Newsgroups: comp.sys.atari.st
Subject: Bug in MWC found by TeX
Keywords: array of structs with long index
Message-ID: <358@mfgfoc.UUCP>
Date: 28 Jun 88 16:44:47 GMT
Organization: FOCUS Semiconductor Sys., Sunnyvale, CA
Lines: 34

A bug in MWC 3.0 found by TeX!!  One step closer.....

There is a bug in the MW C Code Generator as follows:

	foo[bar] = foobar;

will not work if foo is an array of structures, foobar is a structure,
and bar is a long.  The code produced will:
	- Load the address of foobar into a1 
	- push sizeof(foobar) onto the stack
	- push bar onto the stack
	- call lrmul to multiply the two and obtain offset
	- load the address of foo+offset into a0
	- copy the struct's

[a little simplified in that MWC copies the structs using pre-decrement
 and a1,a0 actually point beyond the end of the structure to take that
 into account]

except that a1 is munged by lrmul and no longer contains the address
of foobar.  The fix is to get lrmul.o out of libc.a, disassemble it
with db, and rewrite it so that it saves a1 upon entry and restores 
it upon exit.  MW is working on their fix right now.

-Greg Onufer
 University of the Pacific
 Focus Semiconductor 


-- 
Greg Onufer   		GEnie: G.ONUFER		University of the Pacific
UUCP:						-= Focus Semiconductor =-
exodus@mfgfoc   ...!sun!daver!mfgfoc!exodus
AT&T: 415-965-0604	USMAIL: #901 1929 Crisanto Ave, Mtn View, CA 94040