How can the third parameter value be referenced

Assignment Help C/C++ Programming
Reference no: EM132598358 , Length: 7 pages

Problem Set

Problem 1. Each of these problems gives "before" conditions and an instruction. Give the indicated "after" state.

 

Before

Instruction executed

After

(a)

EBX:  22334455

ESP:  00 63 FB 60

push ebx

EBX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ESP

 

 

 

 

 

 

 

 

 

 

 

 

 

(b)

ESP:  00 63 FB 60

ret

ESP

 

 

 

 

 

 

 

 

 

 

 

(c)

ESP:  00 63 FB 60

proc3 is a procedure at address 00405B C8

call proc3

ESP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

(d)

EDX:  12AB  FF FD

ESP:  00 63 FB 54

push edx

EDX

 

 

 

 

 

 

 

 

 

 

 

 

 

 

ESP

 

 

 

 

 

 

 

 

 

 

 

(e)

ESP:  00 63 FB 54

ret

ESP

 

 

 

 

 

 

 

 

 

 

 

(f)

ESP:  00 63 FB 54

proc3f is a procedure at address 00405B72

call proc3f

EIP

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Problem 2. Given the macro definition

swap MACRO dword1, dword2

push  eax

mov  eax, dword1

xchgeax, dword2

mov  dword1, eax

pop  eax

     ENDM

Show the sequence of statements to which the macro call swap jack, jill expands.

Problem 3. Suppose that procedure examProc has 4 parameters: (1) a doubleword value, (2) a doubleword count, (3) a doublewordnbr, and (4) a doubleword array address arr. The procedure begins with the following code:

examProc PROC NEAR32
push ebp
mov ebp, esp
push ecx


(a) Using the diagram to the right, draw a picture showing the stack following execution of these instructions. Your picture must start with the parameters for the procedure, assuming cdecl protocol. You must label each relevant doubleword and show the bytes to which EBP and ESP point after the above code is executed.

(b) How can the second parameter count be referenced within the body of the procedure? Be specific.

Problem 4. Suppose that procedure examProc has 3 parameters: (1) a doubleword nbr, (2) a doubleword count, and (3) a doublewordvalue. The procedure begins with the following code:

examProc PROC
push ebp
mov ebp, esp
push eax
push ecx

(a) Using the diagram to the right, draw a picture showing the stack following execution of these instructions. Your picture must start with the parameters for the procedure. You must label each relevant doubleword and show the bytes to which EBP and ESP point after the above code is executed. Assume cdecl procedure calling conventions.

(b) How can the third parameter value be referenced within the body of the procedure? Be specific.

Problem 5. The volume of a pyramid with a rectangular base is given by the formula(h(xy))/3where h is the height of the pyramid,x is the length and y is the width of the base.
In C++, the header for a function to calculate this volume could be written
int pVolume(int height, int length, int width);
// return volume of pyramid with rectangular base

(a) Show assembly language code appropriate for "main" that would be equivalent to the C++ statement
volume = pVolume(24, 9, 5);
Assume 32-bit cdecl protocol is used and that volume references a doubleword integer in memory.

(b) Starting with the PROC directive and ending with the ENDP directive, write an 80x86 procedure pVolume that computes the volume of a pyramid. Assume the parameters are doubleword integers, in the order given by the C++ function header above. Follow 32-bit cdecl protocol.

Problem 6. The area of a trapezoid is given by the formula(h(b_1+b_2))/2where h is the height of the trapezoid and b1 and b2 are the lengths of the parallel bases.
In C++, the header for a function to calculate this area could be written
int tArea(int height, int base1, int base2);
// return area of trapezoid

(a) Show assembly language code appropriate for "main" that would be equivalent to the C++ statement
area = tArea(10, 15, 23);
Assume that area references a doubleword in memory.

(b) Starting with the PROC directive and ending with the ENDP directive, write an 80x86 procedure tArea that computes the area of a trapezoid. Assume the parameters are doubleword integers, in the order given by the C++ function header above.
Follow 32-bitcdeclprotocol.

Problem 7. Starting with the PROC directive and ending with the ENP directive, write an 80x86 procedure that implements the function described by the following C++ function header:
int arrMin(int arr[], int count);
// if count > 0 returns minimum of the first count elements of arr
// otherwise returns 99999
Follow 32-bit cdeclprotocol.

Attachment:- Problem Set.rar

Reference no: EM132598358

Questions Cloud

Calculate the activity variances for march : Calculate the activity variances for March. You have just been hired by FAB Corporation, the manufacturer of a revolutionary new garage
Why study is important to advancing nursing knowledge : Describe the purpose of the Flannigan et al. (2014) study and why this study is important to advancing nursing knowledge. According to the study narrative.
What stockholder equity as of end of budget period is called : An accounting statement that presents predicted amounts of the company's assets, liabilities, and stockholders' equity as of end of the budget period is called
Key leadership trait that can assist in managing conflict : Imagine you are working with a partner to plan and host a workshop on leadership. Address a key leadership trait that can assist in managing conflict.
How can the third parameter value be referenced : Draw a picture showing the stack following execution of these instructions. Your picture must start with the parameters for the procedure
What the bulk of the investment-related cash outflow occurs : For a typical capital investment project, the bulk of the investment-related cash outflow occurs? During the operation stage of the project (i.e., after time)
Respiratory acidosis vs respiratory alkalosis : What is the difference in Respiratory Acidosis vs Respiratory Alkalosis vs Metabolic Acidosis vs Metabolic Alkalosis?
Namely personal versus real property : What do you think are the main differences between the two (2) types of property: namely personal versus real property?
Explain how you would respond to the scenario : Write a detailed one-page narrative (not a formal paper) explaining the health assessment information required for a diagnosis of your selected patient.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd