🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.powerpc
Article #4

Re: ANSWER: algorithm to perform 64-bit / 32-bit signed & unsigned divide

#4
From: Brian Lowry
Date: Sat, 03 Sep 1994 00:38
34 lines
2246 bytes
In article <348a5a$dhs@haven.umd.edu>, Charles B. Cranston
<zben@ni.umd.edu> wrote:

> These are my first two assembly language programs on the power PC.
> dmult multiplies two 32 bit numbers to get a 64 bit result,
> ddiv divides a 32 bit number into a 64 bit number to get a 32 bit result.
> it probably needs to be protected from overflow...

> dmult   ;
>         MulLW   R6,R3,R4                ; Generate low word of result
>         StW     R6,4(R5)                ; Save result
>         MulHWU  R7,R3,R4                ; Generate high word of result
>         StW     R7,0(R5)                ; Save result
>         BLR                             ; Return to caller

  This code makes me curious about PPC assembly (I've read the manual and
a book on it, but I guess the details don't stick until you write some
code).  I would have thought that there would be some way to get the 64bit
value to an FP register and then write it out to memory, thus saving a
very expensive extra memory write operation.  Also, everything I know
about pipelining suggests that reorganizing the code as

MulLW   R6,R3,R4                ; Generate low word of result
MulHWU  R7,R3,R4                ; Generate high word of result
StW     R6,4(R5)                ; Save result
StW     R7,0(R5)                ; Save result

would be more efficient.  If anyone can spare the time to clue me in on
the finer points of PPC assembly, I'd appreciate it (not that I mind
programming in C/C++, but occasionally it seems somewhat inefficient...)

-- 

Brian Lowry
Technical Details
Message-ID: <usenet-0209941834550001@lowry.eche.ualberta.ca>
Path: arc1-ca.pugleaf.net!wupost!gumby!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!unixg.ubc.ca!quartz.ucs.ualberta.ca!lowry.eche.ualberta.ca!user
References: <joe.777905986@babel.ho.att.com> <348a5a$dhs@haven.umd.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!wupost!gumby!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!unixg.ubc.ca!quartz.ucs.ualberta.ca!lowry.eche.ualberta.ca!user
From: usenet@lowry.eche.ualberta.ca (Brian Lowry)
Newsgroups: comp.sys.powerpc,comp.arch.arithmetic,gnu.misc.discuss,comp.programming,sci.math,alt.sources
Subject: Re: ANSWER: algorithm to perform 64-bit / 32-bit signed & unsigned divide
Date: 3 Sep 1994 00:38:31 GMT
Organization: Dept. of Chemical Eng., University of Alberta
Lines: 34
Distribution: world
Message-ID: <usenet-0209941834550001@lowry.eche.ualberta.ca>
References: <joe.777905986@babel.ho.att.com> <348a5a$dhs@haven.umd.edu>
NNTP-Posting-Host: lowry.eche.ualberta.ca