chapter6


  1. OR, AND, XOR, Test Instructions. Know what operands can be the destination operand and the source operand and how they work and what flags they set.

AND

destination,source

images/8-1.png

always clear the OF, CY flags and modify SIGN, ZERO, PARITY when destinated operand occur at such.

it useful for bit masking (convert to uppercase, lowercase, clear bit in positiion n) ex: AND AL, 11111011; clear bit 2

OR

destination,source

same operand as AND, clear OF, CY and modify SIGN ZERO PARITY

is useful to set a bit in any pos we want without affect the other ex: or AL, 00000100; set bit 2

if OR AL, AL

images/8-2.png

XOR

destination,source

(or exclusive ex: 0 xor 0 = 0, 0 xor 1 = 1, 1 xor 1 = 0)

useful for toggle bit, 1 and 0 when xor. can only XOR for 8 bit

clear the OF and CY and modifies the SIgn, Zero, and Parity flag.

example:

Usefor checking Parity flags

8 bit:

images/8-3.png

16 bit:

images/8-4.png 4 1s ( even)

32 bit:

images/8-5.png

TEST Instruction

( a fake and without modifying the bits but also set the flags)

The TEST instruction always clears the Overflow and Carry flags. It modifies the Sign, Zero, and Parity flags in the same way as the AND instruction.

images/8-6.png

CMP Instruction

CMP

destination,source

same operand combinations as the AND instruction.

change the OF, Sign, ZEro, carry, Auxiliary Carry and parity flags.

This is for unsigned comparison.

images/8-7.png

signed operands are compared:

images/8-8.png

TIPS;

images/8-9.png

images/8-10.png

images/8-11.png

JUMP CONDITION

images/8-12.png