🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #11412

Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms)

#11412
From: Thomas M. Breuel
Date: Mon, 23 Nov 1992 10:05
41 lines
2441 bytes
In article <1992Nov20.135747.4642@sun0.urz.uni-heidelberg.de> dentzer@clio.iwr.uni-heidelberg.de (Ralf Dentzer) writes:

   As some sort of compromise between portability and efficiency I would make
   the following proposal for a set of basic functions to deal with multiple
   digit integers. The main restriction for them is the imposition to have a 
   C-function interface, but only thus portability can be guaranteed.

Good; that's the right way to go.

   First there should be a data type "Digit_t" e.g., usually unsigned long
   or what else fits into one register, and a constant BitsPerDigit.
   Then come six functions for calculating with Digits, these provide
   access to carrys, the higher digit of a product and a division
   with two digit dividend:

   Digit_t DigitAdd(Digit_t *sum, Digit_t a, Digit_t b, Digit_t carry);
	   /* *sum=LOW-DIGIT(a+b+carry);
	      return HIGH-DIGIT(a+b+carry); 
	   */
   [...]

   These functions are sufficient to build a multiple digit arithmetic,
   but due to function call overhead they are too slow.
   (More or less, depending on the processor; on a Sparc their
   performance is not that bad.)

You could standardize these as macros, not functions.  The main
user-visible difference would be in not being able to take the
address. Even if you do define these as functions, your compiler
could (and should) inline them.

Also, a slightly better interface might be to turn this into a
conditional construct, conditional on the carry bit:

	CPU_WORD result,a,b;
	...
	ADD_WITH_CARRY(result,a,b) { /* carry==1 */ }
	else { /* carry==0 */ }


					Thomas.
Technical Details
Message-ID: <TMB.92Nov23100525@arolla.idiap.ch>
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!tamsun.tamu.edu!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
References: <Bxr8vG.IpI@mentor.cc.purdue.edu> <martin.721995695@bert> <martin.722176263@bert> <1992Nov20.135747.4642@sun0.urz.uni-heidelberg.de>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!cs.utexas.edu!tamsun.tamu.edu!snorkelwacker.mit.edu!ai-lab!life.ai.mit.edu!tmb
From: tmb@arolla.idiap.ch (Thomas M. Breuel)
Newsgroups: comp.arch,comp.lang.misc
Subject: Re: how to advocate new software/hardware features (Re: Hardware Support for Numeric Algorithms)
Date: 23 Nov 92 10:05:25
Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
 Perceptive)
Lines: 41
Message-ID: <TMB.92Nov23100525@arolla.idiap.ch>
References: <Bxr8vG.IpI@mentor.cc.purdue.edu> <martin.721995695@bert>
 <martin.722176263@bert>
 <1992Nov20.135747.4642@sun0.urz.uni-heidelberg.de>
Reply-To: tmb@idiap.ch
NNTP-Posting-Host: arolla.idiap.ch
In-reply-to: dentzer@clio.iwr.uni-heidelberg.de's message of Fri, 20 Nov 92 13:57:47 GMT