This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Writing a C logic for moving MDH register contents after MUL instruction

i am trying to port an assembly logic which is as below

MUL R8,R9
MOV R4, MDH

i am trying to write the same logic in C. i need to move the MDH contents into a variable which i am not able to do.when i check the assembly listing of the C code, i find that always the MDL contents are being moved and not the MDH contents. has anyone encountered this problem.

Parents
  • Are you trying to do a 32-bit multiplication? You may have forgotten to use a type cast to long. Remember that in C the product of two ints is int. Compile this and see the difference:

    int a, b, c, d;
    c = ( a * b ) >> 16;
    d = ( (long)a * (long)b ) >> 16;
    

Reply
  • Are you trying to do a 32-bit multiplication? You may have forgotten to use a type cast to long. Remember that in C the product of two ints is int. Compile this and see the difference:

    int a, b, c, d;
    c = ( a * b ) >> 16;
    d = ( (long)a * (long)b ) >> 16;
    

Children
No data