Compiler Specific Operators
brooks at lll-crg.UUCP
brooks at lll-crg.UUCP
Sun Jul 13 10:03:20 AEST 1986
>C already has a hook for such things. It's called the "asm" statement.
>Despite its name, there is no law that says that what follows "asm"
>must in fact be assembly language. If you're writing the compiler,
>you can implement whatever syntax you like with whatever semantics you like.
It would be nice if asm was more "printf like" instead of just dumping
a string. I have made quite a lot of use of asms when writing things like
multitasking packages and other things which need assembler hooks. Most
of the code can be in C and be reasonably portable. I have often needed
the ability to stick a stack address in an asm without knowing just what
stack address you want to load...
ie
suppose you want to change the stack pointer...
char *oldpointer;
char *newpointer;
asm("store sp,%a", oldpointer);
asm("load sp,%a", newpointer);
The code is machine dependent, but the compiler takes care of the
C name -> AS name mapping for you. Of course I guess the compiler
should not encourage such screwing around.
More information about the Comp.lang.c
mailing list