ASSEM and ARCH - Mod 5
The stack frame inside a procedure is also known as the ____________.
Activation Record
Given the following procedures, with code segment instruction addresses given on each line in 4 byte hex... 00000000 main PROC ; ...; Execution Point A 0000001A CALL someProc1 0000001F CALL WriteDec; ... 00000030 exit00000031 main ENDP 00000031 someProc1 PROC 00000031 PUSH EAX 00000035 CALL someProc2 0000003A POP EAX; Execution Point B; ... 0000016F RET 0000016F someProc1 ENDP 0000016F someProc2 PROC 0000016F PUSH EBX ; ... 00000205 POP EBX 00000209 RET 0000020A someProc2 ENDP Assume ESP = 000004DAh, EAX = 00000040h, EBX = 00000120h at Execution Point A, there are no stack operations other than those visible, and EAX and EBX are only changed by the visible instructions. At Execution Point B: What is the current value of the stack pointer (in 4 byte hex)? What is the value at the top of the stack (in 4 byte hex)?
000004D6 0000001F
Given the following procedures, with code segment instruction addresses given on each line in 4 byte hex... 00000000 main PROC ; ... Execution Point A 0000011C CALL doSomething 00000120 MOV result, EAX; ... 0000023E exit 0000023F main ENDP 0000023F checkThings PROC ; ... 00000243 XOR BX, 0A00h; ... 00000274 RET 00000275 checkThings ENDP 00000275 doSomething PROC ; ... 000002A0 CALL checkThings 000002A5 MOV EAX, EDX ; Execution Point B ; ... 000002F3 RET 000002F4 doSomething ENDP Assume there are no stack operations other than the shown CALL and RET instructions, and ESP = 00000900h at Execution Point A. At Execution Point B: What is the current value of the stack pointer (in 4 byte hex)? What is the value at the top of the stack (in 4 byte hex)?
000008FC 00000120
What will be the value of EAX when the following sequence of instructions has executed? PUSH 5 PUSH 10 PUSH 20 POP EAX
20
The RET instruction (without operands) will pop how many bytes off the stack?
4
Assume ESP equals 1C3Fh at Execution Point A. Trace the following code to Execution Point B, then answer the questions below. MOV EAX, 7 MOV EBX, 11 MOV ECX, 42 MOV EDX, 99 ; Nine Nine!; Execution Point A PUSH ECX PUSH EAX PUSH EBX PUSH EDX POP ECX POP EDX POP EBX; Execution Point B POP EAX At Execution Point B, what is the decimal value in EBX? At Execution Point B, what is the hexadecimal value in ESP? At Execution Point B, what is the decimal value in ?
7 1C3B 42
An input/output parameter may be passed by value. (T/F)
False
In the IA32 architecture, ESP (the stack pointer) is incremented each time data is pushed onto the stack. (t/f)
False
Which of the following is true about the PUSH instruction? It increments the stack pointer by 1 and copies the operand into the stack at the location pointed to by the stack pointer. It decrements the stack pointer (by 2 or 4), and then copies the operand into the stack at the location pointed to by the stack pointer. It increments the stack pointer (by 2 or 4) and copies the operand into the stack at the location pointed to by the stack pointer. It copies the operand into the stack at the location pointed to by the stack pointer, and then decrements the stack pointer (by 2 or 4).
It decrements the stack pointer (by 2 or 4), and then copies the operand into the stack at the location pointed to by the stack pointer.
Which of the following code sequences assigns the value 10 to EBX? MOV ECX, 10MOV EDX, 20 PUSH ECX PUSH EDX POP EBX POP EDX PUSH 20MOV ECX, 10PUSH ECX POP EAX POP EBX MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX
MOV EDX, 20 PUSH EDX MOV ECX, 10 PUSH ECX POP EBX POP EDX
What instruction would I use to save the current value of the flags register?
PUSHF
When values are received by a called subroutine, they are called __________.
Parameters
What parameter-passing method do most/all of Irvine's library procedures use?
Pass Parameters in Registers
What advantages do stack parameters have over register parameters?
Stack parameters are compatible with high-level languages. Stack parameters reduce code clutter because registers do not have to be saved and restored.
A stack frame is _____
The area of the stack set aside for passed arguments, return address, local variables, and saved registers.
An argument passed by reference consists of a memory address offset. (T/F)
True
In the IA32 architecture, the top item on the stack will always have a lower memory address than the bottom item. (T/F)
True
Mechanically speaking, the CALL instruction pushes its return address on the stack and copies the called procedure's address into theinstruction pointer. (T/F)
True
There are several important uses of runtime stacks in programs
When calling a subroutine, you pass input values called arguments by pushing them on the stack. The stack provides temporary storage for local variables. When the CALL instruction executes, the stack is used to store the address where the called procedure will return to.
Values passed to a subroutine by a calling program are called __________.
arguments
A/An ________ procedure call occurs when a called procedure calls another procedure before the first procedure returns.
nested
Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?
on the stack
Select the proper syntax for establishing a subprocedure.
procedureName PROC ;... ;... RET ;return to calling procedure procedureName END