printf (' hello world! ');
Kevin Buettner
kev@primenet.com
Fri, 30 Jun 2000 16:52:40 -0700
On Jun 30, 4:09pm, Shawn T. Rutledge wrote:
> > What is the Linux equivalent of assembly ?
>
> You can do assembly in Linux, the assembler is as86. There is also
> nasm I believe.
Don't forget gas. (The GNU ASsembler used by gcc.)
> But I haven't done it. I suspect you could still
> make function calls to libc functions for doing output, etc. I
> don't think it gets much use outside the kernel itself.
I think you're talking about inline assembler. It comes in handy from
time to time for directly accessing the CPU's registers and for
executing instructions (e.g, cache flushing / synchronization
instructions) which the compiler will never emit. Of course, it's
best avoided if possible since it is extremely non-portable.
But when you really need it, inline assembler is invaluable because
the only other choice is to write the whole function in assembler.
For a good example of a wise use of inline assembler, take a look at
the dmalloc package. (At http://dmalloc.com/ ... dmalloc is a malloc
debugging library.) dmalloc uses inline assembler for getting at the
return address in the various replacement functions (malloc, free,
realloc, etc).