Assembly Language Flashcards
What are the 4 general purpose registers?
EAX - Accumulator
EBX - Base register
ECX - Counter register
EDX - Data register
What are the 3 pointers?
ESP - Stack Pointer
EIP - Instruction Pointer
EBP - Base Pointer
What format string is needed for an integer?
“%d”
How do you output a string variable named StrOne?
lea eax, StrOne
push eax
call printf
pop eax
How do you perform integer user input to store the value in a variable called num?
A variable called fmt exists with “%d”
lea eax, num push eax lea eax, fmt push eax call scanf add esp, 8
How does immediate addressing work?
Value is put directly into instruction.
e.g. mov eax, 5
How does register addressing work?
The value is stored in a register
e.g. mov eax, ebx
How does direct addressing work?
Operand is in main memory and instruction has its address.
e.g. mov eax, [memory address]
How does register indirect addressing work?
Instruction points to a register and the register stores the memory address.
e.g. mov eax, [ebx]
How do you put a register into an instruction so it uses the value in the register as and address rather than a value?
put square brackets around it.
[ebx]
What are the 4 things in the Flags register?
Sign (S)
Zero (Z)
Carry (C)
Overflow (O)
What does the sign flag show?
Whether result is + or -
What does the zero flag show?
Whether the result is zero
What does the carry flag show?
Whether result has an arithmetic carry
What does the overflow flag show?
Whether results has arithmetic overflow
What instruction is done before a conditional jump?
cmp
the compare instruction is what sets the flags
When will JMP jump?
always, its unconditional
When will JC jump?
When carry flag is set (=1)
When will JNC jump?
When carry flag isn’t set (=0)
When will JZ jump?
When zero flag is set (=1)
When will JNZ jump?
When zero flag isn’t set (=0)
When will JS jump?
When sign flag is set (=1)
When will JNS jump?
When sign flag isn’t set (=0)
When will JO jump?
When overflow flag is set (=1)
When will JNO jump?
When overflow flag isn’t set (=0)
When will JE jump?
When previous comparison is equal
a = b
When will JNE jump?
When previous comparison isn’t equal
a != b
When will JG/JNLE jump?
When a > b
Jump is assumed to come after cmp a, b
When will JGE/JNL jump?
When a >= b
Jump is assumed to come after cmp a, b
When will JLE/JNG jump?
When a <= b
Jump is assumed to come after cmp a, b
When will JL/JNGE jump?
When a < b
Jump is assumed to come after cmp a, b
With eax stroring the address of a string, how would you move just the first character into edx?
movzx edx, byte ptr [eax]