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

Please Help!! Have some answered but not sure if my answer is correct. 1. If a p

ID: 3535386 • Letter: P

Question

Please Help!! Have some answered but not sure if my answer is correct.


1. If a procedure recursively calls itself millions of times, what is the likely result?

a. The program will continue to run until interrupted by the user.

b. The number of recursive calls will be limited by the value placed in the RL (recurion limiter) register.

c. The amount of memory usage will be constant, because the procedure is simply branching to its own offset.

d. The stack will overflow.


2. What advantages do stack parameters have over register parameters?

a. Stack parameters reduce code clutter because registers do not have to be saved and restored.

b. Programs using stack parameres execute more quickly.

c. Stack parameters are incompatible with high-level languages.

d. Register parameters are optimized for speed.


3. MySub PROC, N:DWORD CMP N,7,je L1 mov eax, N inc eax‚INVOKE MySub, eaxL1: retMySub,ENDPConsider the procedure named MySub. Which of the following statements are true?

a. MySub uses 4 doublewords of stack space each time it is called.

b. MySub is recursive

c. MySub terminates when N is equal to 8.

d. the parameter N is equivaleent to [EBP+4].


4. Which of the following PROT statements are valid?

a. MySub PROTO, val1:WORD, val2:DWORD.

b. MySub PROTO USES eax, val1:WORD, val2:DWORD

c. MySub PROTO USES eax ebx, val1:WORD, val2:DWORD

d. MySub PROTO, val1:WORD, val2:DWORD LOCAL v1:BYTE


5. Which of the following INVOKE statement are invalid?

a. INVOKE mySub, [array+2].

b. INVOKE mySub, 30.

c. INVOKE mySub, ADDR myList.

d. INVOKE mySub, PTR myList



6. Which of the following are true regarding local variables?

a. They make efficient use of memory because their storage space can be released.

b. They can be accessed from anywhere inside the same source code module.

c. They are usually created in the data segement.

d. None of the above.



7. How are static variables distinguished from global variables?

a. Static variables are visible from all procedures in the source code file.

b. Static variables have a shorter lifetime than global variables.

c. The lifetime of a static variable is the same as the lifetime of its program.

d. Static variables are created on the stack, using the ESP and EBP registers.



8.main PROC mov eax,0 push 8 call Accum‚call DumpRegs,exitmain ENDPAccum PROC‚push ebp‚

mov,ebp,esp,mov‚ ebx,[ebp+8]‚cmp‚ ebx,2,je‚ L1‚add‚eax,ebx, sub‚ebx,2‚push ebx‚call AccumL1: pop,ebp,ret‚ 4Accum ENDPRefer to program above.

What will be the value of EAX when DumpRegs is called?

a. 8

b. 0Ah

c. 12h

d. 14h



9.Which of the following shows the procedure entry code generated by MASM when the LOCAL directive is used to declare a doubleword variable?

a. mov ebp,esppush ebpsub esp,4

b. push ebpmov esp,ebpadd esp,4

c. push ebpmov ebp,espsub esp,4

d. push ebpmov ebp,espadd esp,4



10.Which of the following defines an array local variable consisting of 50 signed words?

a. LOCAL wArray[50]:SWORD

b. LOCAL wArray:SWORD[50]

c. LOCAL SWORD[50]:wArray

d. LOCAL SWORD:wArray[50]


Explanation / Answer

1.

If a procedure recursively calls itself millions of times, the likely result will be that the program will continue to run until interrupted by the user.

Since, in the recursive call, the procedure is called again and again leading to the situation that the program will keep on running again and again.

The correct option is a.

2.

The stack parameters have the advantage over register parameters that stack parameters reduce code clutter because registers do not have to be saved and restored and stack parameters are compatible with high-level languages.

The correct options are a. and c.

3

In this procedure MySub 4 double words are used which are of stack space each time it is called and the parameter N is equivalent to [EBP+4].

The statements which are true are a and d.

4.

The PROT statements which is valid is that MySub PROTO USES eax, val1: WORD, val2: DWORD

The PROTO creates a procedure prototype and the syntax is: label PROTO paramlist.

The correct option is b

5.

The INVOKE statement that is invalid is INVOKE mySub, 30.

The correct option is b

6.

The statement that is true regarding local variables is that they make efficient use of memory because their storage space can be released.

The correct option is a

7.

The static variables can be distinguished from the global variables that the lifetime of a static variable is the same as the lifetime of its program

The static variables have scope within the code block in which they are declared by the scope of the global variables exist throughout the program and not a particular code in which they are declared.

The correct option is c

8.

The value of EAX when DumpRegs is called is 12h

The correct option is c

9.

The following which shows the procedure entry code generated by MASM when the LOCAL directive is used to declare a doubleword variable is:

push ebp

mov ebp,esp

sub esp,4

The correct option is c

10.

The following which defines an array local variable consisting of 50 signed words is

LOCAL wArray[50]:SWORD

The correct option is a