public inbox for crossgcc@sourceware.org
 help / color / mirror / Atom feed
* RE: Invalid Operands with Inline assembly
@ 2000-10-31 16:59 Stan Katz
  2000-11-01  6:09 ` Sobhy Gad
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Stan Katz @ 2000-10-31 16:59 UTC (permalink / raw)
  To: 'Robert Floyd', Stan Katz; +Cc: crossgcc

Robert Floyd [ mailto:robert.floyd@inet.com ] wrote:
>
> I used your example and everything compiles and links just 
> great.  With
> one slight problem that you might be aware of with your Hitachi SH
> experience...
> 
snip

Thanks for the feedback, glad to have helped

> I have asm files that initialize the chip, turns on an LED to RED and
> sends out a boot string over the serial port to my PC.  These actually
> work.  I used the example that you set up for me as a C file 
> with inline
> assembly that I wanted to link into my working assembly 
> language files. 

I tend to do all this is C anyway, the only time I use assembly is when I
need to either put in some interrupt handling code (which usually calls a C
routine for processing anyway) or when I want to use the mul/mac/div
instructions to get a faster scaling routine.

> Well after the chip runs thru all the asm code (which I can see is
> working ok because the LED comes on and the boot string comes out over
> the serial port), I simply... 
> 
> bra pmain	! branch to global _main in another object file
> 
> This pmain is a label in the asm file, i.e. pmain:   .long _main
> 
> But instead the chip seems to branch off into the weeds because after
> several seconds the chip resets, (watchdog timeout?).  I actually went
> thru the code, looked at the srec file and can see that the linker did
> put in the right address for _main.  But oddly enough, nothing happens
> except it eventually resets itself.  Do you think that I should be
> branching to the dummy global ___main instead?  Thanks for 
> any advice on
> this.

It looks as if you are branching to the address pmain, which contains a 32
bit value equivalent to _main and is executing that as code, what happens
depends on the actual value of _main but is not likely to get you back with
the PC equal to _main either. You want to branch to the value that is at the
address pmain (assuming _main is too far away to go directly there) probably
want to do something like:
	mov.l  pmain, r4
	bra    @r4

Although you may be able to use 
	bra _main

Try the second and if the address of _main is too far from the bra
instruction to be assembled you will get an error message from the compiler
or assembler.

Stan

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2000-11-01 13:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-31 16:59 Invalid Operands with Inline assembly Stan Katz
2000-11-01  6:09 ` Sobhy Gad
2000-11-01  6:10 ` SOS Sobhy Gad
2000-11-01  6:29   ` SOS jani
2000-11-01 13:56 ` Invalid Operands with Inline assembly Robert Floyd

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).