Slide 7.5: Flags affected by addition and subtraction
Slide 7.7: Flags affected by addition and subtraction (cont.)
Home

Flags Affected by Addition and Subtraction (Cont.)

 0FFh + 1  00h – 1  00h – 1
 .data
 X  SWORD  12FFh
 .code
     movsx  ebx, X
     inc    bl
     call   DumpRegs
     jz     L1
     call   WaitMsg
 L1: mov    X, bx
     movsx  eax, X
     call   WriteHex
 .data
 X  SWORD  0FF00h
 .code
     movsx  ebx, X
     dec    bl
     call   DumpRegs
     mov    X, bx
     js     L1
     call   WaitMsg
 L1: movsx  eax, X
     call   WriteHex
 .data
 X  SWORD  0FF00h
 .code
     movsx  ebx, X
     sub    bl, 1
     call   DumpRegs
     mov    X, bx
     js     L1
     call   WaitMsg
 L1: movsx  eax, X
     call   WriteHex
 Output  Output  Output
  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX=  



  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX =  



  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX=  



 [X + 1] + 1  0FF0Fh + 1  0101h + 1
 .data
 X  SWORD  0FF00h
 .code
     add    X+1, 1
     call   DumpRegs
     jz     L1
     call   WaitMsg
 L1: movsx  eax, X
     call   WriteHex
 .code
     mov    bx, 0FF0Fh
     add    bl, 1
     call   DumpRegs
     lahf
     test   ah, 00010000b
     jz     L1
     call   WaitMsg
 L1: movsx  eax, bx
     call   WriteHex
 .code
     mov    bx, 0101h
     add    bx, 1
     call   DumpRegs
     jp     L1
     call   WaitMsg
 L1: movsx  eax, bx
     call   WriteHex
 Output  Output  Output
  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX=  



  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX=  



  CF=   SF=   ZF=
  OF=   AF=   PF=

EAX=