Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!gatech!hao!noao!mcdsun!fnf From: fnf@mcdsun.UUCP (Fred Fish) Newsgroups: comp.lang.c Subject: Re: re-using registers Message-ID: <343@mcdsun.UUCP> Date: Wed, 22-Jul-87 19:09:41 EDT Article-I.D.: mcdsun.343 Posted: Wed Jul 22 19:09:41 1987 Date-Received: Sat, 25-Jul-87 02:13:14 EDT References: <2803@phri.UUCP> Reply-To: fnf@mcdsun.UUCP (Fred Fish) Organization: Motorola Microcomputer Division Lines: 42 In article <2803@phri.UUCP> roy@phri.UUCP (Roy Smith) writes: > > Imagine the following (rather silly) function: > [...deleted...] > Are there any C compilers (or other languages, for that matter) >which are smart enough to realize that rs and rp could be put in the same >register? In Fortran you would write this as "EQUIVALENCE (RS, RP)" and The GNU C compiler emits: .globl _f .text .even _f: link a6,#0 movl a6@(12),d0 movl a6@(8),a0 tstb a0@ <--- use a0 for first pointer jeq L13 L2: addql #1,a0 tstb a0@ jne L2 L13: movl d0,a0 tstl a0@ <--- reuse a0 for second pointer jeq L12 L7: movl a0@,a0 tstl a0@ jne L7 L12: unlk a6 rts So the answer is yes, and it won't even cost you an arm and a leg... -Fred -- = Drug tests; just say *NO*! = Fred Fish Motorola Computer Division, 3013 S 52nd St, Tempe, Az 85282 USA = seismo!noao!mcdsun!fnf (602) 438-3614