To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcxOpen lugnet.robotics.rcx in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / 1621
1620  |  1622
Subject: 
RE: h8/300 16-bit multiply
Newsgroups: 
lugnet.robotics.rcx
Date: 
Mon, 4 Mar 2002 05:26:52 GMT
Reply-To: 
<rhempel@bmts.SAYNOTOSPAMcom>
Viewed: 
2693 times
  
I'm trying to implement a 16bit multiply that leaves a 32bit result
on the H8/300.  The RCX ROM includes 16x16=16 and 32x32=32
multiplication routines, but not the intermediate step.  Any hints
or pointers?

The easiest thing is to cast your 16 bit values to 32 bits and use the
built-in 32x32 multiply...

Here's the code from pbForth that does it. (It's written in a pseudo-
assebler, but you can probably figure it out...)

#------------------------------------------------------------------------------
# UM*    UM* ( u1 u2 -- ud )
# ---------------------------------------------------------------------------
pbPrimary {UM*} UMStar 0 CORE

pbCode {}         {MOV.W  r3,rA             } {Save the registers we're using}
pbCode {}         {MOV.W  r4,rB             } {                              }
pbCode {}         {MOV.W  r5,rC             } {                              }
pbCode {}         {MOV.W  #0x0000,r5        } {MSW of u2                     }
pbCode {}         {MOV.W  @rDSP,r4          } {u1                            }
pbCode {}         {MOV.W  #0x0000,r3        } {MSW of u1                     }

pbCode {}         {JSR    _rom_ulong_mul    } {                              }
pbCode {}         {MOV.W  r6,@rDSP          } {LSW of ud                     }
pbCode {}         {MOV.W  r5,r6             } {MSW of ud                     }

pbCode {}         {MOV.W  rC,r5             } {Restore the registers we saved}
pbCode {}         {MOV.W  rB,r4             } {                              }
pbCode {}         {MOV.W  rA,r3             } {                              }

pbCode {}         {JMP    NEXT              }


Cheers, Ralph

--------------------------------------------------------------------
Check out pbFORTH for LEGO Mindstorms at:
<http://www.hempeldesigngroup.com/lego/pbForth>

Buy "Extreme Mindstorms: an Advanced Guide to Lego Mindstorms"
<http://www.amazon.com/exec/obidos/ASIN/1893115844/hempeldesigngrou>
--------------------------------------------------------------------
Reply to:      rhempel at bmts dot com
--------------------------------------------------------------------



Message has 1 Reply:
  Re: h8/300 16-bit multiply
 
Thanks. I have a version just 2 words longer that doesn't use the ROM code. Basically it's the ROM's code, trimmed down after assuming high words are zero initially. It's completely untested though, so there may be a bug. CODE UM* \ 16x16=32 (...) (23 years ago, 4-Mar-02, to lugnet.robotics.rcx)

Message is in Reply To:
  h8/300 16-bit multiply
 
I'm trying to implement a 16bit multiply that leaves a 32bit result on the H8/300. The RCX ROM includes 16x16=16 and 32x32=32 multiplication routines, but not the intermediate step. Any hints or pointers? (it should be straightforward, but my eyes (...) (23 years ago, 27-Feb-02, to lugnet.robotics.rcx)

4 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR