Shop OBEX P1 Docs P2 Docs Learn Events
Anybody got code for assembly language multiply? — Parallax Forums

Anybody got code for assembly language multiply?

Bill BairdBill Baird Posts: 23
edited 2006-08-03 00:48 in Propeller 1
Anybody got a piece of code handy for assembly language multiply?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-01 18:17
    There's a document that was posted some time ago called "Propellor Guts" that includes a discussion of multiplication and division including sample routines. I've attached a copy since I don't have the link handy.
  • Bill BairdBill Baird Posts: 23
    edited 2006-08-02 00:21
    Woah - Thank You. There is a wealth of good stuff for assembly coding in here that I didn't find in the newly released manual.
  • edited 2006-08-02 04:08
    And don't forget this page.

    http://www.sxlist.com/cgi-bin/constdivmul.exe?cpu=sx

    It shows how some functions are done on the SX using shifs and adds. You can then make you own code for the Propellor..

    -Dan

    Post Edited (Direct Digital Labs) : 8/2/2006 4:14:24 AM GMT
  • Bill BairdBill Baird Posts: 23
    edited 2006-08-02 23:56
    Thanks - I have used the SX assembly code for multiply - I just wanted to see if there was a slick way to do it in propellor assembly.
  • Mike GreenMike Green Posts: 23,101
    edited 2006-08-03 00:48
    Along the line of multiplication and division, here's a 32 bit divide that yields a 32 bit quotient and remainder.

    '' 32 bit unsigned division yielding quotient and remainder
    
    divide                  mov     temp,#32                ' Divide a 32 bit unsigned dividend
                              mov     remainder,#0            '  by a 32 bit unsigned divisor to
    :loop                   shl     dividend,#1        wc   '  get a 32 bit unsigned quotient
                              rcl     remainder,#1            '  and a 32 bit unsigned remainder
                              cmpsub  remainder,divisor  wc,wr
                              rcl     quotient,#1
                              djnz    temp,#:loop
    divide_ret           ret
    
    temp                  long    0
    dividend             long    0
    remainder          long    0
    divisor                long    0
    quotient             long    0
    
    
Sign In or Register to comment.