Question

Use assembly language to write a complete program that will input values fornum1 ,num2 and num3...

Use assembly language to

write a complete program that will input values fornum1 ,num2 and num3 and display the

value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3.

assume that the user enters only numbers that are greater than zero and the calculation never exceed 4 bytes size.

Sample run:

num1 = 1
num2 = 2
num3 = 3
((num1 ^ 3) * num2 + 5 * ( num2 ^ 2)) / num3 = 7 R 1

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the assembly code to calculate the value of the expression ( (num1 ^ 3) * num2 + 5 * ( num2 ^ 2) ) / num3.

Where the numbers are greater than zero & size of calculation does not exceeds 4 bytes.

org 0000h ;sets the program counter to the 0000h

mov R0,#num1 ;assign value 'num1' to R0 which is converted to its equivalent hexadecimal value

mov R1,#num2 ;assign value 'num2' to R1 which is converted to its equivalent hexadecimal value

mov R2,#num3 ;assign value 'num3' to R2 which is converted to its equivalent hexadecimal value

mov A,R0 ;mov the value of R0 to the accumulator A means A=num1

mul A R0 ;multiple the values of A and Ro and stores result in A,A=num1*num1

mul A R0 ;again multiple the values of A and Ro and stores result in A,A=num1*num1*num1

mul A R1 ;multiply value of A with value of R1,A=(num1^3)*num2

mov R3,A ;store the result of A in R3

mov A,R1 ;put the value of num2 to A

mul A R1 ;multiply values of A and R1,A=num2*num2

mul A #5 ;multiply the value of A with 5,A=(num2^2)*5

mov R4,A ;store the result of A in R4

mov A,R3 ;put the value of R3 to A

add A,R4 ;add the value of R4 with A & store addition in A

div A,R2 ;divide the value of A with R2 i.e. num3

end

Add a comment
Know the answer?
Add Answer to:
Use assembly language to write a complete program that will input values fornum1 ,num2 and num3...
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
  • Consider the mathematical expression (num1 + num2) × (num3 − num4). We have been asked to...

    Consider the mathematical expression (num1 + num2) × (num3 − num4). We have been asked to replace num1, num2, num3 and num4 by numbers between 1 and 35, i.e. numbers from the set {1, . . . , 35}, so that after substituting these numbers in place of num1, num2, num3 and num4, the evaluation of the expression using PEDMAS leads to an odd positive integer. Find the number of ways in which this can be done. For example, one...

  • Problem Description: Write s Java program to find and display the product of three integer values...

    Problem Description: Write s Java program to find and display the product of three integer values based on the rue mentioned below it should display the product of the three values except when one of thevalues is 7n that case 7 should not be ingluded in the product and the values to its left also shouid not be included If there is only one value to be considered display that value tself f no values can be included in the...

  • C++ Write a program that prompts the user to enter two positive integers: num1 and num2....

    C++ Write a program that prompts the user to enter two positive integers: num1 and num2. - Validate that num1 is less than num2 and that both numbers are positive. If any of these conditions are not met, allow the user to re-enter num1 and num2 until the input is determined valid. - For all integers from num1 through num2, print the word keyboard if the current integer is divisible by 2 and print the word mouse if the current...

  • 1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that...

    1. Assume that you are given values in eax, ebx, ecx. Write an assembly code that does the following: eax = (ecx + edx ) - (eax + ebx) 2. Write a piece of code that copies the number inside al to ch. Example: Assume that Initially eax = 0x15DBCB19. At the end of your code ecx = 0x00001900. Your code must be as efficient as possible. 3. You are given eax = 0x5. Write one line of code in...

  • This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //  ...

    This is an external javascript file // Problem 1:   Declare the variables num1, num2, ans1, //               greet1, greet2. Then initialize them to //               hold the values 1, 2, 0, "Hello", and //               "World", respectively. var num1 = 1; var num2 = 2; var ans1 = 0; var greet1 = "Hello"; var greet2 = "World"; // Problem 1a:   Display the values stored in the previous //               variables in the...

  • Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into...

    Assembly Language////Write a program that read in 10 integers from the user. Save the numbers into an array; reverse the array and display the reversed array. .data arrayInt DWORD 10 DUP(?) Your program consists of 4 procedures: 1. main procedure: call procedures getInput, reverseArray, displayArray 2. getInput procedure: prompt user to enter 10 integer numbers, save the numbers into the memory for the arrayInt 3. reverseArray: reverse arrayInt 4. displayArray: display the reversed array

  • MIPS CODE required to write an assembly program to find the maximum of an array of integers by...

    required to write an assembly program to find the maximum of anarray of integers by doing the following:1. Prompt user to input array size n (n <= 10)2. Prompt user to input element values of array A one by one3. Display the result on the console.This program must at least include one function. The main program will read the valuesof the array (as user inputs the element values) and stores them in the memory (datasegments section) and at the end...

  • Question: WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT ... WRITE A PROGRAM IN LC-3...

    Question: WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT ... WRITE A PROGRAM IN LC-3 ASSEMBLY LANGUAGE. DO NOT USE PYTHON, JAVA, C or C++ or OTHERS. Your task is to write a program that counts the number of 1 bits of the value stored at location given by Datal. Your program should print the count (in hexadecimal, as it is easier) along with an appropriate heading. Test your program with the following values stored in Datal: a xFFFE...

  • Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user...

    Use Assembly (Masm and Irvine32 library) to write a complete program that: 1. Asks the user to enter 2 numbers. Assume that the user enters unsigned 32-bit integers only. 2. Displays the product of the two numbers. Assume that the result will never be larger than 32 bits. 3. This process will continue till the user enters 0 for both inputs. You can’t use mul instruction in your program: You need to use shifting and addition only. Your program must...

  • In C language using printf and scanf statements: Write a program to display a histogram based...

    In C language using printf and scanf statements: Write a program to display a histogram based on a number entered by the user. A histogram is a graphical representation of a number (in our case, using the asterisk character). On the same line after displaying the histogram, display the number. The entire program will repeat until the user enters zero or a negative number. Before the program ends, display "Bye...". The program will ask the user to enter a non-zero...

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