Control Transfer Instruction Flashcards
(15 cards)
What is the syntax for the unconditional control transfer instruction?
jmp <label></label>
jmp transfers to a specific location in the program denoted with a program label without _____________________.
evaluating any condition
A program _________ is the target, or a location to jump to, for control statements.
label
A label starts with a letter, followed by letters, numbers, or _, terminated with a _.
underscore (_), colon (:)
Labels may be defined only _.
once
Conditional control transfer instructions provide a ______________ based on a comparison.
conditional jump
A conditional jump is carried out on the basis of a _____ value
truth
Two steps required for a comparison.
compare, conditional jump
General form of the compare instruction?
cmp <op1>, <op2></op2></op1>
What are the restrictions on the compare instruction?
- operands must of the same size and cannot be both variable.
- only operand2 can be an immediate value
The cmp instruction will compare two results and store the results of the comparison in the ________ register.
rFlag
In conditional transfer instructions,
je means _____
jl means _____
jg means _____
ja means _____
jb means _____
jne means _____
je -> op1 == op2
jl -> op1 < op2
jg -> op1 > op2
ja -> op1 > op2
jb -> op1 < op2
jne -> op1 != op2
What is the assembly code for this?
if (num > max){
max = num
}
mov al, byte[num]
cmp al, byte[max]
ja newMax
newMax:
mov byte[max], al
What is the assembly code for this?
if (num > max){
max = num
}else{
max = max
}
mov al, byte[num]
cmp al, byte[max]
jbe else
mov byte[max], al
else:
Translate this code into assembly:
if (ax >= 100 && ax <= 120){
bx = ax
}else{
bx = cx
cmp ax, 100
jb elseStatement
cmp ax, 120
ja elseStatement
mov bx,ax
jmp SKIP
elseStatement:
mov bx, cx