Path: utzoo!attcan!uunet!portal!cup.portal.com!doug-merritt
From: doug-merritt@cup.portal.com
Newsgroups: comp.sys.amiga
Subject: Re: In-line assembly in Lattice C
Message-ID: <6941@cup.portal.com>
Date: 28 Jun 88 15:04:07 GMT
References: <5841@bloom-beacon.MIT.EDU> <558@sas.UUCP> <6361@well.UUCP>
Organization: The Portal System (TM)
Lines: 29
XPortal-User-Id: 1.1001.4407

>there is *no* construct that's so loony that it's not going to be useful
>sometime. For example, see Ken Arnold's character-to-printable-string macro 
>that I think was in an early version of curses.h. I can't remember it exactly,
>but it's got stuff in it like:
>
>#define ctrl(c) \
>    (((c)<' ')?("^"[1]=(c)+'@',""[-2]):(((c)>'~')?"^?":(""[0]=(c),""[-1])))

Thank you for the appreciation :-), that monstrosity was my invention.
Ken was saying how you couldn't do it as a macro without side-effects
nor a global variable, and I just had to come up with a counter example.

We both thought it was brain damaged, but hey, it did the job...I wasn't
aware that it actually got released, though. Nor that anyone but Ken
(and a few of my friends I showed it to for laughs) had ever seen it.

It worked on many different types of machines, but clearly it could get
broken by a compiler that layed out string constants in memory differently
than usual. I've never seen such a compiler, but I'm sure they exist...any
machine where there's a difference between a "packed" string and an "unpacked"
string would run into trouble (possibly a DEC 10/20, for instance).

I'd been meaning to submit it as a obfuscated-C entry but I never
got around to it.
	Doug
--
      Doug Merritt        ucbvax!sun.com!cup.portal.com!doug-merritt
                      or  ucbvax!eris!doug (doug@eris.berkeley.edu)
                      or  ucbvax!unisoft!certes!doug