Reply by Preston Gurd September 8, 20032003-09-08

> There are a few problems introduced by the
MSP430's assembler syntax.
> I'd want to write:
> 
> void foo(register int *x)
> {
>   /$
>     ...
>     mov.w @@x+, r4
>     ...
>   $/
> }
> 
> But it won't work.  Other than that, it's nicely implemented!

Thanks, Paul.

It will work if you write

	mov.w \@@x+, r4
	

Preston Gurd
Archelon Inc.
(AQ430 C compiler guy)


Beginning Microcontrollers with the MSP430

Reply by Paul Curtis September 8, 20032003-09-08
Hi Preston,

> > There are a few problems introduced by the
MSP430's 
> assembler syntax. 
> > I'd want to write:
> > 
> > void foo(register int *x)
> > {
> >   /$
> >     ...
> >     mov.w @@x+, r4
> >     ...
> >   $/
> > }
> > 
> > But it won't work.  Other than that, it's nicely
implemented!
> 
> Thanks, Paul.
> 
> It will work if you write
> 
> 	mov.w \@@x+, r4

Ahh.  Good to know you've covered that base.  :-)

-- Paul.

Reply by Richard F. Man September 8, 20032003-09-08
At 01:21 PM 9/8/2003 -0700, Jonathan Kirwan wrote:
>....Which, of course, begs another question.
>
>Is register use of inline assembly seemlessly blended into the
>register allocation process?  Or how exactly is it handled?  Is
>this a thing where the coder needs to follow some strict rules
>to avoid a conflict?  Is there a blanket prologue and epilogue
>used to put things into "known states" in order to work around
>tiny fragments like this?  Or is there some parsing intelligence
>operating on the inline assembly, as well?
>
>Jon
>...

No, we aren't too smart peeking inside the asm strings. So the MSP430 is 
nice in that almost all addressing modes are valid in most instructions. On 
the Atmel AVR, you do have to be careful if a local var does not end up in 
register and you use a register only instruction. You will of course get an 
assembly error of course.


// richard <http://www.imagecraft.com> 
<http://www.dragonsgate.net/mailman/listinfo> 


Reply by Indrek Rebane September 8, 20032003-09-08
Jonathan Kirwan wrote:
> Is register use of inline assembly seemlessly
blended into the
> register allocation process?

An example from ImageCraft ICC430 manual:

register unsigned uc;
asm("mov %uc,R10\n"
     "sleep\n");

Indrek

-- 
    Indrek Rebane           |   OU Borthwick-Pignon
    Electronics Engineer    |    Tartu Science Park
    Phone: (+372) 7 302 641 | Riia 185, 51014 Tartu
    Fax:   (+372) 7 383 041 |               Estonia
    indrek@indr...        |  http://www.bps.co.ee


Reply by Jonathan Kirwan September 8, 20032003-09-08
On Mon, 08 Sep 2003 13:11:45 -0700, Richard wrote:

>At 12:55 PM 9/8/2003 +0000, ahmeto77 wrote:
>>Hello everybody,
>>
>>   I want to ask if we can use inline assembly code for a c compiler.
>
>As others mentioned, it depends on the compiler. Our ImageCraft ICC430 does 
>it like this:
>
>         asm("mov #3,$a\n"
>                "mov #5,$b\n"
>                  "mov $a,$b");
>
>a bit more cumbersome than your example, but not by much. You can access 
>any C variable inside the string.
><snip>

Nifty.  Looks like at least two compilers have it.

Which, of course, begs another question.

Is register use of inline assembly seemlessly blended into the
register allocation process?  Or how exactly is it handled?  Is
this a thing where the coder needs to follow some strict rules
to avoid a conflict?  Is there a blanket prologue and epilogue
used to put things into "known states" in order to work around
tiny fragments like this?  Or is there some parsing intelligence
operating on the inline assembly, as well?

Jon

Reply by Paul Curtis September 8, 20032003-09-08
Jon,

> I understand some of Paul's desire to avoid
inline assembler 
> and, personally, I tend to prefer using a real assembler as 
> part of the mix.  But there are times when uncomplicated 
> access to C-symbols and the need for a tiny snippet of 
> assembly arises. It can be done in other ways, usually, but 
> the convenience is a plus.  Paul's comments, "I've never 
> really understood the fascination with inline assembler at 
> all," and "we build for the common case," are exactly the 
> kind of comments which leave me just a little 'cold.'

Well, nobody has asked for inline assembler so, I don't feel bad not
offering it.  I feel better that we have not wasted our effort on
providing something that's not used.  If we had everybody knocking on
our door telling us that they just can't get by without it, then I'd
be
the first to implement it.

> Thanks for the extra effort on this score, Michel.

There are a few problems introduced by the MSP430's assembler syntax.
I'd want to write:

void foo(register int *x)
{
  /$
    ...
    mov.w @@x+, r4
    ...
  $/
}

But it won't work.  Other than that, it's nicely implemented!

If I were to implement inline assembler, and I'm not considering it yet,
I'd use an "__asm" keyword and the old Inmos implementation as a
guideline as that was pretty elegant.

-- Paul.

Reply by Richard F. Man September 8, 20032003-09-08
At 12:55 PM 9/8/2003 +0000, ahmeto77 wrote:
>Hello everybody,
>
>   I want to ask if we can use inline assembly code for a c compiler.

As others mentioned, it depends on the compiler. Our ImageCraft ICC430 does 
it like this:

         asm("mov #3,$a\n"
                "mov #5,$b\n"
                  "mov $a,$b");

a bit more cumbersome than your example, but not by much. You can access 
any C variable inside the string. Let me know direct if you have further 
questions.

>i.e
>
>main()
>{
>   a=b ;
>
>   asm  // inline assembly code here
>  begin
>     mov #3,a
>     mov #5,b
>     mov a,b
>  end ;
>
>   b = a ;
>}
>...

// richard <http://www.imagecraft.com/software> 
<http://www.imagecraft.com/software/FAQ.html>
<http://www.dragonsgate.net/mailman/listinfo> On-line orders, support, and

listservers available on web site.
[ For technical support on ImageCraft products, please include all previous 
replies in your msgs. ] 


Reply by michelqv September 8, 20032003-09-08
Well, actually, Preston and Co  are the ones who made the extra 
effort. I'm just happy to report the result ;-). The Archelon C 
compiler also gives access to C variables in in-line assembly code, 
BTW.

Michel

--- In msp430@msp4..., Jonathan Kirwan <jkirwan@e...> wrote:
> On Mon, 08 Sep 2003 13:45:59 -0000, you wrote:
> 
> >With the AQ430 tools, in-line assembly is supported as follows 
(from 
> >your example):
> > main()
> > {
> >   a=b ;
> > 
> >  /$   // inline assembly code here introduced by "slash dollar 
sign"
> >      mov #3,a
> >     mov #5,b
> >     mov a,b
> > $/   // end of inline assembly: "dollar sign slash "
> >   b = a ;
> > }
> > 
> >Michel (from Quadravox, home of AQ430)
> 
> Excellent.
> 
> I understand some of Paul's desire to avoid inline assembler
> and, personally, I tend to prefer using a real assembler as part
> of the mix.  But there are times when uncomplicated access to
> C-symbols and the need for a tiny snippet of assembly arises.
> It can be done in other ways, usually, but the convenience is a
> plus.  Paul's comments, "I've never really understood the
> fascination with inline assembler at all," and "we build for the
> common case," are exactly the kind of comments which leave me
> just a little 'cold.'
> 
> Thanks for the extra effort on this score, Michel.
> 
> Jon


Reply by Jonathan Kirwan September 8, 20032003-09-08
On Mon, 08 Sep 2003 13:45:59 -0000, you wrote:

>With the AQ430 tools, in-line assembly is supported
as follows (from 
>your example):
> main()
> {
>   a=b ;
> 
>  /$   // inline assembly code here introduced by "slash dollar
sign"
>      mov #3,a
>     mov #5,b
>     mov a,b
> $/   // end of inline assembly: "dollar sign slash "
>   b = a ;
> }
> 
>Michel (from Quadravox, home of AQ430)

Excellent.

I understand some of Paul's desire to avoid inline assembler
and, personally, I tend to prefer using a real assembler as part
of the mix.  But there are times when uncomplicated access to
C-symbols and the need for a tiny snippet of assembly arises.
It can be done in other ways, usually, but the convenience is a
plus.  Paul's comments, "I've never really understood the
fascination with inline assembler at all," and "we build for the
common case," are exactly the kind of comments which leave me
just a little 'cold.'

Thanks for the extra effort on this score, Michel.

Jon


Reply by Dmitry September 8, 20032003-09-08
On Monday 08 September 2003 17:46, Paul Curtis wrote:
> Sure, dadd isn't generated natively.  But
them how often do you use it?
> ;-)

these are very usefull bits when interfacing LCDs, or for 
in-system-uart-debugging (do not tell about jtag debugging - timer interrupts 
eat everything ;), when info being output strait to the terminal.

~d

-- 
/*****************************************************************
     ("`-''-/").___..--''"`-._     (\   Dimmy
the Wild     UA1ACZ
      `6_ 6  )   `-.  (     ).`-.__.`)  State Polytechnical Univ.
      (_Y_.)'  ._   )  `._ `. ``-..-'   Radio-Physics Departament
    _..`--'_..-_/  /--'_.' ,'           Saint Petersburg, 
Russia
   (il),-''  (li),'  ((!.-'             +7 (812)
5403923, 5585314
 *****************************************************************/