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

I NEED A SUDDEN REPLY

DEAR TO ALL, I AM DEALING WITH C8051F120 MICROCONTROLLER.UTILIZING 16 X 16 MAC ENGINE OPERATION.I AM DOING ASSEMBLY LANGUAGE PROGRAMMING USING THIS MICROCONTROLLER FOR MULTIPLICATION. IS IT POSSIBLE TO MULTIPLY TWO UNSIGNED 16 BIT INPUTS?
IF YES, THEN HOW ?

  • from the datasheet : "which can perform integer or fractional multiply-accumulate and multiply operations on signed input values" (my emphasis).

    a simple means would be to rightshift both values (/2) and multiply.

    Erik

  • Your shift key seems to be stuck. All of your letters are capitals ! Can you try and see if you can fix that somehow ?

    IS IT POSSIBLE TO MULTIPLY TWO UNSIGNED 16 BIT INPUTS?

    Yes, why shouldn't it be possible ?

    IF YES, THEN HOW ?

    Just like you would perform a multiplication by hand, on paper (you know, just like in school):

    Each of the input values consists of MSB and an LSB. Let's call them MSBa, LSBa, MSBb and LSBb.

    So you need to do the following:

    1. Multiply MSBa and MSBb. Place the 16-bit result in the upper 16 bit of your 32-bit end result.
    2. Multiply MSBa and LSBb. Add the 16-bit result to the upper 24 bits of your 32-bit end result.
    3. Multiply LSBa and MSBa. Add the 16-bit result to the upper 24 bits of your 32-bit end result.
    4. Multiply LSBa and LSBb. Add the 16-bit result to your 32-bit end result.

    And that's it. As long as you know how to add variables that are longer than one byte.

  • Oops. I didn't read the part about the device in question. In that case, follow Erik's advice.

  • my question is-- main constraints for me is execution time i want to reduce execution time too while 16x16 multiplication
    and also while writing to MAC0BL register ,MAC engine gives result
    so how i will do this shift operation?
    inputs are directly loading through serial port,so we cannt predict what is type of input? you know i need only unsigned operation there is a bit for selecting signed fractional or integer operation
    so i am asking you all that is there any bit (other than msb bit) that we can set or clear for signed or unsigned operation

    please reply

  • so i am asking you all that is there any bit (other than msb bit) that we can set or clear for signed or unsigned operation

    say your input value is in "int Ralph"

    and you right now do xxxxx Ralph; (I do not check for actual MAC code)

    Just change to xxxxx Ralph/2; (the compiler wikk change that to a shift 1 - or - you can, of course use ralph >>=- 1;

    are you multiplying or multiply-adding? If you are just multiplying then do this at the end
    result <<= 2; and you will be fine.

    BTW why the worry about signed/unsigned, if the values you multiply are >32k (where signed/unsigned differ) the result will not fit in an int.

    Erik

  • MOV SFRPAGE,#3
    MOV MAC0CF, #00H
    MOV MAC0AH, #0AAH ;INPUT A MSB
    MOV MAC0AL, #33H ;INPUT A LSB
    MOV MAC0BH, #73H ;INPUT B MSB
    MOV MAC0BL, #55H ;INPUT B LSB NOP NOP
    tell me what will be the answer

  • any chance to get the result same as what we are getting by calculator

    NOTE:mine is assembly coding

    please i need your help

  • "tell me what will be the answer"

    Can't you just run it in the simulator and see for yourself?

    Or, as these chips have on-chip debug, run it in the chip itself!

  • tried
    answers are different
    first input msb bit is set
    so our MAC Engine treating it as signed integer
    i dont want any signed operation
    i need only what calculator gives.
    Mr.Erac told to do shift operation.
    But how can we tell whether the inputs msb bit is set or not
    in my application data is 16 bit datas are getting from one equipment and we have to multiply the two and do further operation
    that is why i am asking you all that whether any bit setting for signed or unsigned operation in C8051F120

    PLEASE THIS ENTIRELY HARDWARE DEPENDENT QUESTION

  • that is why i am asking you all that whether any bit setting for signed or unsigned operation in C8051F120

    There isn't. At least not officially and described in the datasheet.

    However, you could break up a 16x16 unsigned multiplication into four 8x8 unsigned multiplications and a few bit-shifts and adds. That may or may not be faster than the method I described earlier, which doesn't make use of the MAC unit at all.

  • YES,I TRIED WITH THE MULTIPLICATION YOU EXPLAINED
    DO YOU KNOW ,WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER
    THAT IS WHY WE OPTED C8051F120

  • "But how can we tell whether the inputs msb bit is set or not"

    The same way you'd test any bit, or the MSB in any byte, surely?

    "THIS ENTIRELY HARDWARE DEPENDENT QUESTION"

    So why are you asking it in the Keil forum - as Keil have nothing to do with this hardware?!

  • HARDWARE DEPENDENT MEANS 8051 HARDWARE
    I MEAN IT AS ASSEMPLY LANGUAGE PROGRAMING

  • Your Caps-Lock is stuck again - you're writing in ALL CAPITALS again.

    "WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER"

    But, apparently, only with signed values

    "THAT IS WHY WE OPTED C8051F120"

    You missed the bit about signed values, then?
    I agree, it's very annoying when that happens - but that's life!

    :-(

  • DO YOU KNOW ,WITH MAC ENGINE WITHIN TWO SYSTEM CYCLE WE WILL GET ANSWER

    Well, the datasheet for the device clearly states that the MAC engine does 16x16 signed integer multiplications (which is quite usual for MAC units, since signed/signed is the multiplication type usually used in DSP applications).

    There's no way of getting a 16x16 unsigned/unsigned result out of the MAC engine in just two cycles, if it's supposed to be accurate. You'll have to break the multiplication up into several parts, or use the 8051's MUL command. I don't know from the top of my head which one is faster, but I guess it's going to be the former.