Week Four Flashcards
How would you order this four-byte sequence 928A8A57h stored in consecutive memory cells in a little-endian architecture into a big-endian architecture?
57 8A 8A 92
MSB –> LSB
How would you order this two-byte sequence C1ACh stored in consecutive memory cells in a little-endian architecture into a big-endian architecture?
AC C1h
MSB –> LSB
How would you order this four-byte sequence 50 8A 8A 92h stored in consecutive memory cells in a big-endian architecture into a little-endian architecture?
92 8A 8A 50h
LSB –> MSB
When values are received by a called subroutine/function, they are called _________.
parameters
High-level languages always pass arrays to subroutines by value.
False
What are the order of steps for creating a stack frame?
a. passed arguments are pushed on the stack
b. if there are local variables, ESP is decremented to reserve space for the variables on the stack
c. if any registers need to be saved they are pushed on the stack
d. the subroutine is called, causing the subroutine’s return address to be pushed on the stack
e. as the subroutine begins to execute, EBP is pushed on the stack
f. EBP is set equal to ESP. From this point on EBP acts as a base reference for all of the subroutine parameters.
A - D - E - F - B - C
When an argument is passed by value, a copy of the address is pushed on the stack.
False
A stack frame is?
The area of the stack set aside for passed arguments, subroutine return address, local variables, and saved registers.
Passing by reference requires dereferencing a parameter’s offset from the stack inside the called procedure.
True
A subroutine’s stack frame always contains the caller’s return address and the subroutine’s local variables.
True
What advantages do stack parameters have over register parameters?
Stack parameters reduce code clutter because registers do not have to be saved and restored.
Stack parameters are compatible with high-level languages.
Another name for a stack frame is?
Activation record
Assuming that a procedure contains no local variables, a stack frame is created in what order of actions at runtime?
arguments pushed on stack; procedure called; EBP pushed on stack; EBP set to ESP
How would you define a local variable array consisting of 50 signed words?
LOCAL wArray[50]: SWORD
Values passed to a subroutine by a calling program are called _____.
arguments
Which action must take place inside a procedure to reserve space on the stack for two doubleword local variables?
after MOV EBP,ESP, subtract 8 from the stack pointer (ESP)
An argument passed by reference consists of the offset of an object.
True
Local variables are created by adding a positive value to the stack pointer.
False (subtracting from EBP)
What general types of parameters are passed on the stack?
Value and reference arguments
What is the procedure entry code generated by MASM when the LOCAL directive is used to declare a doubleword variable?
push ebp
mov ebp,esp
sub esp,4
Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?
on the stack yo
When an argument is passed by value, a copy of the address is pushed on the stack.
False
What does the RET instruction do?
When the procedure is ready to return, its RET instruction pops the 4-byte return address from the stack into the instruction pointer. The CPU executes the instruction in memory pointed to by EIP (instruction pointer register).
Is this a valid instruction?
mov [edx], [eax]
No, there are no memory to memory instructions. Both of these instructions point to a memory address.
The stack pointer is _____ when we push things on, and _____ when we pop things off
decremented - push
incremented - pop
In the Intel x86 architecture, the register that always points to the next instruction to be executed is the?
EIP
Please sort the following types of memory according to their relative access speeds, slowest to fastest.
a. main memory
b. cache
c. registers
d. optical disk
D - A - B - C