Question

Plz give me correct code and screen shots for this question by using SASM !!!!!!!! Implement...

Plz give me correct code and screen shots for this question by using SASM !!!!!!!!

Implement the following working C++ program in assembler. Submit assembler code and screen shot.

#include <iostream>
#include <iomanip>
using namespace std;

// This menu-driven Health Club membership program carries out the
// appropriate actions based on the menu choice entered. A do-while loop
// allows the program to repeat until the user selects menu choice 4.


int main()
{
// Constants for membership rates
const int ADULT_RATE = 40;
const int CHILD_RATE = 20;
const int SENIOR_RATE = 30;

int choice; // Menu choice
int months; // Number of months
int charges; // Monthly charges

do
{ // Display the menu and get the user's choice
cout << "\n Health Club Membership Menu\n\n";
cout << "1. Standard Adult Membership\n";
cout << "2. Child Membership\n";
cout << "3. Senior Citizen Membership\n";
cout << "4. Quit the Program\n\n";
cout << "Enter your choice: ";
cin >> choice;

// Validate the menu selection
while ((choice < 1) || (choice > 4))
{
cout << "Please enter 1, 2, 3, or 4: ";
cin >> choice;
}
// Process the user's choice
if (choice != 4)
{
cout << "For how many months? ";
cin >> months;

// Compute charges based on user input
switch (choice)
{
case 1: charges = months * ADULT_RATE;
break;
case 2: charges = months * CHILD_RATE;
break;
case 3: charges = months * SENIOR_RATE;
}
// Display the monthly charges

cout << "The total charges are $" << charges << endl;
}
} while (choice != 4); // Loop again if the user did not
// select choice 4 to quit

return 0;
}

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

.LC0:

.string "\n Health Club Membership Menu\n\n"

.LC1:

.string "1. Standard Adult Membership\n"

.LC2:

.string "2. Child Membership\n"

.LC3:

.string "3. Senior Citizen Membership\n"

.LC4:

.string "4. Quit the Program\n\n"

.LC5:

.string "Enter your choice: "

.LC6:

.string "Please enter 1, 2, 3, or 4: "

.LC7:

.string "For how many months? "

.LC8:

.string "The total charges are $"

main:

pushq %rbp

movq %rsp, %rbp

subq $32, %rsp

movl $40, -8(%rbp)

movl $20, -12(%rbp)

movl $30, -16(%rbp)

.L10:

movl $.LC0, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movl $.LC1, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movl $.LC2, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movl $.LC3, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movl $.LC4, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movl $.LC5, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

leaq -20(%rbp), %rax

movq %rax, %rsi

movl $_ZSt3cin, %edi

call _ZNSirsERi

.L4:

movl -20(%rbp), %eax

testl %eax, %eax

jle .L2

movl -20(%rbp), %eax

cmpl $4, %eax

jle .L3

.L2:

movl $.LC6, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

leaq -20(%rbp), %rax

movq %rax, %rsi

movl $_ZSt3cin, %edi

call _ZNSirsERi

jmp .L4

.L3:

movl -20(%rbp), %eax

cmpl $4, %eax

je .L5

movl $.LC7, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

leaq -24(%rbp), %rax

movq %rax, %rsi

movl $_ZSt3cin, %edi

call _ZNSirsERi

movl -20(%rbp), %eax

cmpl $2, %eax

je .L6

cmpl $3, %eax

je .L7

cmpl $1, %eax

jne .L8

movl -24(%rbp), %edx

movl %edx, %eax

sall $2, %eax

addl %edx, %eax

sall $3, %eax

movl %eax, -4(%rbp)

jmp .L8

.L6:

movl -24(%rbp), %edx

movl %edx, %eax

sall $2, %eax

addl %edx, %eax

sall $2, %eax

movl %eax, -4(%rbp)

jmp .L8

.L7:

movl -24(%rbp), %eax

imull $30, %eax, %eax

movl %eax, -4(%rbp)

.L8:

movl $.LC8, %esi

movl $_ZSt4cout, %edi

call _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc

movq %rax, %rdx

movl -4(%rbp), %eax

movl %eax, %esi

movq %rdx, %rdi

call _ZNSolsEi

movl $_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_, %esi

movq %rax, %rdi

call _ZNSolsEPFRSoS_E

.L5:

movl -20(%rbp), %eax

cmpl $4, %eax

je .L9

jmp .L10

.L9:

movl $0, %eax

leave

ret

_Z41__static_initialization_and_destruction_0ii:

pushq %rbp

movq %rsp, %rbp

subq $16, %rsp

movl %edi, -4(%rbp)

movl %esi, -8(%rbp)

cmpl $1, -4(%rbp)

jne .L14

cmpl $65535, -8(%rbp)

jne .L14

movl $_ZStL8__ioinit, %edi

call _ZNSt8ios_base4InitC1Ev

movl $__dso_handle, %edx

movl $_ZStL8__ioinit, %esi

movl $_ZNSt8ios_base4InitD1Ev, %edi

call __cxa_atexit

.L14:

nop

leave

ret

_GLOBAL__sub_I_main:

pushq %rbp

movq %rsp, %rbp

movl $65535, %esi

movl $1, %edi

call _Z41__static_initialization_and_destruction_0ii

popq %rbp

ret

Add a comment
Know the answer?
Add Answer to:
Plz give me correct code and screen shots for this question by using SASM !!!!!!!! Implement...
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
  • // This program displays a menu and asks the user to make a 2 // selection....

    // This program displays a menu and asks the user to make a 2 // selection. An if/else if statement determines which item 3 // the user has chosen. 4 #include <iostream> 5 #include <iomanip> 6 using namespace std; 7 8 int main() 9 { 10 int choice; // To hold a menu choice 11 int months; // To hold the number of months 12 double charges; // To hold the monthly charges 13 14 // Constants for membership rates...

  • Hi there! I need to fix the errors that this code is giving me and also...

    Hi there! I need to fix the errors that this code is giving me and also I neet to make it look better. thank you! #include <iostream> #include <windows.h> #include <ctime> #include <cstdio> #include <fstream> // file stream #include <string> #include <cstring> using namespace std; const int N=10000; int *freq =new int [N]; int *duration=new int [N]; char const*filename="filename.txt"; int songLength(140); char MENU(); // SHOWS USER CHOICE void execute(const char command); void About(); void Save( int freq[],int duration[],int songLength); void...

  • THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #inclu...

    THIS IS FOR C++ PROGRAMMING USING VISUAL STUDIO THE PROGRAM NEEDS TO BE IN C++ PROGRAMMING #include "pch.h" #include #include using namespace std; // Function prototype void displayMessage(void); void totalFees(void); double calculateFees(int); double calculateFees(int bags) {    return bags * 30.0; } void displayMessage(void) {    cout << "This program calculates the total amount of checked bag fees." << endl; } void totalFees() {    double bags = 0;    cout << "Enter the amount of checked bags you have." << endl;    cout <<...

  • (C++) Hey guys we just went over loops and it got me confused, it has me...

    (C++) Hey guys we just went over loops and it got me confused, it has me scrathcing my head for the past two days. I would appreciate any help you guys have to offer. Few places I have a hard time is get input and determine winner(cummulative part). Write a program that lets the user play the Rock, Paper, Scissors game against the computer. The computer first chooses randomly between rock, paper and scissors, but does not display its choice....

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Can you fix this program and run an output for me. I'm using C++ #include using...

    Can you fix this program and run an output for me. I'm using C++ #include using namespace std; //function to calculate number of unique digit in a number and retun it int countUniqueDigit(int input) {    int uniqueDigitCount = 0;    int storeDigit = 0;    int digit = 0;    while (input > 0) {        digit = 1 << (input % 10);        if (!(storeDigit & digit)) {            storeDigit |= digit;       ...

  • c++, I am having trouble getting my program to compile, any help would be appreciated. #include...

    c++, I am having trouble getting my program to compile, any help would be appreciated. #include <iostream> #include <string> #include <string.h> #include <fstream> #include <stdlib.h> using namespace std; struct record { char artist[50]; char title[50]; char year[50]; }; class CD { //private members declared private: string artist; //asks for string string title; // asks for string int yearReleased; //asks for integer //public members declared public: CD(); CD(string,string,int); void setArtist(string); void setTitle(string); void setYearReleased(int); string getArtist() const; string getTitle() const; int...

  • C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please...

    C++ EXERCISE (DATA STRUCTURES). I just need a code for some functions that are missing. Please help me figure out. Thanks. C++ BST implementation (using a struct) Enter the code below, and then compile and run the program. After the program runs successfully, add the following functions: postorder() This function is similar to the inorder() and preorder() functions, but demonstrates postorder tree traversal. displayParentsWithTwo() This function is similar to the displayParents WithOne() function, but displays nodes having only two children....

  •   Write codes that will produce the screen as shown Firstly, the program prompts user to...

      Write codes that will produce the screen as shown Firstly, the program prompts user to enter his name. Then it will display Hello <user name>. Next it prints out a menu which contains 5 options (1- add two integers, 2- add two strings, 3- compute factorial, 4- reverse a string, 5- quit program). Code all 5 tasks appropriately. When the task is completed (not including quitting program of course), the menu pops up again and asks user to try...

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