MIPS assembly code multiplier/divider. - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

MIPS assembly code multiplier/divider.

I have to write an unsigned 16-bit software implementation of a multiplier and a divider in MIPS assembly code. Two positive integers are read from the console. The program is supposed to multiply and divide the two integers, outputting the product, quotient and remainder.

[b]Here is an example run:[/b]
Enter an integer: 10
Enter an integer: 4
Product is 40
Quotient is 2
Remainder is 2

I can't use any MIPS multiply/divide instructions either.
CAN SOMEONE PLEASE HELP ME WITH THIS? I'M STILL A BEGINNER WITH MIPS ASSEMBLY LANGUAGE AND WOULD APPRECIATE ANY HELP. I know the process involves shifts, but I really need help with this project...please help.

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : I have to write an unsigned 16-bit software implementation of a
    : multiplier and a divider in MIPS assembly code. Two positive
    : integers are read from the console. The program is supposed to
    : multiply and divide the two integers, outputting the product,
    : quotient and remainder.
    :
    : [b]Here is an example run:[/b]
    : Enter an integer: 10
    : Enter an integer: 4
    : Product is 40
    : Quotient is 2
    : Remainder is 2
    :
    : I can't use any MIPS multiply/divide instructions either.
    : CAN SOMEONE PLEASE HELP ME WITH THIS? I'M STILL A BEGINNER WITH MIPS
    : ASSEMBLY LANGUAGE AND WOULD APPRECIATE ANY HELP. I know the process
    : involves shifts, but I really need help with this project...please
    : help.
    :

    I don't know MIPS but the basics of multiplying and/or dividing two numbers using only addition and subtraction is:
    Multiply: a * b -> Initialise a result variable to 0, create a loop from 1 to a, and in the loop add b to the result. Then at the end of the loop you'll have b+b+..+b for 'a' times, thus a*b
    Division: a / b -> Initialise a counter variable to 0, create a loop that ends when a < b, and in this loop subtract b from a (a = a - b) and add one to counter. Then at the end of the loop, counter will hold the amount of times you've managed to subtract b from a }= a/b
    (and incidentally, what's left in a is the remainder after division)
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.