04 control Flashcards
(11 cards)
Transfers to a specific location in the program denoted with a program label without evaluating any condition.
Unconditional Control Transfer
jmp <label></label>
The target or a location to jump to for control statements.
Starts with a letter, followed by letters, numbers, or “_”, terminated with a colon (“:”).
label (program label)
True or False:
Labels may be defined only once.
True
Control transfer instruction that provides a conditional jump based on a comparison.
This provides the functionality of a basic IF statement.
Conditional Control Transfer (jae, jbe, ja, jb, etc.)
Two steps that are required for a comparison
compare instruction
&
conditional jump instruction
True or False:
The conditional jump instruction always jumps to the provided label regardless of the result of the previous comparison or condition.
False
(will or will not jump)
What is the general form of the compare instruction?
cmp <op1>, <op2></op2></op1>
True or False:
<op1> can be an immediate value, but
<op2> may not be an immediate value
</op2></op1>
False
(Should always be cmp eax, 10 or cmp ebx, ecx)
cmp 10, eax (INVALID)
True or False:
The conditional jump instruction is based only on the values of general-purpose registers, not the rFlag register.
False
(based on the contents of the rFlag register) (CF,ZF,SF,OF, etc.)
Convert to Assembly:
num db 3
max db 8
if (num > max)
max = num
num db 3
max db 8
mov al, byte[num]
cmp al, byte[max]
jg newMax
newMax:
mov byte[max], al
Convert to Assembly:
if ((ax >= 100) && (ax <= 120)){
bx = ax;
}else {
bx = cx;
}
cmp ax, 100
jl else_stmt
cmp ax, 120
jg else_stmt
mov bx, ax