1/18
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What are loops for?
-Loops are used to iterate over instructions by jumping backwards in the code. Jump instructions move the instruction pointer back to an earlier point in the code.
-Loops need to have terminating conditions - they iterate while a condition is true or until a certain condition is true.
What are the different types of loops?
-While loop
-Do While loop
-For loop
How is ECX used in loops?
The loop instruction performs a jump based on the value of ECX.
-First it decrements ECX.
-Then jumps to the given label if ECX is not zero.
How can we get the address of a variable?
(Load effective address)
lea ebx, age
What is used to access the memory address stored in a register?
Register Indirect mode.
mov eax, [ebx]
What are arrays used for?
Arrays are items stored in consecutive memory locations. The amount of memory depends on the data being stored in the array.
How much memory does an array take up in a 32-bit system?
Four bytes of memory
How do we find the memory address of an array?
lea ebx, grades
What are subroutines?
Subroutines are sections of code which can be invoked repeatedly as the program executes.
Why do we use subroutines?
How are subroutines used in asm?
Simple jump to a label (address) that points to the first instruction in the subroutine. Use the call instruction with the label of the subroutine. Use the ret instruction to return from the subroutine.
Explain the RET instruction
What are stacks used for?
Stacks allow us to store an arbitrary number of nested return addresses. It uses main memory of the current process. It is treated separately and accessed directly through CPU registers.
Stack grows downwards in memory.
Explain ESP, PUSH and POP
ESP - stack pointer, always points to memory address of top item on the stack.
PUSH – decrements ESP, points to next free area of memory. Writes the data item to that address.
POP – moves the data addressed by ESP into given register. Increments ESP by the correct amount to remove the item from stack.
Explain the CALL instruction
How do you adjust the stack?
What are the two forms of parameters?
What does Pass by Value depend on?
The caller and the callee agreeing on which registers to use.
What are the four calling conventions?