Slide 7.6: Flags affected by addition and subtraction (cont.)
Slide 8.1: Data-related operators
Home

Flags Affected by Addition and Subtraction (Cont.)

 0FFh + 1  80h – 1  80h + 0FFh
 .data
 X  SBYTE  0FFh
 .code
      add    X, 1
      call   DumpRegs
      jc     L1
      call   WaitMsg
 L1:  movsx  eax, X
      call   WriteHex
 .data
 X  BYTE  80h
 .code
      sub    X, 1
      call   DumpRegs
      jc     L1
      call   WaitMsg
 L1:  movsx  eax, X
      call   WriteHex
 .data
 X  BYTE  80h
 .code
      add    X, 0FFh
      call   DumpRegs
      jc     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=  



 –128 – 1  1 – 2  –(–128)
 .data
 X  SBYTE  -128
 .code
      sub    X, 1
      call   DumpRegs
      jc     L1
      call   WaitMsg
 L1:  movsx  eax, X
      call   WriteHex
 .data
 X  SBYTE  1
 .code
      sub    X, 2
      call   DumpRegs
      jc     L1
      call   WaitMsg
 L1:  movsx  eax, X
      call   WriteHex
 .code
      sub    eax, eax
      mov    al, -128
      neg    al
      call   DumpRegs
      jo     L1
      call   WaitMsg
 L1:  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=