Flags Affected by Addition and Subtraction (Cont.)

0FFh + 1 80h – 1 80h + 0FFh
 INCLUDE Irvine32.inc
 .data
  X  SBYTE  0FFh
 .code
 main PROC
  add    X, 1
  call   DumpRegs
  jc     L1
  call   WaitMsg 
 L1:
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X  BYTE  80h
 .code
 main PROC
  sub    X, 1
  call   DumpRegs
  jc     L1
  call   WaitMsg
 L1:
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X  BYTE  80h
 .code
 main PROC
  add    X, 0FFh
  call   DumpRegs
    jc     L1
   call   WaitMsg
 L1:
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
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)
 INCLUDE Irvine32.inc 
 .data
  X  SBYTE  -128
 .code
 main PROC
  sub    X, 1
  call   DumpRegs
  jc     L1
  call   WaitMsg
 L1:
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  X  SBYTE  1
 .code
 main PROC
  sub    X, 2
  call   DumpRegs
  jc     L1
  call   WaitMsg
 L1:
  movsx  eax, X
  call   WriteHex
  exit
 main ENDP
 END main
 INCLUDE Irvine32.inc
 .data
  Dummy  WORD  ?
 .code
 main PROC
  sub    eax, eax
  mov    al, -128
  neg    al
  call   DumpRegs
  jo     L1
  call   WaitMsg
 L1:
  call   WriteHex
  exit
 main ENDP
 END main
Output Output Output

CF=   SF=   ZF=

OF=   AF=   PF=

EAX=  

 


CF=   SF=   ZF=

OF=   AF=   PF=

EAX=  

 


CF=   SF=   ZF=

OF=   AF=   PF=

EAX=  

 



      “I’m not arguing, I’m just explaining why I’m right.”    
      ― Unknown