﻿ 24 bit multiplication
22 May, 2013, 00:45:35
 OmnomIRC You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

 Pages: 1 2 [3]   Go Down
 Author Topic: 24 bit multiplication - multiply two 24 bit numbers to get 48 bit result  (Read 1781 times) 0 Members and 1 Guest are viewing this topic.
jacobly
LV4 Regular (Next: 200)

Offline

Date Registered: 09 October, 2011, 01:53:09
Posts: 199

Total Post Ratings: +149

 « Reply #30 on: 11 December, 2011, 21:06:55 » 0

 123456789 // Multiply a times btemp = 0repeat for each bit in a temp <<= 1 if (high bit of a set) temp += b a <<= 1return temp
if a and b are 2 bytes, temp is 4 bytes, and you loop 16 times.
Spoiler for for code:
stolen from Axe
p_MulFull:
; Input in hl, result in cahl
ld   c,h
ld   a,l
ld   hl,0   ;11
ld   b,16   ;7
__MulFullNext:
rla      ;4
rl   c   ;8
jr   nc,__MulFullSkip   ;12/7
jr   nc,__MulFullSkip
inc   c
__MulFullSkip:
djnz   __MulFullNext
ret
__MulFullEnd:

 1234567891011121314 // Sqrt atemp = high byte of aa <<= 8b = 0repeat for every 2 bits in a test = b << 8 + 0x40 b <<= 1 if (temp >= test) temp -= test set low bit of b temp += high 2 bits of a a <<= 2return b
If a is 4 bytes, then b and temp are 2 bytes, and you loop 16 times.
Spoiler for code:
stole my own routine from axe (and modified it)
p_Sqrt88:
; input in hlde, result in de
ld   b,16
ld   a,h
ld   c,l
push   de ; ld ixh,d
pop   ix ; ld ixl,e
ld   de,0
ld   h,d
ld   l,e
__Sqrt88Loop:
sub   \$40
sbc   hl,de
jr   nc,__Sqrt88Skip
__Sqrt88Skip:
ccf
rl   e
rl   d
rl   c
rla
rl   c
rla
djnz   __Sqrt88Loop
ret
__Sqrt88End:
 Logged
 Pages: 1 2 [3]   Go Up

Page created in 0.172 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.