Question

Using MASM Please! Part 1: Call Mul from a procedure (50 pts) Create a procedure, and in that pro...

Using MASM Please!

Part 1: Call Mul from a procedure (50 pts)

Create a procedure, and in that procedure multiply two numbers together using mul.
Then call the procedure from the main procedure.

Part 2: Do bitwise mulitiplication using only shift and add statements (30 pts)

In your multiplication procedure multiply two numbers not using mul but by
combining a fixed number of shift and add commands. For this part you only need
to be able to handle 8 bit numbers so you don't need to use a loop for this part

Part 3: Add loop to bitwise multiplication procedure (20 pts)

Instead of using a fixed number of bitwise multipliers, use a loop to run the bitwise
multiplication

EC 15 pts:

Create a bitwise division procedure.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
public int mul(int a, int b) {
    if (a ==0  || b == 0) {
        return 0;
    }

    if (a == 1) {
        return b;
    }
    else
        if (b == 1) {
            return a;
        }

    int result = 0; 
    int x = a;
    boolean isORNeeded = false;
    while (b != 0 ) {

        if (b == 1) {
            break;
        }

        if ((b & 1) == 1) //......... Carry needed, odd number.........
         {  
                 result += x; 
            isORNeeded = true;
        }

        a <<= 1; // this will Doubles the a
        b >>= 1; // this will make Half of the b
        System.out.println("a=["+a+"], b=["+b+"], result=["+result+"]");
    }

    return (isORNeeded ? (a | x) : a); // a + result;
}
Add a comment
Know the answer?
Add Answer to:
Using MASM Please! Part 1: Call Mul from a procedure (50 pts) Create a procedure, and in that pro...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Assembly - Call Mul from a procedure Create a procedure, and in that procedure multiply...

    In Assembly - Call Mul from a procedure Create a procedure, and in that procedure multiply two numbers together using mul. Then call the procedure from the main procedure. - Do bitwise mulitiplication using only shift and add statements In your multiplication procedure multiply two numbers not using mul but by combining a fixed number of shift and add commands. For this part you only need to be able to handle 8 bit numbers so you don't need to use...

  • First you must create a logic circuit using only basic gates such as AND, OR, NOR,...

    First you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement an ADDER capable of adding two 4 bit binary numbers. Second you must create a logic circuit using only basic gates such as AND, OR, NOR, NAND, NOT, etc. to implement a Subtractor that is capable of subtracting the second number from the first, by converting the second number into its 2's complement form and then adding the resulting...

  • Python Help Create a program that outputs a table from 1 to 5 using what you've...

    Python Help Create a program that outputs a table from 1 to 5 using what you've learned about "for" loops. Your program will print the number and indicate if the number is odd or even. If it is not odd you will multiply 2 numbers with it: number 1 and number 2. Your program must do the multiplication for only even numbers in the table. The output of your program should look like the figure below. Hint: Create a program...

  • Using Racket Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is...

    Using Racket Create a Racket procedure compute_pos that reads numbers from the keyboard until 0 is read, count how many positive numbers are read, and also compute the sum of only positive numbers, and display the count and the sum of positive numbers in different lines. Note that 0 is not included in the computations. For example, if user enters: 3 6 -4 12 15 -9 -24 4 -3 -5 1 0 then your procedure should print positive count: 6...

  • Can someone carefully explain and answer questions 1, 2, 3, 4 and 5 in detail, please!!! Multiplication can be thought...

    Can someone carefully explain and answer questions 1, 2, 3, 4 and 5 in detail, please!!! Multiplication can be thought of as repeated addition. Three times four is 4 added to itself 3 times. 1) Create an assembly program that multiplies two 8 bit integers (2's complement) together in your PIC, using the repeated summation technique 2) Add a feature to your program that detects if the answer is too big to hold in 8 bit 2's complement notation 3)...

  • Can someone carefully explain and answer questions 1, 2, 3, 4 and 5 in detail, please!!!...

    Can someone carefully explain and answer questions 1, 2, 3, 4 and 5 in detail, please!!! Multiplication can be thought of as repeated addition. Three times four is 4 added to itself 3 times. 1) Create an assembly program that multiplies two 8 bit integers (2's complement) together in your PIC, using the repeated summation technique 2) Add a feature to your program that detects if the answer is too big to hold in 8 bit 2's complement notation 3)...

  • Problem 3 (13 pts): (modified from Attaway Problem 3.39) a) (5 pts) Using the Matlab rand () func...

    Problem 3 (13 pts): (modified from Attaway Problem 3.39) a) (5 pts) Using the Matlab rand () function, create a script that generates a row vector (1 row X 20 columns) of random numbers, each with magnitude between 0 and 5 b) (3 pts) Use the round() function to turn all of the values into whole numbers by rounding down (truncate the decimal part on your vector) c) (5 pts) Add code to your script to generate a new vector...

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

  • 1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers...

    1. Write a program in Assembly language using MIPS instruction set that reads two integer numbers from the user named as start and end number and finds out all the prime numbers between start and end (including start and end). Your program should do the validation of both the numbers as follows: i. start number must be smaller or equal to the end number. ii. Both numbers must be positive. iii. The maximum value for the end number is 10000...

  • Please help code in c++ and use the answers you get from question 1 and 2...

    Please help code in c++ and use the answers you get from question 1 and 2 into the 3rd answer! Question 1 is first, question 2 is in the middle, question 3 is last Input Array (10 pts) te a function only (no main) that takes an array of doubles as a parameter as well as another integer rray. Create a for loop that asks the user to input any real number between-100 and r each element of the array....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT