Question

Problem 3) Write a Motorola program that calculates X (a 16bit number stored in memory) raised to the Y (a 8bit number stored

Motorola MC68000 Please

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

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.

Add a comment
Know the answer?
Add Answer to:
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...
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
  • Using #include <stdio.h> 6) Write a program that computes X^Y (X to the power of Y)....

    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...

    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 prog...

    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 ...

    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...

    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...

  • a.) Write a C++ program that calculates the value of the series sin x and cos...

    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...

  • Create a CPP file for a C++ Program. Write exactly these functions, power(x,y) function and 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...

  • Write a C++ -program that will implement Worst-fit, memory management algorithms. Your program must do the...

    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...

  • In this assignment, you are going to write a program that will calculate x*x by using shift opera...

    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...

  • Can someone please help me with this problem? We are using CodeWarrior to write this program...

    Can someone please help me with this problem? We are using CodeWarrior to write this program in assembly language. The array sample contains eight 8-bit signed binary numbers (integers) as shown below. Write a program which stores the negative numbers in the array nelements, computes the sum of the positive numbens to be stored in the variable psum and stores the number of the positive numbers in the variable pnumber. Note that a zero is ther positive nor negative. Your...

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