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

[-- 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
b × c = BC
a × c = AC

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. http://6502org.wikidot.com/software-math-intmul, or have a 8×8=16.

--
Cheers, Ralph.

```

```next prev parent 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,

Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

switches of git-send-email(1):

git send-email \
```This is a public inbox, see mirroring instructions