<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>
Date   : Fri, 12 Aug 1994 14:28:17 EST
From   : Stephen Quan <quan@...>
Subject: Re: adc and sbc (again).

There is a logic error in the calculation of the carry flag.
A patch macros for ADC, and SBC are :

#define ADC(cycles,amode) \
  pre##amode; \
  M=amode; \
  A2=A+M+(P&P_C); \
  P=P&~(P_N^P_V^P_Z^P_C)^P_NZ[A2]^((A>0xff-M-(P&P_C))?P_C:0)^((((A2^M))&(A^A2)&0
x80)?P_V:0); \
  A=A2; \
  post##amode; \
  IncClock(cycles); \
  break;

#define SBC(cycles,amode) \
  pre##amode; \
  M=amode; \
  A2=A+(~M)+(P&P_C); \
  P=P&~(P_N^P_V^P_Z^P_C)^P_NZ[A2]^((A<M+1-(P&P_C))?0:P_C)^((((A^M))&(A^A2)&0x80)
?P_V:0); \
  A=A2; \
  post##amode; \
  IncClock(cycles); \
  break;
-- 
Stephen Quan
<< Previous Message Main Index Next Message >>
<< Previous Message in Thread This Month Next Message in Thread >>