anchor.diff:  
   ;; Binary-coded decimal
   
  -(defun ascii-adjust-after-add-or-sub (addition?)
  -  (disasm-instr (if addition? '("aaa") '("aas"))
  -    (let ((adjusted (or (> (logand (byte-register :al) #x0f) 9) (flag-p :af))))
  -      (if adjusted
  -	  (if addition? (incf (register :ax) #x106) (decf (register :ax) #x106)))
  -      (setf (flag-p :af) adjusted)
  -      (setf (flag-p :cf) adjusted)
  -      (logandf (byte-register :al) #x0f))))
  -
  -(defun decimal-adjust-after-add-or-sub (addition?)
  -  (disasm-instr (if addition? '("daa") '("das"))
  -    (let ((old-al (byte-register :al)) (old-cf (flag-p :cf))) 
  -	  (when (or (> (logand (byte-register :al) #x0f) 9) (flag-p :af))
  -	    (if addition? (incf (byte-register :al) 6) (decf (byte-register :al) 6))
  -	    (setf (flag-p :cf) (or old-cf *has-carried*))
  -	    (set-flag :af))
  -	  (when (or (> old-al #x9f) old-cf)
  -	    (if addition? (incf (byte-register :al) #x60) (decf (byte-register :al) #x60))
  -	    (set-flag :cf))
  -	  (set-zf-on-op (set-sf-on-op (set-pf-on-op (byte-register :al)) nil)))))
  +(defmacro ascii-adjust-after-add-or-sub (modifier)
  +  `(let ((adjusted (or (> (logand (byte-register :al) #x0f) 9) (flag-p :af))))
  +     (when adjusted
  +       (,modifier (register :ax) #x106))
  +     (setf (flag-p :af) adjusted)
  +     (setf (flag-p :cf) adjusted)
  +     (logandf (byte-register :al) #x0f)))
  +
  +(defmacro decimal-adjust-after-add-or-sub (modifier)
  +  `(let ((old-al (byte-register :al)) (old-cf (flag-p :cf)))
  +     (when (or (> (logand (byte-register :al) #x0f) 9) (flag-p :af))
  +       (,modifier (byte-register :al) 6)
  +       (setf (flag-p :cf) (or old-cf *has-carried*))
  +       (set-flag :af))
  +     (when (or (> old-al #x99) old-cf)
  +       (,modifier (byte-register :al) #x60)
  +       (set-flag :cf))
  +     (set-zf-on-op (set-sf-on-op (set-pf-on-op (byte-register :al)) nil))))
  +
  +(defun ascii-adjust-after-addition ()
  +  (disasm-instr '("aaa")
  +    (ascii-adjust-after-add-or-sub incf)))
  +
  +(defun ascii-adjust-after-subtraction ()
  +  (disasm-instr '("aas")
  +    (ascii-adjust-after-add-or-sub decf)))
  +
  +(defun decimal-adjust-after-addition ()
  +  (disasm-instr '("daa")
  +    (decimal-adjust-after-add-or-sub incf)))
  +
  +(defun decimal-adjust-after-subtraction ()
  +  (disasm-instr '("das")
  +    (decimal-adjust-after-add-or-sub decf)))
   
   ;;; Opcode parsing
   
  
positive.code:   `(disasm-instr (list "add" :src ,src :dest ,dest)
       (with-in-place-mod ,dest ,mod-bits ,r/m-bits
         (let ((src-value ,src))
  	 (set-zf-on-op (set-sf-on-op (set-pf-on-op (set-of-on-op (set-cf-on-add (set-af-on-op (incf ,dest src-value) src-value)) src-value ,is-word)) ,is-word))))))
  
  (defmacro add-with-carry (src dest is-word &optional mod-bits r/m-bits)
    `(disasm-instr (list "adc" :src ,src :dest ,dest)
       (with-in-place-mod ,dest ,mod-bits ,r/m-bits
         (let ((src-plus-cf (+ ,src (flag :cf))))
  	 (set-zf-on-op (set-sf-on-op (set-pf-on-op (set-of-on-op (set-cf-on-add (set-af-on-op (incf ,dest src-plus-cf) src-plus-cf)) src-plus-cf ,is-word)) ,is-word))))))
  
  (defmacro sub-without-borrow (src dest is-word &optional mod-bits r/m-bits)
    `(disasm-instr (list "sub" :src ,src :dest ,dest)
       (with-in-place-mod ,dest ,mod-bits ,r/m-bits
         (let ((src-value ,src))
  	 (set-zf-on-op (set-sf-on-op (set-pf-on-op (set-of-on-op (set-cf-on-sub (set-af-on-op (+ (decf ,dest src-value) src-value) src-value) src-value) src-value ,is-word)) ,is-word))))))
  
  (defmacro sub-with-borrow (src dest is-word &optional mod-bits r/m-bits)
    `(disasm-instr (list "sbb" :src ,src :dest ,dest)
       (with-in-place-mod ,dest ,mod-bits ,r/m-bits
         (let ((src-plus-cf (+ ,src (flag :cf))))
  	 (set-zf-on-op (set-sf-on-op (set-pf-on-op (set-of-on-op (set-cf-on-sub (set-af-on-op (+ (decf ,dest src-plus-cf) src-plus-cf) src-plus-cf) src-plus-cf) src-plus-cf ,is-word)) ,is-word))))))
  
  (defmacro cmp-operation (src dest is-word &optional mod-bits r/m-bits)
    `(disasm-instr (list "cmp" :src ,src :dest ,dest)
       (let ((src-value ,src))
         (set-zf-on-op (set-sf-on-op (set-pf-on-op (set-of-on-op (set-af-on-op (set-cf-on-sub ,dest src-value) src-value) src-value ,is-word)) ,is-word)))))
  
  (defmacro and-operation (src dest is-word &optional mod-bits r/m-bits)
    `(disasm-instr (list "and" :src ,src :dest ,dest)
  
negative.code:     ((= opcode #x9d) (pop-flags))
      ((= opcode #x9e) (store-flags-to-ah))
      ((= opcode #x9f) (load-flags-from-ah))
      ((= opcode #x27) (decimal-adjust-after-addition))
      ((= opcode #x2f) (decimal-adjust-after-subtraction))
      ((= opcode #x37) (ascii-adjust-after-addition))
      ((= opcode #x3f) (ascii-adjust-after-subtraction))))
  
  ;;; Main functions
  
  