🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #1632

Div/mod is a slow way to convert binary to decimal

#1632
From: Don Speck
Date: Sat, 22 Jul 1989 07:50
22 lines
1170 bytes
Binary to decimal conversion can be done in hardware almost as
fast as one division by 10.  Rather than subtracting off successive
binary shifts of 10, subtract off the place values of BCD bits
(from a lookup table), starting with the most significant BCD bit.
E.g.
	if (binary > 2000000000) {
		binary -= 2000000000;
		set the bit for 2000000000 in the decimal result
	}
	if (binary > 1000000000) {
		binary -= 1000000000;
		set the bit for 1000000000 in the decimal result
	}
	if (binary > 800000000) {
		binary -= 800000000;
		set the bit for 800000000 in the decimal result
	}
	...

Of course the usual methods of speeding up division (non-restoring,
etc) are applicable here too, and most of the hardware can be shared
with the divider.
Technical Details
Message-ID: <11335@cit-vax.Caltech.Edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!elroy.jpl.nasa.gov!cit-vax!mangler
References: <117065@sun.Eng.Sun.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!apple!usc!elroy.jpl.nasa.gov!cit-vax!mangler
From: mangler@cit-vax.Caltech.Edu (Don Speck)
Newsgroups: comp.arch
Subject: Div/mod is a slow way to convert binary to decimal
Message-ID: <11335@cit-vax.Caltech.Edu>
Date: 22 Jul 89 07:50:57 GMT
References: <117065@sun.Eng.Sun.COM>
Organization: California Institute of Technology
Lines: 22