QuestionQuestion

Assignment:
You will write an assembly program to act as a limited interactive scientific calculator that operates on floating point values. No C++ libraries other than iostream should be used. Using whichever IDE you like and whichever assembly syntax you prefer, write some inline assembly to complete the following C++ program:
int main () {
char operation;
float param, result;
std: : cout << "Which operation would you like to perform?\n";
std: : cout << " (s) sine, (c) cosine, (t) tangent\n";
std: : cout << " (a) area of a circle, (v) volume of a sphere\n";
std: : cout << " (g) log_2, (n) 1n, (1) log_10\nn;
std: : cin >> operation;
// Still in C++: Prompt for one operand
// The area & volume computations should prompt for the radius
11 Your C++ code should only be doing input & output--the --
// assembly should be doing the actual calculations
asm
(
Your assembly code goes here
Set up registers to pass in variable values
};
// Print out the results in C++ here
return 0
}

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>

int main()
{
char operation;
float param, result;
std::cout << "Which operation would you like to perform?\n";
std::cout << "(s) sine, (c) cosine, (t) tangent\n";
std::cout << "(a) area of a circle, (v) volume of a sphere\n";
std::cout << "(g) log_2, (n) ln, (l) log_10\n";

std::cin >> operation;

// Still in C++: Prompt for one operand
// The area & volume computations should prompt for the radius
// Your C++ code should only be doing input & output--the
// assembly should be doing the actual calculations
if ((operation == 'a') || (operation == 'v'))
{
std::cout << "Enter the radius:\n";
}
else
{
std::cout << "Enter the operand:\n";
}

std::cin >> param;

__asm
{
fld param // load param into FPU stack
mov eax, 1 // load 1 into eax register
mul operation // multiply it with operation to get operation in eax

// Calculate sine
cmp eax, 0x73 // check if operation is 's'
jne checkCosine // if not continue checking
fsin...
$25.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Assembly Language Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats