EmbeddedRelated.com
Forums

IAR and inline assembler

Started by Jardar Johannes Maatje May 14, 2003
Is it possible to mix assembler and C in the same file with IAR WB? Could
not find any documentation on this, so I guess it's not possible, but I
want to be sure cause it would be realy convenient.

Jardar


Beginning Microcontrollers with the MSP430

Here is what you need....

John


http://focus.ti.com/docs/analog/catalog/resource/appnoteabstract.jhtml?familyId42&abstractName=slaa140



At 13:37 14.5.2003 +0200, you wrote:
>Is it possible to mix assembler and C in the same file with IAR WB? Could
>not find any documentation on this, so I guess it's not possible, but I
>want to be sure cause it would be realy convenient.
>
>Jardar
>
>
>Yahoo! Groups Sponsor
><http://www.netflix.com/Default?mqso`164797&partid170658>1743b61.jpg" target="_blank" rel="nofollow">http://rd.yahoo.com/M%1812.3170658.4537139.1261774/D=egroupweb/S05005378:HM/A64416/R=0/*http://www.netflix.com/Default?mqso`164797&partid170658>1743b61.jpg

>
>1743b81.jpg
>
>.
>
>
>
>">http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.


John Leijonakallio Engineer, R&D Software, Finlux Ltd,
Radiomiehenkatu 3, P.O.Box 13 FIN-20321 Turku, Finland
Tel. +358 2 333 285, Fax. +358 2 3330 404
http://www.finlux.com   





Can't speak for the other vendors, but in AQ430, you can easily 
insert assembly code by putting it between an opening /$ and a 
closing $/
You can also easily refer to C declared variables in inserted 
assembly code.

Michel

--- In msp430@msp4..., Jardar Johannes Maatje <maatje@s...> 
wrote:
> Is it possible to mix assembler and C in the same file with IAR WB? 
Could
> not find any documentation on this, so I guess
it's not possible, 
but I
> want to be sure cause it would be realy
convenient.
> 
> Jardar


I have an assembly function with a parameter that uses R4 to R15 inside .
Is there any restriction ,besides SLAA140 ? when I call it from C (using IAR )
.When in C-spy, when tracing it with F3 I can't come back from it. Do I
have to avoid using R4, R5 ?( I am also pushing R6 to R11 as they recommend.).
Karl.
  ----- Original Message ----- 
  From: John Leijonakallio 
  To: msp430@msp4... 
  Sent: Wednesday, May 14, 2003 7:47 AM
  Subject: Re: [msp430] IAR and inline assembler



  Here is what you need....

  John


 
http://focus.ti.com/docs/analog/catalog/resource/appnoteabstract.jhtml?familyId42&abstractName=slaa140



  At 13:37 14.5.2003 +0200, you wrote:
  >Is it possible to mix assembler and C in the same file with IAR WB? Could
  >not find any documentation on this, so I guess it's not possible, but
I
  >want to be sure cause it would be realy convenient.
  >
  >Jardar
  >
  >
  >Yahoo! Groups Sponsor
 
><http://www.netflix.com/Default?mqso`164797&partid170658>1743b61.jpg" target="_blank" rel="nofollow">http://rd.yahoo.com/M%1812.3170658.4537139.1261774/D=egroupweb/S05005378:HM/A64416/R=0/*http://www.netflix.com/Default?mqso`164797&partid170658>1743b61.jpg

  >
  >1743b81.jpg
  >
  >.
  >
  >
  >
  >">http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.


  John Leijonakallio Engineer, R&D Software, Finlux Ltd,
  Radiomiehenkatu 3, P.O.Box 13 FIN-20321 Turku, Finland
  Tel. +358 2 333 285, Fax. +358 2 3330 404
  http://www.finlux.com   

  



        Yahoo! Groups Sponsor 
       
       

  .



   





--- In msp430@msp4..., Jardar Johannes Maatje <maatje@s...>
wrote:
> Is it possible to mix assembler and C in the same file with IAR WB?
Could
> not find any documentation on this, so I guess
it's not possible,
but I
> want to be sure cause it would be realy
convenient.

Yes, you can mix assembly and C in the same file, in a number of ways
-- either as separate functions, or with inline assembly.

However, I'll caution you that ** inline ** assembly should be avoided
for a couple of reasons:

1) The syntax is rarely portable.

2) The optimizers may / will do funny things with in-line assembly.

3) Depending on the compiler, you may or may not have a comprehensive
feature set when working "in" the in-line assembler. For example, some
in-line assemblers do not enable access to global variables (by name),
the program counter, labels, etc. This can be very frustrating.

4) Source-level debugging doesn't work so well with in-line assembly.

IMO, you're better off either writing assembly-language modules (i.e.
functions) that interface via the C calling conventions of the
compiler, or use C-language macros (either intrinsics or your own)
that result in the assembly code you want.

--Andrew


Sorry for the identical, multiple posts -- I'm not sure why that
happened.

--Andrew



Shouldn't you have as many apologies as duplicated messages ? ;-)

Michel

--- In msp430@msp4..., "aekalman" <aek@n...> wrote:
> Sorry for the identical, multiple posts --
I'm not sure why that 
happened.
> 
> --Andrew


Dear sir.
 
i have modified c -code fet examples in msp430f123. i included as u suggested /$
 nop $/ like . but it showing an error as binary operator missing. had i missed
to include some  files. if so, please tell me about that. actually i want to add
asm and c-code in same file.
 
so please help me
 
 
venkat


michelqv <michel@mich...> wrote:
Can't speak for the other vendors, but in AQ430, you can easily 
insert assembly code by putting it between an opening /$ and a 
closing $/
You can also easily refer to C declared variables in inserted 
assembly code.

Michel

--- In msp430@msp4..., Jardar Johannes Maatje <maatje@s...> 
wrote:
> Is it possible to mix assembler and C in the same file with IAR WB? 
Could
> not find any documentation on this, so I guess
it's not possible, 
but I
> want to be sure cause it would be realy
convenient.
> 
> Jardar


Yahoo! Groups Sponsor
.



 

Catch all the cricket action. Download Yahoo! Score tracker




Venkateswarlu Palle <venkatmsp430@venk...> writes:

> i have modified c -code fet examples in
msp430f123. i included as u
> suggested /$ nop $/ like . but it showing an error as binary
> operator missing. had i missed to include some files. if so, please
> tell me about that. actually i want to add asm and c-code in same
> file.

Hi Venkat!

If you're using version 2 of the IAR tools then you can use the
"asm"
keyword to mix assembler instruction and C code.

For example:

void test()
{
  asm("NOP");
}


This results in the following code:

      1          void test()
   \                     test:
      2          {
      3            asm("NOP");
   \   000000   0343                 NOP
      4          }
   \   000002   3041                 RET

    -- Anders

Try to find this document (slaa140.pdf) on www.ti.com, it is very 
usefull.