From: Leendert Combee Newsgroups: comp.os.msdos.djgpp Subject: gcc as crosscompiler Date: Tue, 29 Dec 1998 16:45:50 +0100 Organization: Geco-Prakla Lines: 51 Message-ID: <3688F92E.7F88990@oslo.geco-prakla.slb.com> NNTP-Posting-Host: sunw220.oslo.geco-prakla.slb.com Mime-Version: 1.0 Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 4.04j2 [en] (X11; I; SunOS 5.5.1 sun4u) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I use gcc/djgpp all the time, now I need to ask something  offtopic but related to using gcc as
cross-compiler.  I tried to find appropriate resources on the web/newsgroups  to resolve my
compiling problem but could not find them sofar.  Any help will be much approeciated - otherwise
please ignore my message below.
-----------------------------------------------------------

 I am using gcc as a cross-compiler for (Hitachi) SH70xx type microcontroller. (gcc 2.7.2.1)
(I use unix gcc binaries as well as dos binaries; both were created by 'Cygnus' for free distribution
, the dos version is based on the older djgpp version 1.12m4 etc., but that's not the issue  here - I
obviously use the latest djgpp for normal compiling etc.)
Problem: I can't get gcc to produce the (SH) MAC.W instruction (multiply and accumulate).
Whatever optimisation switches I use (typically gcc -m1 -O2 ....), it always breaks a loop like

  for (i=0; i<n; i++)  mac  += a[i]*b[i];

up into seperate  MOV.W's for a[i] and b[i] and  then a MUL(tiply) and an ADD(ition)... This
takes a lot of cycles while it can be done with a simple single MAC.W instruction.  Then I tried
inline assembly or - alternatively - modifying the assembler output. This is fine, except then
gdb (with target sim) chokes on the MAC instruction (SIGSEGV - it plainly aborts). I am pretty
sure I have the MAC instruction correct etc., so following this my conclusion is that :

     - either I am missing something fundamental here,
     - or gcc output for SH processor doesn't know about the MAC instruction and neither does
         gdb. Strangely, the assembler does know about (and complains when I do not specify
         the instruction arguments correctly).

 Any SH/gcc programmers out there that can help?! any ideas/help/etc is *much* appreciated.

-Leendert Combee
   email: combeel AT oslo DOT geco-prakla DOT slb DOT com
------------------------------------------------------------------