[Coco] Divide by 10 on a Motorola MC6809(E)

johnmarkmelanie at gmail.com johnmarkmelanie at gmail.com
Wed Mar 20 15:17:46 EDT 2024


Don,

That is brilliant.

-John Mark Mobley

-----Original Message-----
From: Coco <coco-bounces at maltedmedia.com> On Behalf Of Don Barber via Coco
Sent: Wednesday, March 20, 2024 12:09 PM
To: CoCoList for Color Computer Enthusiasts <coco at maltedmedia.com>
Cc: Don Barber <don at dgb3.net>
Subject: Re: [Coco] Divide by 10 on a Motorola MC6809(E)

A trick I use to divide 8 bit integers by 10 is to MUL by 205, then shift the A register down by 3 bits (ASRA three times). This works out to 205/2048 which is close enough precision to 1/10 for 8 bit integers.

Thanks

Don





More information about the Coco mailing list