Question: I am stuck here on this code and I keep getting an issue from the compiler. Can you help me figure out how to get
I am stuck here on this code and I keep getting an issue from the compiler. Can you help me figure out how to get this asm inline code to work. Thank you
#include
using namespace std;
short drinkCost, NoDrinks, foodSize, noSand, totalBill;
char drinkType;
short two=2, one=1, three=3, six=6, four=4;
void askNoDrinks()
{
cout<< "How many drinks? "<< endl;
cin>> NoDrinks;
}
void askDrinkType()
{
cout<< "What kind of drink? "<< endl;
cin>>drinkType;
}
void showTotalBill()
{
cout<< "Your total bill is "<< totalBill<< endl;
}
int main()
{
// display a header
cout << "------------MENU------------" << endl;
cout << "Drinks: "< cout << "Sodas(1) ......$2 " << endl; cout<< "Water(2) ..... $1 "<< endl; cout << "Beer(3)....$3 "<< endl; cout<< "Sandiches: "<< endl; cout<<"6 inches(4)....$4 "<< endl; cout<< "12 inches(5)....$6"<< endl; cout<< "How many Drinks and what kind?: "<< endl; asm { call askNoDrinks; call askDrinkType; cmp drinkType, 's'; je sodaLabel; cmp drinkType, 'S'; jne testWater; sodaLabel: //Calculate drink price for sodas mov ax, NoDrinks; imul two; mov drinkCost,ax; jmp foodTotal; testWater: cmp drinkType, 'w'; je WaterLabel; cmp drinkType, 'W'; jne testbeer; WaterLabel: //Calculate the cost of water mov ax, NoDrinks; imul one; mov drinkCost, ax; jmp foodTotal; testbeer: mov ax, NoDrinks; imul three; mov drinkCost, ax; foodTotal: cmp foodSize,6; je chargesixin; charge12in: //Compute cost when user orderes 12 in sub mov ax, noSand; imul six; mov foodTotal, ax; jmp totalBill; chargesixin: mov ax, noSand; imul four; mov foodTotal, ax; totalCost: //Drink cost plus food cost for total cost; mov ax, drinkCost; add ax, foodTotal; mov totalBill, ax; } cout<< "Your total bill is "<< totalBill<< endl; return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
