From owner-freebsd-hackers Tue Apr 15 18:32:01 1997 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.5/8.8.5) id SAA26956 for hackers-outgoing; Tue, 15 Apr 1997 18:32:01 -0700 (PDT) Received: from caipfs.rutgers.edu (caipfs.rutgers.edu [128.6.91.100]) by freefall.freebsd.org (8.8.5/8.8.5) with ESMTP id SAA26929 for ; Tue, 15 Apr 1997 18:31:56 -0700 (PDT) Received: from jenolan.caipgeneral (jenolan.rutgers.edu [128.6.111.5]) by caipfs.rutgers.edu (8.8.5/8.8.5) with SMTP id VAA21543; Tue, 15 Apr 1997 21:31:23 -0400 (EDT) Received: by jenolan.caipgeneral (SMI-8.6/SMI-SVR4) id VAA01790; Tue, 15 Apr 1997 21:30:05 -0400 Date: Tue, 15 Apr 1997 21:30:05 -0400 Message-Id: <199704160130.VAA01790@jenolan.caipgeneral> From: "David S. Miller" To: ccsanady@nyx.pr.mcs.net CC: hackers@FreeBSD.ORG In-reply-to: <199704150943.EAA03061@nyx.pr.mcs.net> (message from Chris Csanady on Tue, 15 Apr 1997 04:43:37 -0500) Subject: Re: inline asm question.. Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk Date: Tue, 15 Apr 1997 04:43:37 -0500 From: Chris Csanady All I wanted to do was to make the below inline function generate the following code. (It is a piece from one of Van Jacobsons mails..) I realize this is for sparc, but it really doesnt matter.. /* NB - ocadd is an inline gcc assembler function */ cksum = ocadd(ocadd(ocadd(ocadd(cksum, seq), ack), flg), sum); addcc %l3,%o0,%o3 addxcc %l4,%o3,%o3 addxcc %l2,%o3,%o3 addxcc %l0,%o3,%o3 static __inline__ unsigned int ocadd1(unsigned int sum, unsigned int addend) { unsigned int ret; __asm__ __volatile__("addcc %1, %2, %0" : "=r" (ret) : "r" (sum), "r" (addend)); return ret; } static __inline__ unsigned int ocadd(unsigned int sum, unsigned int addend) { unsigned int ret; __asm__ __volatile__("addxcc %1, %2, %0" : "=r" (ret) : "r" (sum), "r" (addend)); return ret; } cksum = ocadd(ocadd(ocadd(ocadd1(cksum, seq), ack), flg), sum); something like that... Then make sure you compile using gcc and don't specify any options which disable function inlining or __asm__ directives... (BTW: as you can see Jacobsons code could not have possibly output that sequence of instructions as it is, simply because there is no way just one ocadd() function could have output both "addcc" and "addxcc" by magically knowing if it was the first invocation in a series or not) ---------------------------------------------//// Yow! 11.26 MB/s remote host TCP bandwidth & //// 199 usec remote TCP latency over 100Mb/s //// ethernet. Beat that! //// -----------------------------------------////__________ o David S. Miller, davem@caip.rutgers.edu /_____________/ / // /_/ ><