Xref: utzoo comp.lang.c++:2216 comp.lang.c:14597 comp.lang.misc:2317
Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!pitstop!sundc!seismo!uunet!vsi!friedl
From: friedl@vsi.COM (Stephen J. Friedl)
Newsgroups: comp.lang.c++,comp.lang.c,comp.lang.misc
Subject: Re: Assembly or ....
Summary: C with asm macros are pretty hot
Message-ID: <966@vsi.COM>
Date: 7 Dec 88 03:28:04 GMT
References: <1388@aucs.UUCP> <707@ethz.UUCP> <818@quintus.UUCP>
Organization: V-Systems, Inc. -- Santa Ana, CA
Lines: 38

In article <707@ethz.UUCP> pasche@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@quintus.UUCP>, ok@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@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!"