I need MIPS code for this program
Translate the following C++ program to MIPS assembly program (Please explain each instruction of your code by a comment and submit a .asm file)
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
const int ADULT_CHOICE= 1,
CHILD_CHOICE= 2,
SENIOR_CHOICE= 3,
QUIT_CHOICE= 4,
ADULT = 250,
CHILD = 200,
SENIOR = 350;
int choice, months;
int charges = 0;
do
{
cout <<"\n\t\tHealth Club Membership Menu\n\n"
<<"1. Standard Adult Membership\n"
<<"2. Child Membership\n"
<<"3. Senior Citizen Membership\n"
<<"4. Quit the program\n\n"
<< "Enter your choice:";
cin >> choice;
while (choice < ADULT_CHOICE || choice > QUIT_CHOICE)
{
cout << "please enter a valid menu choice:";
cin >> choice; }
if (choice != QUIT_CHOICE)
cout <<" For how many months?";
cin >> months;
switch (choice)
{
case ADULT_CHOICE:
for (int i=0; i<months; i++)
charges = charges + ADULT;
break;
case CHILD_CHOICE:
for (int i=0; i<months;i++)
charges = charges + CHILD;
break;
case SENIOR_CHOICE:
for (int i=0; i<months; i++)
charges = charges + SENIOR ;
}
cout << " the total charges are $"
<< charges << endl;
}
while (choice != QUIT_CHOICE);
return 0;
}
.LC0:
.string "\n\t\tHealth 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 a valid menu choice:"
.LC7:
.string " For how many months?"
.LC8:
.string " the total charges are $"
main:
push rbp
mov rbp, rsp
sub rsp, 64
mov DWORD PTR [rbp-20], 1
mov DWORD PTR [rbp-24], 2
mov DWORD PTR [rbp-28], 3
mov DWORD PTR [rbp-32], 4
mov DWORD PTR [rbp-36], 250
mov DWORD PTR [rbp-40], 200
mov DWORD PTR [rbp-44], 350
mov DWORD PTR [rbp-4], 0
.L16:
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, OFFSET FLAT:.LC1
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, OFFSET FLAT:.LC2
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, OFFSET FLAT:.LC3
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, OFFSET FLAT:.LC4
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, OFFSET FLAT:.LC5
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-48]
mov rsi, rax
mov edi, OFFSET FLAT:_ZSt3cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
.L4:
mov eax, DWORD PTR [rbp-48]
test eax, eax
jle .L2
mov eax, DWORD PTR [rbp-48]
cmp eax, 4
jle .L3
.L2:
mov esi, OFFSET FLAT:.LC6
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-48]
mov rsi, rax
mov edi, OFFSET FLAT:_ZSt3cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
jmp .L4
.L3:
mov eax, DWORD PTR [rbp-48]
cmp eax, 4
je .L5
mov esi, OFFSET FLAT:.LC7
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
.L5:
lea rax, [rbp-52]
mov rsi, rax
mov edi, OFFSET FLAT:_ZSt3cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
mov eax, DWORD PTR [rbp-48]
cmp eax, 3
je .L6
cmp eax, 3
jg .L7
cmp eax, 1
je .L8
cmp eax, 2
je .L9
jmp .L7
.L8:
mov DWORD PTR [rbp-8], 0
.L11:
mov eax, DWORD PTR [rbp-52]
cmp DWORD PTR [rbp-8], eax
jge .L18
add DWORD PTR [rbp-4], 250
add DWORD PTR [rbp-8], 1
jmp .L11
.L9:
mov DWORD PTR [rbp-12], 0
.L13:
mov eax, DWORD PTR [rbp-52]
cmp DWORD PTR [rbp-12], eax
jge .L19
add DWORD PTR [rbp-4], 200
add DWORD PTR [rbp-12], 1
jmp .L13
.L6:
mov DWORD PTR [rbp-16], 0
.L14:
mov eax, DWORD PTR [rbp-52]
cmp DWORD PTR [rbp-16], eax
jge .L7
add DWORD PTR [rbp-4], 350
add DWORD PTR [rbp-16], 1
jmp .L14
.L18:
nop
jmp .L7
.L19:
nop
.L7:
mov esi, OFFSET FLAT:.LC8
mov edi, OFFSET FLAT:_ZSt4cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov rdx, rax
mov eax, DWORD PTR [rbp-4]
mov esi, eax
mov rdi, rdx
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
mov esi, OFFSET FLAT:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))
mov eax, DWORD PTR [rbp-48]
cmp eax, 4
je .L15
jmp .L16
.L15:
mov eax, 0
leave
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L22
cmp DWORD PTR [rbp-8], 65535
jne .L22
mov edi, OFFSET FLAT:_ZStL8__ioinit
call std::ios_base::Init::Init() [complete object constructor]
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:_ZStL8__ioinit
mov edi, OFFSET FLAT:_ZNSt8ios_base4InitD1Ev
call __cxa_atexit
.L22:
nop
leave
ret
_GLOBAL__sub_I_main:
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret
I need MIPS code for this program Translate the following C++ program to MIPS assembly program...
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...
// 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...
C++ Check Book Program I need to have a checkbook program that uses the following items. My code that I have appears below. 1) Math operations using built-in math functions 2) Class type in a separate .h file with member functions (accessor functions, get, set, show, display find, etc). There needs to be an overloaded function base/derived classes or a template. 3) Binary File #include <iostream> using namespace std; int main() { double checking,savings; cout<<"Enter the initial checking...
IN C++ Help to fix code Library management program. Error is when i type a letter into options menu the code breaks. after your edits, the code should still run as normal. CODE: #include<iostream> using namespace std; //structure to store library data class BookDetails{ public: struct library { int code; char title[20]; int status; }; library book_details[100]; }; //structure to store user data class UserDetails:public BookDetails{ public: struct users { int id; char name[20]; int booksNumber; }; users user_details[100]; };...
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...
IN C++ add Inheritance, Class and Pointers to program This is a library management program, users can borrow books and return books. Just incorporate the use of Inheritance, Class and Pointers into this program. The program should work the same after your edits. #include using namespace std; //structure to store library data struct library { int code; char title[20]; int status; }; //structure to store user data struct users { int id; char name[20]; int booksNumber; }; int main() {...
I am working on this switch program everything seems to be ok but the compiler is giving me an error on the final closing brace and wanted to know where I am making an error #include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { int choice; char repeat; double MidTerm = 0; double FinalExam = 0; double Quiz1 = 0; double Quiz2 = 0; double MidTermGrade = 1, FinalExamGrade = 2, Quiz1Grade = 3, Quiz2Grade = 4,...
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...
Code is in C++: Im wondering how i can make the program continue to ask the user to enter Y/N with the if statment. Is it possible with an If statment? #include <iostream> using namespace std; int main() { float usDollars,cYuan; float *Dollars; char choice; Dollars = &usDollars; while(usDollars >= 0){ cout <<"Enter the amount in U.S Dollars: "; cin >> usDollars; cout << usDollars<< " U.S Dollar in Chinese Yuan is :"<<*Dollars*7.09<<endl; if (choice == 'y' || choice ==...