MAC and MPY problem in assembly language
variables. The problem I have is that the result is always of twice
of the expected. For example, If I multiply 1 by 1, the the result I
got is always 2 other than 1. The following is the code I used; The C portion:
int multiply(int, int);
int some_global = 4;
int main(void)
{
int a=1, b=1, c=0;
c = multiply(a,b);
some_global = c;
return(0);
}
The assembly portion:
section rtlib
org p:
global Fmultiply
Fmultiply:
clr A
move Y1,X0
mpy Y0,X0,A
move A0,Y0
rts
endsec
Could someone tell me why this is happening. Thanks for the help
discussed in the Family Manual as well as several Application Notes...
--
dB --- haoyeshen <haoyeshen@haoy...> wrote:
> I am trying to use either MAC or MPY to make a product of two
> variables. The problem I have is that the result is always of twice
> of the expected. For example, If I multiply 1 by 1, the the result I
> got is always 2 other than 1. The following is the code I used; > The C portion:
>
> int multiply(int, int);
> int some_global = 4;
>
> int main(void)
> {
> int a=1, b=1, c=0;
>
> c = multiply(a,b);
>
> some_global = c;
>
> return(0);
>
> }
>
> The assembly portion:
>
> section rtlib
> org p:
>
> global Fmultiply
>
> Fmultiply:
>
> clr A
> move Y1,X0
> mpy Y0,X0,A
> move A0,Y0
> rts
>
> endsec
>
> Could someone tell me why this is happening. > Thanks for the help >
__________________________________________________
-----Original Message-----I am trying to use either MAC or MPY to make a product of two
From: haoyeshen [mailto:h...@yahoo.com]
Sent: Saturday, May 14, 2005 1:11 AM
To: m...@yahoogroups.com
Subject: [motoroladsp] MAC and MPY problem in assembly language
variables. The problem I have is that the result is always of twice
of the expected. For example, If I multiply 1 by 1, the the result I
got is always 2 other than 1. The following is the code I used;The C portion:
int multiply(int, int);
int some_global = 4;
int main(void)
{
int a=1, b=1, c=0;
c = multiply(a,b);
some_global = c;
return(0);
}
The assembly portion:
section rtlib
org p:
global Fmultiply
Fmultiply:
clr A
move Y1,X0
mpy Y0,X0,A
move A0,Y0
rts
endsec
Could someone tell me why this is happening.Thanks for the help
NEW! You can now post a message or access and search the archives of this group on DSPRelated.com:
http://www.dsprelated.com/groups/motoroladsp/1.php
_____________________________________
Note: If you do a simple "reply" with your email client, only the author of this message will receive your answer. You need to do a "reply all" if you want your answer to be distributed to the entire group.
_____________________________________
About this discussion group:
Archives: http://www.dsprelated.com/groups/motoroladsp/1.php
To Post: Send an email to m...@yahoogroups.com
Other DSP Related Groups: http://www.dsprelated.com/groups.phpThe information contained in this message is confidential and intended only for use of the designated recipient(s) named above. If the reader of this message is not the intended recipient or an agent responsible for delivering it to the intended recipient, you are hereby notified that you have received this message in error, and that any review, dissemination, distribution, copying, or alteration of this message is strictly prohibited. If you have received this communication in error, please notify the originator immediately and remove it from your system.