Assembly or ....
Stephen J. Friedl
friedl at vsi.COM
Wed Dec 7 13:28:04 AEST 1988
In article <707 at ethz.UUCP> pasche at bernina.UUCP (Stephan Paschedag) writes:
>for example : I don't know a high-level language where you have control of
> the CPU status flags. These can be very useful for some
In article <818 at quintus.UUCP>, ok at quintus.uucp (Richard A. O'Keefe) writes:
> (b) C with "asm" or "inline" can be made to generate any instruction.
AT&T's C compilers for the 3B2, from Issue 3 and up, have assembler
macros that let you do this kind of thing in a pretty nice manner.
For example, the familiar `spl' function in the kernel would be
implemented:
asm void SPL(newpri)
{
%reg newpri; # if the arg is a register or
# or an automatic variable
spl newpri
%con newpri; # if the arg is a constant
movw newpri, %r0
spl %r0
}
The %XXX is roughly like a switch on the *type* of the argument
to the macro. If it's a register or an auto variable, then call
`spl' directly, and if it's a constant then move it into a register
before calling `spl'. There are facilities to generate temp labels
(for little loops and such), and I've found this real handy on the
rare occasions that I need to write asm.
Steve
--
Stephen J. Friedl 3B2-kind-of-guy friedl at vsi.com
V-Systems, Inc. attmail!vsi!friedl
Santa Ana, CA USA +1 714 545 6442 {backbones}!vsi!friedl
Nancy Reagan on my new '89 Mustang GT Convertible: "Just say WOW!"
More information about the Comp.lang.c
mailing list