Question

In: Computer Science

Develop an x86 assembly language program that properly executes an "x to the y power" function:...

Develop an x86 assembly language program that properly executes an "x to the y power" function:

int power(int x, int y)
Compute the integer value that is x to the y power
Do not concern yourself with the possibility of overflow
You may only use only a loop structure to compute the value
Remember that the return value must be placed in the EAX register
Make sure that any registers (not EAX) used by this function are placed back to their initial states prior to exiting

Allow an end user to test this function in the following manner:

Prompt the user to enter an integer value ("Enter a value for x: ")
Allow the user to input their value
Prompt the user to enter an integer value ("Enter a value for y: ")
Allow the user to input their value
Pass the user input value to the power() function Let the function
do its work and return the correct value
Print out the result ("x to the y power is: ")

Solutions

Expert Solution

  1. Hello, Student I hope you are doing great in lockdown.

Here is your x86 assembly language program that properly executes an "x to the y power" function:

int power(int x, int y)

still if you have any doubt then feel free to ask in comment section, I am always happy to help you.

Please upvote.

I have included some comments, so you can understand what is going in code.

.MODEL SMALL

.DATA

greet   db 13,10, "Simple Calculator: x to the y power. $"
msg1    db 13,10, 0AH,0DH,"Enter a value for x:: $"
m       db 3,4 dup(?)
msg2    db 10,13, 0AH,0DH,"Enter a value for y:: $"
n       db 3,4 dup(?)
total   db 10,13, "x to the y power is: $"


.CODE

START:

mov ax, seg greet
mov ds, ax
mov dx, offset greet
mov ah, 09h     ;Display message
int 21h 

mov ax, seg msg1
mov ds, ax
mov dx, offset msg1
mov ah, 09h
int 21h         ;Print a message

mov ah, 0ah
mov dx, offset m
int 21h         ;Get 'x' value


n_POWER:

mov ax, seg msg2
mov ds, ax
mov dx, offset msg2
mov ah, 09h
int 21h         ;Print a message

mov ah, 0ah
mov dx, offset n    ;Get 'y' value
int 21h

mov ax, m
mov n, ax
mul ax, n
mov total, n

finish:
mov ah, 09h ;Display message
int 21h

mov ax,4c00h    ;Return control to DOS
int 21h         
end start

Please do not forget to hit that like or thumbs-up button, it really motivates me<3

Thank you!!

Have a nice day:)


Related Solutions

Develop an x86 assembly language program that properly executes an "is even" function: bool isEven(int value)...
Develop an x86 assembly language program that properly executes an "is even" function: bool isEven(int value) If the value passed in is even, return 1 If the value passed in is odd, return 0 Remember that the return value must be placed in the EAX register Make sure that any registers (not EAX) used by this function are placed back to their initial states prior to exiting Allow an end user to test this function in the following manner: Prompt...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please...
Hi this is Assembly Language MASM x86 program. Please write it in the language and please explain it with comments thank you Please answer it I really need help this question was refunded before so please answer. Thank you so much also these are two separate programs thank you. 1) Write a procedure to read in decimal or hex number (byte-sized) Then write a procedure using shifts and ANDS to convert the string to a binary number (if is backward,...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the...
Convert this C++ program exactly as you see it into x86 assembly language: // Use the Irvine library for the print function #include <iostream> // The string that needs to be printed char word[] = "Golf\0"; // Pointer to a specific character in the string char * character = word; //NOTE: This main() function is not portable outside of Visual Studio void main() { // Set up a LOOP - See the while loop's conditional expression below int ecx =...
in assembly language x86 Masm, Write a program that calculate the first seven values of the...
in assembly language x86 Masm, Write a program that calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1) + Fib(n-2). You NEED to calculate each value in the series "using registers and the ADD operation" You can also use variables, Have your program print out "The first seven numbers is" Use WriteInt for the printing, Place each value in the EAX...
Assembly Language for x86 processors You are to write a program which should first ask for...
Assembly Language for x86 processors You are to write a program which should first ask for 4 random numbers from 0-20 (user will inpute these numbers in no preset order). Input these 5 numbers in variables called num1, num2, num3, num4, and num5. When done, your program should sort these numbers (you will use lots of conditions to check order). num1 should contain smallest number while num5 should contain the biggest. display the contents of num1 through num5 on the...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A palindrome is a word, number, phrase or any other sequence which reads the same backward as forward e.g. madam, racecar. Sample Execution: Please enter a String: redivider The string is a palindrome Another Sample Execution: Please enter a String: abracadabra The string is not a palindrome
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings...
Please write in x86 Assembly language on Visual Studio Write a program to compare two strings in locations str1 and str2. Initialize str1 to Computer and initialize str2 to Compater. Assume Str1 holds the correct spelling and str2 may have an incorrect spelling. Use string instructions to check if str2 is correct and if not correct the mistake in str2.
Write an x86 assembly language program that performs equivalently to the C++ source code file shown...
Write an x86 assembly language program that performs equivalently to the C++ source code file shown below.Please note that commented out behavior must be implemented in x86 assembly language. There is no standard, portable way to perform some of these actions in C++. #include void main() { // Use registers for these in your x86 assembly language program // Only use the .data segment for string (character array) variables int eax; int esi; int ecx; int edi; // Loop the...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one...
Please write in x86 Assembly language on Visual Studio. IRVINE32 Write a program to copy one array of size 24 to another array of size 24 using string instructions. Write 3 versions of this code. One code must copy byte at a time. One code must copy word at a time and one code must copy double word at a time. Cut and paste the array in memory to show your code is working.
Please use assembly language x86 Visual Studio Write a program to add the following word size...
Please use assembly language x86 Visual Studio 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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT