130 likes | 284 Views
Chapter 6:. 22342 – Computer Organization & Assembly Language. Conditional Processing. Boolean Instructions. AND AND reg , reg AND reg , mem AND reg , imm AND mem , reg AND mem , imm Sign, Zero Flags OR XOR NOT. Boolean Instructions.
E N D
Chapter 6: 22342 – Computer Organization & Assembly Language Conditional Processing
Boolean Instructions • AND • AND reg, reg • AND reg, mem • AND reg, imm • AND mem, reg • AND mem, imm Sign, Zero Flags • OR • XOR • NOT
Boolean Instructions Example: ASCII Case: A = 0100 0001 a = 0110 0001 Sentence = “I aM A sTudeNT”
Boolean Instructions • TEST (Similar to AND) • TEST reg, reg • TEST reg, mem • TEST reg, imm • TEST mem, reg • TEST mem, imm Sign, Zero Flags
Compare Instruction • CMP (Similar to SUB) • CMP reg, reg • CMP reg, mem • CMP reg, imm • CMP mem, reg • CMP mem, imm Carry, Overflow, Sign, Zero Flags
Jump on Condition Instructions • Jcondition Label • Zero • Carry • Overflow • Sign • CX = 0
Jump on Compare Result • Unsigned Comparison (CMP X, Y) • X > Y • X ≥ Y • X = Y • X < Y • X ≤ Y
Jump on Compare Result • Signed Comparison (CMP X, Y) • X > Y • X ≥ Y • X = Y • X < Y • X ≤ Y
Jump on Compare Result Example: Z = MAX ( X, Y )
Jump on Compare Result Example: D = MIN ( A, B, C )
Jump on Compare Result Example: Find the first nonzero element in an array
LOOP on Condition (Repeat While) • LOOPZ (LOOPE) • Decrement the Counter • If Counter > 0 and ZF = 1 jump to label • LOOPNZ (LOOPNE)