1. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Hi all,

    Does anyone know what operations are found in the ALU of the atlem8051? and how can these operations be used to do an uusigned multiplication?

    Thanks in advance.
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    All microcontrollers can perform unsigned multiplication.
     
  3. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    There is an 8x8 hardware multiplier in the 8051, the Assembler op-code is MUL. If you need to do a 16bit by 16 bit multiply, you'll need to write your own routine.

    Some PIC Microcontrollers have a multiplier, some don't.

    Here's a list of routines for multiplication on a PIC that should give you an idea of what is involved, though it is a different instruction set/architecture.
     
  4. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Thanks for the replies.

    Another question: In the ALU, why is two's complement better to represent signed numbers?
     
  5. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    2's compliment makes an 8 bit unsigned number (0-255 range) into a 7 bit signed number (-127 to 127 range). The sign bit states if the number is positive or negative.

    With 2's compliment, all math is performed the exact same way as it would be using unsigned numbers, no special hardware for subtraction, for example. Simply add the 2's compliment of the number to be subtracted.
     
  6. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    No one system is better than another. They might serve different purposes.
    The neat thing about two's complement is when you add 1 to -1 the answer is 0.

    Wow!
     
  7. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
    Isn't it from -128 to +127 ?? or am I wrong ?
     
    Last edited: Feb 13, 2013
  8. Dritech

    Thread Starter Well-Known Member

    Sep 21, 2011
    756
    5
  9. MrChips

    Moderator

    Oct 2, 2009
    12,440
    3,360
    You are correct. Eight-bit two's complement range is -128 to +127, to be precise.
     
  10. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Yes, but rounding to equal numbers simplifies things. :eek:
     
  11. nigelwright7557

    Senior Member

    May 10, 2008
    487
    71
    Just use C then C will take care of multiplication.
     
Loading...