PIC24 Multiply instruction

General discussion on mikroC for dsPIC30/33 and PIC24.
Post Reply
Author
Message
MiteaRazvan
Posts: 4
Joined: 22 Oct 2008 08:03

PIC24 Multiply instruction

#1 Post by MiteaRazvan » 07 May 2009 09:30

Hello,

I am developing a project on PIC24FJ64A002 microcontroller and I'm having a little problem regarding the MUL.SS instruction.
The datasheet tells me that MUL.SS outputs the result in W3:W2 register pair.
The problem is that if I'm trying to multiply two negative numbers (say -50 and -1000) the W2 will contain the correct result (50,000) , but W3 will contain the sum of the two operands (-1050), even though W3 should remain 0 ( because W2 didn't overflow). For me that is a problem because afterwards I am making some shifting operations on W3 and W2 and I will get incorrect results.

P.S. This happens only if at least one of the operands is negative, if both are positive, the multiply will give 50,000 in W2 and 0 in W3 (on the values mentioned earlier).

If anyone could help me with this I would appreciate it very much.

Thank you,

Mitea Razvan

Post Reply

Return to “mikroC for dsPIC30/33 and PIC24 General”