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-11 by Eric Engler

--- In lpc2000@yahoogroups.com, "Stephen Pelc" <stephen@...> wrote:

> When I look at where MPE (as opposed to its clients) uses in-
> line assembly, we find it in device-specific drivers, e.g. UART 
> and Ethernet drivers, and in CPU specific sections, e.g. 
> schedulers, where we are striving for performance.

That's true with me, too. The few times I get involved with low-level
issues not already handled by libraries I need to spend a lot of hours
with irritating registers, processor modes and the like. Frankly,
these types of things make me employable, so I shouldn't complain too
much!

But I have never used any inline assember except for the code
recommended by compiler vendors (which used to happen more than it
does now - libs weren't well developed back then). I always prefer to
isolate my asm code in separate modules with well-defined API's, and
then I link them to C programs.

I also use asm for things that need to be kept secret, like licensing
support code, and the like. It's much harder to disassemble hand-coded
assembly routines than compiled C code, especially if the asm code was
written with this in mind. Sometimes the art of deception even
involves code for peripherals that aren't even being used for anything
- it's the old magicians trick of attracting you to one hand while the
other hand is doing something completely different.

Assembler routines take about 10 - 20 times longer to write than C,
and a much longer time to debug. Most companies simply can't afford
this kind of development except for those cases where there is no
alternative. And when this kind of need arises it often makes sense to
use a consultant who specializes in this.

Eric

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.