Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: Notesfiles $Revision: 1.7.0.10 $; site mirror Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!ima!inmet!mirror!rs From: rs@mirror.UUCP Newsgroups: net.lang.c Subject: Re: Orphaned Response Message-ID: <6000010@mirror> Date: Thu, 27-Mar-86 09:21:00 EST Article-I.D.: mirror.6000010 Posted: Thu Mar 27 09:21:00 1986 Date-Received: Sat, 12-Apr-86 21:59:04 EST References: <1700003@umn-cs> Lines: 49 Nf-ID: #R:umn-cs:-170000300:mirror:6000010:000:1357 Nf-From: mirror.UUCP!rs Mar 27 09:21:00 1986 A friend of mine recently did what you want. We were running UniPlus SysV on a 68000. He was doing image compression and needed to sample every n'th bit in a source, writing it out as the m'th bit in the destination. The 68000 "test bit specified by register X" was too slow, and he also wanted to unroll the loops. As I remember, the code went something like this: typedef int (*PFI)(); typedef short WORD; extern char *malloc(); PFI generate(count) int count; { WORD *base; WORD *p; base = p = malloc(sub_size); *p++ = prolog; /* he had the actual */ *p++ = prolog; /* hex words of the */ while (--count >= 0) { *p++ = test_bit; /* code here, not these */ *p++ = branch_if_zero .+2; /* "mnemonics" */ *p++ = mv 0,(a0); *p++ = skip; *p++ = mv 1,(a0); *p++ = decrement and branch if non-zero .-5; } *p++ = epilog; *p++ = return; return((PFI)base); } Then, in the main routine he had something like this: PFI *p, generate(); p =generate(5); (*p)(); I may have a cast or two slightly wrong, but the basic principle is sound. (Well, it worked, at any rate; I don't know how sound the basic principle really is :-) -- Rich $alz {mit-eddie, ihnp4!inmet, wjh12, cca, datacube}!mirror!rs Mirror Systems 2067 Massachusetts Avenue Cambridge, MA, 02140 Telephone: 6,176,610,777