*[COFF] Pointers for maths routines in "assembly"@ 2020-05-25 4:27 wkt2020-05-25 5:22 ` ralph 2020-05-25 9:12 ` dfawcus+lists-coff 0 siblings, 2 replies; 3+ messages in thread From: wkt @ 2020-05-25 4:27 UTC (permalink / raw) Hi all, I have a strange question and I'm looking for pointers. 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: AABB * CCDD ---- PPPP = BB*DD QQQQ00 = BB*CC RRRR00 = AA*DD SSSS0000 = AA*CC -------- 32-bit result 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? Next question, is it possible to do 16-bit division when the hardware can only do 8-bit divided by 8-bit. Ditto 16-bit modulo with only 8-bit modulo? Yes, I could sit down and nut it all out from scratch, but I assume that somewhere this has already been done and I could use the results. Thanks in advance for any pointers. Warren ** 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. ^ permalink raw reply [flat|nested] 3+ messages in thread

*

**[COFF] Pointers for maths routines in "assembly"**2020-05-25 4:27 [COFF] Pointers for maths routines in "assembly" wkt**@ 2020-05-25 5:22 ` ralph**2020-05-25 9:12 ` dfawcus+lists-coff 1 sibling, 0 replies; 3+ messages in thread From: ralph @ 2020-05-25 5:22 UTC (permalink / 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 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. http://6502org.wikidot.com/software-math-intmul, or have a 8×8=16. -- Cheers, Ralph. ^ permalink raw reply [flat|**nested**] 3+ messages in thread*

2020-05-25 4:27 [COFF] Pointers for maths routines in "assembly" wkt 2020-05-25 5:22 ` ralph**[COFF] Pointers for maths routines in "assembly"****@ 2020-05-25 9:12 ` dfawcus+lists-coff**1 sibling, 0 replies; 3+ messages in thread From: dfawcus+lists-coff @ 2020-05-25 9:12 UTC (permalink / raw) On Mon, May 25, 2020 at 02:27:26PM +1000, Warren Toomey wrote: > > Next question, is it possible to do 16-bit division when the hardware > can only do 8-bit divided by 8-bit. Ditto 16-bit modulo with only 8-bit > modulo? I believe so. I've seen code for a 68000 to do division of 32 bit values when the chip only provides for division of 16 bit values. So the same approach should apply for extending an 8 bit divide to provide 16 bit division. The book I have this in attributes the algorith to a Dr. Arthur Norman. See https://archive.org/stream/Programming_The_M68000_1983_Adn-Wesley_Publishing_Company/Programming_The_M68000_1983_Addison-Wesley_Publishing_Company_djvu.txt Section 5.8 & 5.9, page 99 in the actual printed book. DF ^ permalink raw reply [flat|**nested**] 3+ messages in thread

end of thread, other threads:[~2020-05-25 9:12 UTC | newest]Thread overview:3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-05-25 4:27 [COFF] Pointers for maths routines in "assembly" wkt 2020-05-25 5:22 ` ralph 2020-05-25 9:12 ` dfawcus+lists-coff

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).