public void ADC(int tmp)
    {        
            if ((m6502.p & F_D)	!=0)											
            {															
            int c = (m6502.p & F_C);											
            int lo = (m6502.a & 0x0f) + (tmp & 0x0f) + c; 					
            int hi = (m6502.a & 0xf0) + (tmp & 0xf0); 						
                    m6502.p &= ~(F_V | F_C);										
                    if (lo > 0x09)											
                    {														
                            hi += 0x10; 										
                            lo += 0x06; 										
                    }														
                    if ((~(m6502.a^tmp) & (m6502.a^hi) & F_N)!=0)							
                            m6502.p |= F_V;											
                    if (hi > 0x90)											
                            hi += 0x60; 										
                    if ((hi & 0xff00)!=0)										
                            m6502.p |= F_C;											
                    m6502.a = (lo & 0x0f) + (hi & 0xf0);							
            }															
            else														
            {															
            int c = (m6502.p & F_C);											
            int sum = m6502.a + tmp + c;										
                    m6502.p &= ~(F_V | F_C);										
                    if ((~(m6502.a^tmp) & (m6502.a^sum) & F_N)!=0)							
                            m6502.p |= F_V;											
                    if ((sum & 0xff00)!=0)										
                            m6502.p |= F_C;											
                    m6502.a =  sum & 0xFF;										
            }															
            SET_NZ(m6502.a);
    }