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] |
Stan, Thanks so much. You are completely correct and my examples are compiling fine now. Forgive me for asking but quite possibly you can explain something to me. For my SH7032, I have a particular assembly source file that contains everything I need to use the serial port on the Hitachi part. For example, it contains one piece of code that allows one to send a string out the serial port. So in another assembly file if I want to send out "Hello World", I do the following: DoHelloWorld: mov.l pTxString,r4 ! address loaded for global TxStr function mova pHelloStr,r0 ! get 'Hello World' string and put in r0 jsr @r4 ! jump to address in r4 (global TxStr) ---and at the bottom of my file I have---- pTxString: .long TxStr ! TxStr is a global function in another asm file pHelloStr: .asciz "\n\rHello World " ! my ascii string Since I really want to write my code in C but I also don't want to recreate the wheel, since there is alot of assembly language functions I could use, how could I write this DoHelloWorld function in C. I tried the following: extern long TxChar; int main() { char pHelloStr[6] = "Hello"; while(1) { asm( "mov.l TxStr, r4;"); asm( "mova pHelloStr, r0;"); asm( "jsr @r4;"); } return(0); } All I get is the following message: Assembler messages: /var/tmp/ccSJdkkV.s:54: Error: pcrel too far /var/tmp/ccSJdkkV.s:55: Error: pcrel too far I searched the entire SH7032 Hardware manual and Programming Manual and did not find any reference to pcrel. Could you tell me what it is and maybe another way that I could call a function that is written in assembly that is in another file? Thanks for any help on this. Robert Stan Katz wrote: > > Robert Floyd wrote > > >> I am attempting to embed inline assembly into my C code but during the > >> compilation, I keep getting the error "invalid operands for opcode". > >> Here is one of my lines: > >> > >> asm("mov %r14, %r15"); > >> > >> I don't see why this should cause an error. mov is a valid Hitachi SH > >> opcode, r14 and r15 are valid registers. > > I have been using inline assembly on the SH for a while now without any > problems. From my understanding the "%" is used to specify replacable > parameters for the inline assembly and is the cause of the confusion. To > simply move between registers the line is > asm("mov r14, r15;"); > > A common problem that I have is that the compiler seems to concatenate all > sequential asm commands into a single long string and then complains because > there is no separation between assembly mnemonics. I have mad a practice of > adding a terminating ";" to all my commands to prevent this (as in the above > example). > > I have not needed any additional command line parameters to get the code > working. > > 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] |