1. If a procedure recursively calls itself millions of times, what is the likely
ID: 3535165 • Letter: 1
Question
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-leve 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. Assuming that a procedure contains no local variables, a stack frame is created by which sequence of actions at runtime?
a. arguments pushed on stack; procedure called; EBP set to ESP; EBP pushed on stack.
b. arguments pushed on stack; EBP pushed on stack; EBP set to ESP; procedure called.
c. EBP pushed on stack; arguments pushed on stack; procedure called; EBP set to ESP.
d. arguments pushed on stack; procedure called; EBP pushed on stack; EBP set to ESP.
7. Which of the following PROC statements are invalid?
a. MySub PROC. val1: BYTE, val2: SDWORD.
b. MySub PROC, val1:PTR WORD, val2:DWORD
c. MySub PROC val1: WORD, val2:DWORD
d. None of the above
8. Which of the following are true about the C language specifier in the .MODEL directive?
a. The RET instruction removes parameters from the stack.
b. The calling program removes parameters froom the stack.
c. Inside the procedure, the POP instruction removed parameters from the stack before RET executes.
d. Afer the CALL instructions, a constant value is added to EBP to remove parameters from the stack.
9. 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.
10. 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 EBX when DumpRegs is called?
a. 2.
b. 4.
c. 6.
d. 8.
11. How does using the LEA instruction differ from using the OFFSET operator with MOV?
a. LEA cannot have an indirect source operand, whereas MOV-OFFSET can.
b. MOV-OFFSET retrieves a 32-bit offset, whereas LEA retrieves a combined segment-offset address.
c. LEA is effective for obtaining the address of a stack parameter.
d. The source operand used by LEA must be a constant value known at assembly time.
12. What advantages does INVOKE offer over the CALL instruction?
a. None. INVOKE is just a synonym for CALL.
b. INVOKE permits you to pass arguments separated by commas.
c. CALL does not require the use of the PROTO directive.
d. INVOKE executes more quickly than CALL.
Explanation / Answer
Below are your answers
1.
In the recursive calling, the procedure will execute again and again.
The procedure will be stop when the user interrupts the procedure, otherwise it will execute continuously.
Thus, the correct option is a.
2.
Since, the registers do not need to be restored and saved.
The stack parameters have the advantage of reducing the clutter.
Thus, the correct option is a.
3.
In the given procedure MySub, whenever it is being called it uses the four doublewords of the stack space.
Also, the parameter N in the procedure is equivalent to the [EBP + 4].
Thus, the correct options are a and d.
4.
The syntax for creating a procedure is as follows:
label PROTO paramlist.
Therefore, the correct syntax in the given options is as follows:
MySub PROTO USES eax, val1:WORD, val2:DWORD
Thus, the correct option is b.
5.
The incorrect syntax for invoking an invoke statement is INVOKE mySub, PTR myList.
Thus, the incorrect option is d.
6.
The steps for the creation of the stack frame is as follows:
The arguments are pushed into the stack.
The procedure will be called.
The ESB will be pushed on the stack.
Then, the EBP will be set to ESP.
Thus, the correct option for creating the stack frame is d.
7.
The given statements are valid statements with proper syntax of PROC.
Thus, the correct option is d.
8.
The C language specifier in the .MODEL directive removes the parameters from the stack while calling the program.
Thus, the correct option is b.
9.
The local variables use the memory more efficiently.
Since, the space used by the local variables can be released.
Thus, the correct option is a.
10.
When the DumpRegs is called, the value in EBX becomes 2.
Thus, the correct option is a.
11.
The LEA retrieve the address of the item while the mov instruction retrieve the exact value of the variable at the address.
Thus, the correct option is c.
12.
One of the advantage of using the INVOKE instruction rather than using the CALL instruction is that the parameters are separated by commas.
Thus, the correct option is b.
13.
While the accum is called in the program, the memory used by it is of 4 bytes.
Thus, the correct answer is a.
14.
The ADDR gives the facility of passing the arguments by reference and pass the parameters
on stack.
Thus, the correct options are a and b.
15.
As per the given program, the execution of RET instruction is 3 times.
Thus, the correct option is b.
16.
The steps to reserve the space on the stack is as follows:
after MOV EBP, ESP
substract 8 from the stack pointer (ESP).
Thus, the correct option is d.
17.
The global variable is accessible anywhere in the program.
They are visible to all the procedures of the file.
The static variable are alive till the program is alive.
Thus, the correct option is c.
18.
As per the given program, the value assign in the variable EAX is 12h.
Thus, the correct option is c.
19.
The procedure for the entry code is as follows:
push ebp
mov ebp, esp
sub esp, 4
Thus, the correct option is c.
20.
The correct syntax for assigning the 50 signed words is as follows:
LOCAL wArray[50] : SWORD
a
Thus, the correct option is a.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.