Chapter 6 - Conditional Processing Flashcards
What flag is set when the result of an operation equals zero?
Zero flag
The Zero flag is set when the destination equals zero.
What flag is set when an instruction generates a result that is too large for the destination operand?
Carry flag
The Carry flag is set when an unsigned value is out of range.
What flag indicates that the destination operand is negative?
Sign flag
The Sign flag is set if the destination operand is negative and clear if positive.
What flag is set when an instruction generates an invalid signed result?
Overflow flag
The Overflow flag is determined by XORing bit 7 carry with bit 6 Carry.
What flag is set when an instruction generates an even number of 1 bits in the low byte of the destination operand?
Parity flag
The Parity flag reflects the evenness of 1 bits in the low byte.
What flag is set when an operation produces a carry out from bit 3 to bit 4?
Auxiliary Carry flag
This flag indicates a carry between specific bits.
What operation does the AND instruction perform?
Boolean AND operation
The AND instruction performs a bitwise AND between two operands.
What happens to the Overflow and Carry flags after an AND instruction?
Cleared
The AND instruction always clears the Overflow and Carry flags.
What operation does the OR instruction perform?
Boolean OR operation
The OR instruction performs a bitwise OR between two operands.
What does the XOR instruction do?
Boolean exclusive-OR operation
The XOR instruction performs a bitwise exclusive OR between two operands.
What is the result of the NOT instruction?
One’s complement
The NOT instruction toggles (inverts) all bits in an operand.
What type of searches utilize techniques from propositional logic?
Boolean searches
Boolean searches use AND, OR, and NOT to filter search results.
What does the AND connective do in Boolean searches?
Matches records containing both search terms
The AND connective is used to find results that include all specified terms.
What does the OR connective do in Boolean searches?
Matches one or both search terms
OR is the broadest operator and returns any results containing either term.
What does the NOT connective do in Boolean searches?
Excludes a particular search term
The NOT operator filters out unwanted terms from search results.
What instruction performs a nondestructive AND operation?
TEST instruction
TEST does not modify the destination operand but affects the Zero flag.
What does the CMP instruction do?
Compares destination and source operands
CMP performs nondestructive subtraction of source from destination.
What flags does the CMP instruction affect?
Overflow, Sign, Zero, Carry, Auxiliary Carry, Parity flags
These flags indicate the result of the comparison.
What does the JC instruction do?
Jump to a label if the Carry flag is set
JC is a conditional jump based on the Carry flag.
What does the JZ instruction do?
Jump to a label if the Zero flag is set
JZ is a conditional jump based on the Zero flag.
What does the JG instruction do?
Jump if greater (signed comparison)
JG checks if the left operand is greater than the right for signed values.
What does the JA instruction do?
Jump if above (unsigned comparison)
JA is used for unsigned comparisons to check if the first operand is greater.
What is the purpose of the JNL instruction?
Jump if not less
JNL checks if the left operand is greater than or equal to the right.
What is the purpose of the JL instruction?
Jump if less
JL checks if the left operand is less than the right.
What instruction is used to compare signed values in assembly?
CMP
What does the instruction ‘JG’ do?
Jump if greater (signed)
What does the instruction ‘JA’ do?
Jump if above (unsigned)
What condition must be met for ‘JLE’ to transfer control?
EAX is less than or equal to Val1 (signed)
What condition must be met for ‘JBE’ to transfer control?
EAX is below or equal to Val1 (unsigned)
What does the instruction ‘JZ’ check for?
Jump if zero (ZF = 1)
What does ‘JAE’ stand for?
Jump if above or equal (unsigned)
In the context of conditional jumps, what does ‘JE’ mean?
Jump if equal
What do the instructions ‘LOOPZ’ and ‘LOOPE’ have in common?
They both loop if zero (ZF = 1)
What is the purpose of the ‘LOOPNZ’ instruction?
Loop if not zero (ZF = 0)
What is the function of the ‘CMP’ instruction?
Compare two values
Fill in the blank: The instruction ‘______’ is used to compare two unsigned values.
CMP
What is a key characteristic of the ‘JNE’ instruction?
Jump if not equal
What does the instruction ‘TEST’ do?
Logical AND operation with setting flags
True or False: The ‘CMP’ instruction can only compare signed integers.
False
What is the purpose of the XOR instruction in the encryption example?
To transform every character in a string into a new value
What is required for a ‘WHILE’ loop to execute?
The loop condition must be true
What does ‘JA’ check for in conditional structures?
Jump if op1 > op2 (unsigned)
What is the syntax for the ‘LOOPZ’ instruction?
LOOPZ destination
What is the result of using ‘XOR’ for encryption?
Encrypts a message by transforming its characters
What does ‘JAE’ check for?
Jump if op1 >= op2 (unsigned)
What happens if the condition for ‘JNG’ is not met?
The jump is not taken
What is the effect of the ‘MOV’ instruction?
Copies data from one location to another
What kind of values do the instructions ‘JBE’ and ‘JAE’ deal with?
Unsigned values
What is the purpose of the ‘CMP’ instruction in the lottery example?
To check if the user’s number matches any winning number
What does the ‘JGE’ instruction check?
Jump if greater or equal (signed)
What does ‘JNL’ do?
Jump if not less (signed)
What is the significance of the Zero flag (ZF)?
Indicates whether the last operation resulted in zero
True or False: ‘LOOP’ decrements the ECX register.
True
What does the instruction ‘JAE’ do?
Jump if above or equal (unsigned)
Fill in the blank: The ‘______’ instruction is used to check for even parity.
TEST
What does ‘JLE’ check for?
Jump if less than or equal (signed)
What is a common use for the ‘CMP’ instruction?
To compare two operands before a conditional jump
What is a finite-state machine (FSM)?
A graph structure that changes state based on some input
Also called a state-transition diagram
What are the components of a graph representing an FSM?
Nodes and edges
Nodes are squares or circles, edges are lines with arrows between the circles
What is a directed graph in relation to FSM?
A more general structure of which FSM is a specific instance
What are the three basic states represented by nodes in an FSM?
- Start state
- Terminal state(s)
- Nonterminal state(s)
What does an FSM accept?
Any sequence of symbols that puts it into an accepting (final) state
What can an FSM be used to recognize?
A sequence of characters governed by language rules (called a regular expression)
What are the advantages of using a finite-state machine?
- Provides visual tracking of program’s flow of control
- Easy to modify
- Easily implemented in assembly language
What does JE stand for in assembly language?
Jump if equal
What does JZ indicate in assembly language?
Jump if zero flag = 1
What are some high-level conditional control flow directives in MASM?
- JE
- JNE
- JC
- JZ
- JNC
- JP
- JG
- JL
- JNG
- JA
- JB
- JNA
What is the purpose of CMP in assembly language?
Compares operands using implied subtraction and sets condition flags
What are bitwise instructions used for?
Manipulating individual bits in operands
Examples include AND, OR, XOR, NOT, TEST
What is the function of conditional jumps in assembly?
Control the flow of execution based on the evaluation of conditions
Fill in the blank: The flowchart is a ______ tool.
logic diagramming
True or False: High-level conditional control flow directives in MASM can be used in 64-bit mode.
False
What does LOOPZ do in assembly language?
Loops while zero flag is set
What does LOOPNZ do in assembly language?
Loops while zero flag is not set
What does the instruction call DisplayErrorMsg do?
Displays an error message for invalid input found
What is the purpose of a state-transition diagram?
To visually represent the state changes in a finite-state machine
What is the significance of the leading + or - sign in the FSM for signed integers?
Indicates whether the integer is positive or negative