Week Four Flashcards

1
Q

How would you order this four-byte sequence 928A8A57h stored in consecutive memory cells in a little-endian architecture into a big-endian architecture?

A

57 8A 8A 92

MSB –> LSB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How would you order this two-byte sequence C1ACh stored in consecutive memory cells in a little-endian architecture into a big-endian architecture?

A

AC C1h

MSB –> LSB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

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?

A

92 8A 8A 50h

LSB –> MSB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

When values are received by a called subroutine/function, they are called _________.

A

parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

High-level languages always pass arrays to subroutines by value.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A - D - E - F - B - C

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

When an argument is passed by value, a copy of the address is pushed on the stack.

A

False

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

A stack frame is?

A

The area of the stack set aside for passed arguments, subroutine return address, local variables, and saved registers.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Passing by reference requires dereferencing a parameter’s offset from the stack inside the called procedure.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A subroutine’s stack frame always contains the caller’s return address and the subroutine’s local variables.

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

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.
Stack parameters are compatible with high-level languages.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Another name for a stack frame is?

A

Activation record

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Assuming that a procedure contains no local variables, a stack frame is created in what order of actions at runtime?

A

arguments pushed on stack; procedure called; EBP pushed on stack; EBP set to ESP

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How would you define a local variable array consisting of 50 signed words?

A

LOCAL wArray[50]: SWORD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Values passed to a subroutine by a calling program are called _____.

A

arguments

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which action must take place inside a procedure to reserve space on the stack for two doubleword local variables?

A

after MOV EBP,ESP, subtract 8 from the stack pointer (ESP)

17
Q

An argument passed by reference consists of the offset of an object.

A

True

18
Q

Local variables are created by adding a positive value to the stack pointer.

A

False (subtracting from EBP)

19
Q

What general types of parameters are passed on the stack?

A

Value and reference arguments

20
Q

What is the procedure entry code generated by MASM when the LOCAL directive is used to declare a doubleword variable?

A

push ebp
mov ebp,esp
sub esp,4

21
Q

Which offers a more flexible approach, passing arguments to procedures in registers, or on the stack?

A

on the stack yo

22
Q

When an argument is passed by value, a copy of the address is pushed on the stack.

A

False

23
Q

What does the RET instruction do?

A

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).

24
Q

Is this a valid instruction?

mov [edx], [eax]

A

No, there are no memory to memory instructions. Both of these instructions point to a memory address.

25
Q

The stack pointer is _____ when we push things on, and _____ when we pop things off

A

decremented - push

incremented - pop

26
Q

In the Intel x86 architecture, the register that always points to the next instruction to be executed is the?

A

EIP

27
Q

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

A

D - A - B - C