Question

In: Computer Science

Write a MASM program that uses a loop to multiply 2 numbers. Use the equal sign...

Write a MASM program that uses a loop to multiply 2 numbers. Use the equal sign directive to define the two numbers. Save the product in the EAX register.

Hint

4 x 5 = 4 + 4 +4 + 4 + 4 = 5 + 5 + 5 + 5

Language (Assembly)

ASAP

Solutions

Expert Solution

Solution:-

The above task can be achieved using the load registers (LDR) and a loop to work around with the numbers.

The numbers can be represented as: (a) 4 = 00 00 00 04

(b) 5 = 00 00 00 05

Area prog, Code, readonly
Entry
Main                           ;Main block of the code
   LDR R1, VALUE1
   LDR R2, VALUE2
   MOV R0, #0x00000000

LOOP                           ;Loop to add the number '4' 5 times
   ADD R0, R0, R1               ;Logic is R0 = R0 + R1
   SUBS R2, R2, #1               ;This is used to decrement the loop value by 1
   BNE LOOP                   ;This command will check the R2 till it gets R2 = 0
  
   MOV EAX, R0                   ;Move the value in R0 to EAX
  
Area prog, data, readonly       ;Initializing the data in here
VALUE1 = 00000004               ;VALUE1 is initialize as 4
VALUE2 = 00000005               ;VALUE2 is initialize as 5
END                               ;End the program

Note:- If you have any doubt on any of the command comment it below i will definitely help understand it.


Related Solutions

Write a program in python language, which accepts 2 numbers and a + sign (for addition)...
Write a program in python language, which accepts 2 numbers and a + sign (for addition) A sign - (for subtraction) A sign * (for multiplication), / (for division) Then calculate and to display the result of the operation he chose with the two numbers. Displaying the appropriate message
Write an assembly program (Data and Code) that uses loop to read 10 numbers and output...
Write an assembly program (Data and Code) that uses loop to read 10 numbers and output the largest of those numbers, you can assume any length for those numbers. 80x86 assembly language
In Assembly Language MASM Write a program that generates 10 random numbers (0~99). Save the numbers...
In Assembly Language MASM Write a program that generates 10 random numbers (0~99). Save the numbers into arrayInt and calculate the sum. .data arrayInt Byte 10 DUP(?) Displays the array and the sum as follows: The random numbers are: xx xx xx xx xx xx …. The sum is   xxxx
Write a Python program to add, multiply and divide any two numbers.
Write a Python program to add, multiply and divide any two numbers.
Write a program which uses a while loop to add the following numbers: 5, 52, 31,...
Write a program which uses a while loop to add the following numbers: 5, 52, 31, and 65 and output the sum of those numbers. Your output should look like this: The sum of (list the numbers) is ( give the result). //In C language Upload a screen shot of your program and the results of running the program.
Write an assembly program In MASM assembler to calculate the sum of odd numbers only stored...
Write an assembly program In MASM assembler to calculate the sum of odd numbers only stored in a 16-bit integers array. The size of the array is provided in a separate variable. Use the following design: Sum = 0 FOR i = 0 TO SizeOfArray - 1     IF Arr[i] % 2 = 1           Sum = Sum + Arr[i]     END IF END FOR
1.write a small program using a loop to add a series of numbers 2.write a function...
1.write a small program using a loop to add a series of numbers 2.write a function called "main" that performs several given steps. Be sure to call the main() function so that its code executes In python and doesn't have to be long. just long enough to do what it says. Thank you.
Using visual studio in MASM x86, Write a program to add the following word size numbers:...
Using visual studio in MASM x86, Write a program to add the following word size numbers: 15F2, 9E89, 8342, 99FF, 7130 using adc instruction and a loop. The result must be in DX, AX. Show the result in debug window.
Write a program using c++. Write a program that uses a loop to keep asking the...
Write a program using c++. Write a program that uses a loop to keep asking the user for a sentence, and for each sentence tells the user if it is a palindrome or not. The program should keep looping until the user types in END. After that, the program should display a count of how many sentences were typed in and how many palindromes were found. It should then quit. Your program must have (and use) at least four VALUE...
Write a program that uses a for loop to print One of the months of the...
Write a program that uses a for loop to print One of the months of the year is January One of the months of the year is February ...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT