Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

You must INCLUDE Irvine32.inc Write a procedure named ShowParams that displays t

ID: 3535981 • Letter: Y

Question

You must INCLUDE Irvine32.inc

Write a procedure named ShowParams that displays the address and hexadecimal value of the

32-bit parameters on the runtime stack of the procedure that called it. The parameters are to be

displayed in order from the lowest address to the highest. Input to the procedure will be a single

integer that indicates the number of parameters to display. For example, suppose the following

statement in main calls MySample, passing three arguments:

INVOKE MySample, 1234h, 5000h, 6543h

Next, inside MySample, we make a call to ShowParams, passing the number of parameters:

MySample PROC first:DWORD, second:DWORD, third:DWORD

paramCount = 3

call ShowParams, paramCount

Suggestion: Run the program in Debug mode and examine the Disassembly window. The following

is a sample of the expected output:

Stack parameters:

---------------------------

Address 0012FF80 = 00001234

Address 0012FF84 = 00005000

Address 0012FF88 = 00006543

Use these prototypes in your program:

ShowParams PROTO numParams:DWORD

Note: after displaying the addresses and hex value of each 32-bit parameter ShowParms MUST utilize WaitMsg to pause the screen.

Explanation / Answer

Use the = (equal sign) subcommand to display an address in a given format. This command displays instruction and data addresses in a simpler form and can display the results of arithmetic expressions. For example, entering:

displays the address of the symbol main:

The following example shows a command that displays (in decimal) the sum of the internal variable b and the hexadecimal value 0x2000, together with its output:

If a count is given, the same value is repeated that number of times. The following example shows a command that displays the value ofmain twice and the output that it produces:

If no address is given, the current address is used. After running the above command once (setting the current address to main), the following command repeats that function:

If you do not specify a format, the adb debug program uses the last format that was used with this command. For example, in the following sequence of commands, both main and one are displayed in hexadecimal:

To trace the path of all active functions, use the $c subcommand. This subcommand lists the names of all functions that have been called and have not yet returned control. It also lists the address from which each function was called and the arguments passed to each function. For example, the following command sequence sets a breakpoint at the function address .f+2 in the adbsamp2 program. The breakpoint calls the $c subcommand. The program is started, runs to the breakpoint, and then displays a backtrace of the called C language functions:

By default, the $c subcommand displays all calls. To display fewer calls, supply a count of the number of calls to display. For example, the following command displays only one of the active functions at the preceding breakpoint:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote