Computer Old Farts Forum
 help / color / mirror / Atom feed
From: ralph at (Ralph Corderoy)
Subject: [COFF] Pointers for maths routines in "assembly"
Date: Mon, 25 May 2020 06:22:29 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 962 bytes --]

Hi Warren,

> Assume that you can multiply two 8-bit values in hardware and get a
> 16-bit result (e.g. ROM lookup table). It's straightforward to use
> this to multiply two 16-bit values:
> But if the hardware can only provide the low eight bits of the 8-bit
> by 8-bit multiply, is it still possible to do a 16-bit by 16-bit
> multiply?

Yes.  Given hex 8-b numbers ab and cd, use your 8×8=8 hardware multiply
to work out

    b × d = BD
    a × d = AD
    b × c = BC
    a × c = AC

and then shift and add:

    BD + (AD << 4) + (BC << 4) + (AC << 8)

> ** Back story. I'm designing an 8-bit TTL CPU which has 8-bit
> multiply, divide and modulo in a ROM table. I'd like to write
> subroutines to do 16-bit and 32-bit integer maths.

That's quite an unusual mix.  Eight-bit CPUs I can think of either have
no hardware multiply of which to take advantage,
e.g., or have a 8×8=16.

Cheers, Ralph.

  reply	other threads:[~2020-05-25  5:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-25  4:27 wkt
2020-05-25  5:22 ` ralph [this message]
2020-05-25  9:12 ` dfawcus+lists-coff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).