Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Example of C and inline ASM in a file?

2006-04-12 by jayasooriah

Dear Brendan,

This dialog has gone long enough.  I like to finish off by addressing
your lingering doubts once more as best as one can, and move on.

--- In lpc2000@yahoogroups.com, "brendanmurphy37" <brendan.murphy@...>
wrote:

> Consider the following sequence of events:
> 
> 1. We need some mechanism to lock out interrupts, for reasons that 
> should be clear enough to everyone.
> 
> 2. We decide to implement this as in-line assembler, wrapped up in 
> some nice macros. In fact, we implement exactly the same macros as 
> you presented in your example.
> 
> 3. We test these out, and they work well. Everyone is delighted with 
> the results. Our macros are a great sucess, and everyone is happy. 
> Everyone uses them, all over the place.

Thus my on-the-fly example has served its purpose.

> 4. Then, as often happens, some new requirement comes along. Code 
> space is now a real issue for everyone. No problem: our chosen 
> architecture has just the solution: re-build all our software using 
> Thumb mode.
> 
> 5. We re-build our software and are faced with an immediate problem: 
> our nice macros that are used everywhere no longer work, as they use 
> ARM-mode specific instructions.
> 
> How do we solve this problem? there are all sorts of ways it can be 
> solved: I'm sure you and I could both come up with several without 
> too much effort. The problem is that it will take effort, no matter 
> how it's done.

You cannot turn off interrupts while in thumb mode if you do not
interwork. 

> The point I'm making is that the more you use non-standard, compiler-
> specfic features such as in-line assembler, the more likely it is 
> that changing requirements will cause problems.

GCC supports interworking.  It has compiler options to select the
paradigm you want to adopt for interworking.  If you do not want to
use it because it is not supported in the same way on all compilers,
that is up to you.

I like to use the feature given I think GCC supports it well enough.

> I completely take your point that your example was for illustrative 
> purposes only, and that you probably wouldn't implement these macros 
> in a working system (possibly for the reasons I outline).

This is not what I said.  I stand by what I said.

Finally Brendan, my on-the-fly example having served its purpose, and
the forum having moved on, it is about time you do the same.

Jaya

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.