





































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This lecture is part of lecture series on Computer Organization and Assembly Language. Main points of this lecture are: Conditional Processing, Boolean and Comparison, Conditional Jumps, Conditional Loop Instructions, Conditional Structures, Finite-State Machines, Decision Directives, Applications, Instruction Generates, Destination Operand
Typology: Slides
1 / 77
This page cannot be seen from the preview
Don't miss anything!






































































Boolean and Comparison
Instructions
Conditional Jumps
Conditional Loop Instructions
Conditional Structures
Application: Finite-State Machines
Decision Directives
The Zero flag is set when the result of an operation equals
zero.
The Carry flag is set when an instruction generates a result
that is too large (or too small) for the destination operand.
The Sign flag is set if the destination operand is negative,
and it is clear if the destination operand is positive.
The Overflow flag is set when an instruction generates an
invalid signed result.
The Parity flag is set when an instruction generates an even
number of 1 bits in the low byte of the destination operand.
The Auxiliary Carry flag is set when an operation produces a
carry out from bit 3 to bit 4 Docsity.com
Performs a Boolean AND operation between each
pair of matching bits in two operands
Syntax: (OF=0,CF=0,SF,ZF,PF)
AND destination, source (same operand types as MOV)
0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 0 0 0 0 1 0 1 1
AND cleared unchanged
AND
Performs a Boolean exclusive-OR operation between each pair of matching bits in two operands
Syntax: (OF=0,CF=0,SF,ZF,PF)
XOR destination, source
XOR
0 0 1 1 1 0 1 1 0 0 0 0 1 1 1 1 0 0 1 1 0 1 0 0
XOR unchanged inverted
XOR is a useful way to invert the bits in an operand.
Performs a Boolean NOT operation on a single destination operand
Syntax: (no flag affected)
NOT destination
NOT
0 0 1 1 1 0 1 1 1 1 0 0 0 1 0 0
NOT inverted
mov al,6 ; AL = 00000110b or al,00110000b ; AL = 00110110b
The ASCII digit '6' = 00110110b
mov ax,40h ; BIOS segment mov ds,ax mov bx,17h ; keyboard flag byte or BYTE PTR [bx],01000000b ; CapsLock on
keyboard flag byte at 0040:0017h in the BIOS data area.
This code only runs in Real-address mode, and it does not work under Windows NT, 2000, or XP.
or al,al jnz IsNotZero ; jump if not zero
(jump if not zero) instruction.
ORing any number with itself does not change its value.
Performs a nondestructive AND operation between each pair of matching bits in two operands
No operands are modified, but the flags is affected.
Example: jump to a label if either bit 0 or bit 1 in AL is set.
test al,00000011b jnz ValueFound
Example: destination > source (unsigned)
mov al, cmp al,5 ; ZF = 0, CF = 0
(both the Zero and Carry flags are clear)
Example: destination > source (signed)
mov al, cmp al,-2 ; Sign flag == Overflow flag
mov al,- cmp al,5 ; Sign flag != Overflow flag
Boolean and Comparison Instructions
Conditional Jumps
Conditional Loop Instructions
Conditional Structures
Application: Finite-State Machines
Decision Directives