1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MSP430 Assembly Language Pythagorean Theorem HELP!

  1. Mar 1, 2009 #1
    The problem statement given is this:
    Write a PUBLIC function in MSP430 assembly that implements the
    Pythagorean theorem A^2 + B^2 = C^2.
    Make A and B 16bit
    integers. What size should you make C? Your function must
    use the HW multiplier's multiply and accumulate feature. Also write a brief main
    in either C or assembly which first assigns values to A and B and then calls your
    function. Your main does not have to display the results but explain where and
    how C is stored.

    So far I have this:

    NAME HW62
    PUBLIC pytha
    ORG 0200h

    A DS16 1
    B DS16 1
    C DS16 1
    AA DS32 1
    BB DS32 1
    CC DS32 1

    ORG 0FFFEh
    RSEG CODE
    DW pytha
    Pytha MOV #0xA00, SP
    CLR R4
    CLR R5
    CLR R6
    DINT
    MOV A, MPY
    MOV A, OP2
    NOP
    MOV RESLO, AA(R4)
    INCD R4
    MOV RESHI, AA(R4)
    MOV B, MPY
    MOV B, OP2
    NOP
    MOV RESLO, BB(R5)
    INCD R5
    MOV RESHI, BB(R5)
    ADD AA, BB
    MOV BB, CC



    This uses the hardware multiplier to multiply A by itself and B by itself, adds the two results together and places the result in CC. My problem is I don't know how to extract simply C. There is no function in MSP430 Assembly that does square roots as far as I know. Could someone help please?
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?



Similar Discussions: MSP430 Assembly Language Pythagorean Theorem HELP!
  1. Assembly Language (Replies: 0)

  2. Thermodynamics help (Replies: 0)

Loading...