Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!cbosgd!gatech!seismo!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: Long Longs Message-ID: <3408@umcp-cs.UUCP> Date: Fri, 28-Feb-86 21:36:22 EST Article-I.D.: umcp-cs.3408 Posted: Fri Feb 28 21:36:22 1986 Date-Received: Sun, 2-Mar-86 02:24:53 EST References: <491@faron.UUCP> Distribution: net Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 35 In article <491@faron.UUCP> bs@faron.UUCP (Bob Silverman) writes: >Does anyone have a good solution [to getting (b*c)/d and (b*c)%d >done with double-length instructions]? and also mentions that one can >write an assembler routine to do such arithmetic. However, if one >does such computations frequently (e.g. millions of times) the cost >of calling a routine to do it is prohibitive. One method, used in the 4BSD kernel and in Franz Lisp, is to write a `sed' script, and run the output of the compiler through this. Thus what looks like a function call is actually expanded in-line: # foo.e - sed script to expand various routines in line # # Usage: /lib/cpp file.c | /lib/ccom | sed -f foo.e | /lib/c2 | \ # as -o file.o # (or use .s files if your `as' cannot read pipes). # # Change calls to `foo' to a `bar' instruction. # Foo takes two arguments and presents a return # value in r0. /calls $2,_foo/s//movl (sp)+,r0\ movl (sp)+,r1\ bar r1,r0/ This costs a few redundant stack operations; these can be avoided by using the 4.3BSD `inline' program---if you have it---in place of sed. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1415) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu