Assembly Language:
For this program you will call a procedure that finds the minimum and maximum elements of an
array, and the last positions in the array where the minimum and maximum element occurs.
The output of the program is:
The position in array of last occurrence of minimum element is: 4
The minimum element in the array is: 5
The position in array of last occurrence of maximum element is: 6
The maximum element in the array is: 90
Use an array named Array to contain the elements (as DWORDS):
5, 46, 90, 50, 5, 6, 90, 8, 20
All variables in main are DWORDS.
The name of the procedure is MinandMax, and its equivalent call in C++ would be:
MinandMax(int &max, int &maxposn, int &min, int &maxposn,int& Array, int Arrsze);
All arguments must be passed on the stack. You must use the C++ calling conventions for
ordering of arguments on the stack. You must use the conventions for caller and callee saved
registers on slide 26 of SS7 assuming that all registers EAX, EBX, ECX, EDX, EDI, ESI may be
used for some purpose in main other than support for calling MinandMax.
Registers EAX, EBX, ECX, EDX, EDI, ESI are used for some purpose in MinandMax.
In MinandMax, there is only one loop. Thus, you must use conditionals within the loop to
implement finding the maximum element, minimum element, position of the maximum element
and position of the minimum element.
The ebp register must be saved within MinandMax.
The caller is responsible for cleaning up the stack.
The last line in the program should be END main
Solution
Answer:
.zero 1
.LC0:
.string \"\ \ \\t ENTER THE SIZE OF THE ARRAY\\342\\200\\246:\"
.LC1:
.string \"\ \ \\t ENTER THE ELEMENTS OF THE ARRAY\\342\\200\\246: \"
.LC2:
.string \"\ \ \\t THE LARGEST ELEMENT IS\\342\\200\\246: %d\"
.LC3:
.string \"\ \ \\t AND ITS POSSITION IS\\342\\200\\246: %d\"
.LC4:
.string \"\ \ \\tTHE SMALlEST ELEMENT IS\\342\\200\\246: %d\"
main:
push rbp
mov rbp, rsp
sub rsp, 144
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
lea rax, [rbp-132]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream >::operator>>(int&)
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream >& std::operator<< >(std::basic_ostream >&, char const*)
mov DWORD PTR [rbp-20], 1
.L3:
mov eax, DWORD PTR [rbp-132]
cmp DWORD PTR [rbp-20], eax
jg .L2
lea rax, [rbp-128]
mov edx, DWORD PTR [rbp-20]
movsx rdx, edx
sal rdx, 2
add rax, rdx
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream >::operator>>(int&)
add DWORD PTR [rbp-20], 1
jmp .L3
.L2:
mov eax, DWORD PTR [rbp-124]
mov DWORD PTR [rbp-4], eax
mov DWORD PTR [rbp-12], 1
mov DWORD PTR [rbp-20], 1
.L6:
mov eax, DWORD PTR [rbp-132]
cmp DWORD PTR [rbp-20], eax
jg .L4
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
cmp eax, DWORD PTR [rbp-4]
jle .L5
mov eax, DWORD PTR [rbp-20]
cdqe
mov eax, DWORD PTR [rbp-128+rax*4]
mov DWORD PTR [rbp-4], ea.
C# Programming. Using methods to call results to display. The code i.pdf
1. C# Programming. Using methods to call results to display. The code is basically in the right form
I think, but I keep getting errors. Ive tried several different ways to change the code and this is
the closest Ive found with the fewest errors. It is not supposed to use any methods more
advanced than this. No if else or other types of code. If you show me and breifly expalin what Im
doing wrong It would be appreciated.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter3Program2
{
/*
* Program: Weekly Payroll App
* Programmer: Laura Sturgill
* Purpose: To calculate and print out the take-home pay for a commissioned sales employee.
* */
class Program
{
static void Main(string[] args)
{
CreateInput();
}
static void CreateInput()
{
string name;
double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct,
takeHomePay;
name = GetName();
sales = GetSales();
commission = GetCommission();
grossPay = GetGrossPay();
fedTax = GetFedTax();
socSecTax = GetSocSecTax();
retirement = GetRetirment();
2. totalDeduct = GetTotalDeduct();
takeHomePay = GetTakeHomePay();
DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement,
totalDeduct, takeHomePay);
}
static string GetName()
{
Console.WriteLine("You will be asked to enter the name of an employee and his weekly
sales. Calculations will be performed to determine his deductions and take home pay.");
Console.WriteLine("Please enter an employee name:");
string name = Console.ReadLine();
return name;
}
static double GetSales()
{
Console.WriteLine("Please enter an employee's weekly sales:");
double sales = Double.Parse(Console.ReadLine());
return sales;
}
static double GetCommission(double sales)
{
const double COM_RATE = .07;
double commission = sales * COM_RATE;
return commission;
}
static double GetGrossPay(double commission)
{
double grossPay = commission;
return grossPay;
}
static double GetGrossPay(double commission)
{
const double FED_TAX = .18;
double grossPay = commission * FED_TAX;
return grossPay;
}
4. Console.WriteLine("t Total Deductions:", totalDeduct);
Console.WriteLine("t Take Home Pay:", takeHomePay);
}
}
}
Solution
Here is the code for you:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Chapter3Program2
{
/*
* Program: Weekly Payroll App
* Programmer: Laura Sturgill
* Purpose: To calculate and print out the take-home pay for a commissioned sales employee.
* */
class Program
{
static void Main(string[] args)
{
CreateInput();
}
static void CreateInput()
{
string name;
double sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct, takeHomePay;
name = GetName();
sales = GetSales();
commission = GetCommission(sales);
5. grossPay = GetGrossPay(commission);
fedTax = GetFedTax(grossPay);
socSecTax = GetSocSecTax(grossPay);
retirement = GetRetirement(socSecTax);
totalDeduct = GetTotalDeduct(grossPay, fedTax, socSecTax, retirement);
takeHomePay = GetTakeHomePay(grossPay, totalDeduct);
//Console.WriteLine(sales);
DisplayResults(name, sales, commission, grossPay, fedTax, socSecTax, retirement, totalDeduct,
takeHomePay);
}
static string GetName()
{
Console.WriteLine("You will be asked to enter the name of an employee and his weekly sales.
Calculations will be performed to determine his deductions and take home pay.");
Console.Write("Please enter an employee name: ");
string name = Console.ReadLine();
return name;
}
static double GetSales()
{
Console.Write("Please enter an employee's weekly sales: ");
double sales = Double.Parse(Console.ReadLine());
return sales;
}
static double GetCommission(double sales)
{
const double COM_RATE = .07;
double commission = sales * COM_RATE;
return commission;
}
static double GetGrossPay(double commission)
{
double grossPay = commission;
return grossPay;
}
static double GetFedTax(double grossPay)