This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more infromation.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

RE: Invalid Operands with Inline assembly


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]