Question:
Write a Motorola program that calculates X (a 16bit number stored in memory) raised to the Y (a 8bit number stored in memory) power. The program should have a whilerepetition control structure.
Answer:
Step 1: Write C Program to operation power(x,y) create file find_pow_of_x_y.c and below is the code
===============================
$ cat find_pow_of_x_y.c
#include <stdio.h>
#include <math.h>
int main()
{
double base, power, result;
printf("Enter the base number: ");
scanf("%lf", &base);
printf("Enter the power raised: ");
scanf("%lf",&power);
result = pow(base,power);
printf("%.1lf^%.1lf = %.2lf\n", base, power, result);
return 0;
}
===============================
Step 2: Convert the C program into ASM68K Code using linux command
$ gcc -O2 -S -c find_pow_of_x_y.c
Step 3: Above Linux Command will generate .s file-name find_pow_of_x_y.s and below is the ASM68K language code
===============================
$ cat find_pow_of_x_y.s
.file "find_pow_of_x_y.c"
.section .rodata.str1.1,"aMS",@progbits,1
.LC0:
.string "Enter the base number: "
.LC1:
.string "%lf"
.LC2:
.string "Enter the power raised: "
.LC3:
.string "%.1lf^%.1lf = %.2lf\n"
.text
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB14:
.cfi_startproc
subq $24, %rsp
.cfi_def_cfa_offset 32
movl $.LC0, %edi
xorl %eax, %eax
call printf
leaq 8(%rsp), %rsi
movl $.LC1, %edi
xorl %eax, %eax
call __isoc99_scanf
movl $.LC2, %edi
xorl %eax, %eax
call printf
movq %rsp, %rsi
movl $.LC1, %edi
xorl %eax, %eax
call __isoc99_scanf
movsd (%rsp), %xmm1
movsd 8(%rsp), %xmm0
call pow
movsd (%rsp), %xmm1
movl $.LC3, %edi
movapd %xmm0, %xmm2
movl $3, %eax
movsd 8(%rsp), %xmm0
call printf
xorl %eax, %eax
addq $24, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE14:
.size main, .-main
.ident "GCC: (GNU) 4.4.7 20120313 (Red Hat 4.4.7-3)"
.section .note.GNU-stack,"",@progbits
===============================
Compile and Execute the above ASM68K language in MC68000 Machine operating system and validate,verify the output.
Motorola MC68000 Please Problem 3) Write a Motorola program that calculates X (a 16bit number stored in memory) raised to the Y (a 8bit number stored in memory) power. The prograri should have a whil...
a. write a program that calculates the sum of two numbers x and y and then the program should call the function by address and prints the sum b. write a program that stores 10 integers provided at run time in an array. the program should prompt the user for a random integer exit in the array, the value must be replaced by a-1
Using #include <stdio.h> 6) Write a program that computes X^Y (X to the power of Y). You are required to use a while loop to solve the problem. Do not use the pow function from the “math.h” library. You may hard code the variables X and Y in the beginning of your program. Hint: 5^4 =5*5*5*5
help me
Problem: Write a simple C program that calculates the corresponding y-coordinate for any x-coordinate onaline defined by two points. These points areinputspecifiedas pairsofxandycoordinates in the two-dimensional Cartesian coordinate system. Youneed to determine the slope ofthe line and they-intercept for the line plotted by these two points and store this data in memory. The programmustpromptthe userforthe coordinates of the first point X1 and then Y1, and then prompt the user for the second point, X2 and then Y2. After...
3. (a) Write a MatLab program that calculates for the function F(x, y) = ln(x + Va,2-y2) The program should use pretty) to display both the original function and the differentiated result, and also use fprintf() to print a label such as "F(x,y) -" and "dF/dxdy - " in front of both the function and the derivative. Then have your program also print out the derivative again after it uses simplify() on the result (b) Find the Taylor expansion of...
3. Write a Matlab program that returns the n roots of a complex number. The function should have z and n as inputs a nd returns y as theoutput
3. Write a Matlab program that returns the n roots of a complex number. The function should have z and n as inputs a nd returns y as theoutput
USING PYTHON PLEASE
Write a program that calculates the factorial value of a number entered by the user. Remember that x! =x* (x-1)* (x-2)*... *3+ 2* 1. Your program should check the value input by the user to ensure it is valid (i.e., that it is a number > =1). To do this, consider looking at the is digit() function available in Python. If the user enters an incorrect input, your program should continue to ask them to enter a...
Create a CPP file for a C++ Program. Write exactly these functions, power(x,y) function and a print(text, number) function and the main() function. The power(x,y) function returns an integer result that is calculated by raising a number x (integer) to a power y (integer). The second argument y (exponent) of the function can not exceed 100. If the second argument exceeds 100, the function should return -1. Your power(x,y) function must be able to take either 1 or 2 integer...
a.) Write a C++ program that calculates the value of the series
sin x and cos x, sin 2x or cos 2x where the user enters the value
of x (in degrees) and n the number of terms in the series. For
example, if n= 5, the program should calculate the sum of 5 terms
in the series for a given values of x. The program should use
switch statements to determine the choice sin x AND cos x, sin...
Write a C++ -program that will implement Worst-fit, memory management algorithms. Your program must do the following: 1. Input the memory size and the number and sizes of all the partitions (limit the max number of the partitions to 5); 2. Input the job list that includes: - Job's name; - Job's size. 3. For each job you should create in your program a data structure that will include the job status (Run/Wait) and the partition number (if the job...
Please solved IAR workbench in C language I have a limited time
less than 10 hours
In this assignment, you are going to write a program that will calculate x*x by using shift operations. Details are as follows: x can be any number between 1 - 100. The result x*x will be stored in 0x20000000. You may first find the binary representation of x. In the binary representation, if you see a 1 in the nth bit, you will shift...