/* $19 DAA inherent (A) -**0* */ INLINE void daa( void ) { UINT8 msn, lsn; UINT16 t, cf = 0; msn=A & 0xf0; lsn=A & 0x0f; if( lsn>0x09 || CC&0x20 ) cf |= 0x06; if( msn>0x80 && lsn>0x09 ) cf |= 0x60; if( msn>0x90 || CC&0x01 ) cf |= 0x60; t = cf + A; CLR_NZV; /* keep carry from previous operation */ SET_NZ8((UINT8)t); SET_C8(t); A = t; }
static void sub_ba( void ) { UINT16 t; t = RDA - RDB; WRA(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 5; }
static void sbb_ba( void ) { UINT16 t; t = RDA - RDB - ((pSR & SR_C) ? 0 : 1); WRA(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 5; }
static void adc_b2a( void ) { UINT16 t; t = RDA + RDB + GET_C; WRA(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 5; }
static void inc_b( void ) { UINT16 t; t = RDB + 1; WRB( t ); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 5; }
static void dec_a( void ) { UINT16 t; t = RDA - 1; WRA( t ); CLR_NZC; SET_N8(t); SET_Z8(t); SET_C8(~t); tms7000_icount -= 5; }
static void sbb_ra( void ) { UINT16 t; UINT8 r; IMMBYTE(r); t = RDA - RM(r) - ((pSR & SR_C) ? 0 : 1); WRA(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 8; }
static void sbb_ib( void ) { UINT16 t; UINT8 i; IMMBYTE(i); t = RDB - i - ((pSR & SR_C) ? 0 : 1); WRB(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void sub_rb( void ) { UINT16 t; UINT8 r; IMMBYTE(r); t = RDB - RM(r); WRB(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 8; }
static void sub_ib( void ) { UINT16 t; UINT8 i; IMMBYTE(i); t = RDB - i; WRB(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void add_i2b( void ) { UINT16 t; UINT8 v; IMMBYTE(v); t = v + RDB; WRB(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void add_r2a( void ) { UINT16 t; UINT8 v; IMMBYTE(v); t = RM(v) + RDA; WRA(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 8; }
static void cmp_ba( void ) { UINT16 t; t = RDA - RDB; CLR_NZC; SET_N8(t); SET_Z8(t); if( t==0 ) SETC; else SET_C8( ~t ); tms7000_icount -= 5; }
static void sub_ir( void ) { UINT16 t; UINT8 r,i; IMMBYTE(i); IMMBYTE(r); t = RM(r) - i; WM(r,t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 9; }
static void sub_rr( void ) { UINT16 t; UINT8 r,s; IMMBYTE(s); IMMBYTE(r); t = RM(r) - RM(s); WM(r,t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 10; }
static void adc_r2b( void ) { UINT16 t; UINT8 v; IMMBYTE(v); t = RM(v) + RDB + GET_C; WRB(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 8; }
static void adc_i2a( void ) { UINT16 t; UINT8 v; IMMBYTE(v); t = v + RDA + GET_C; WRA(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void sbb_ir( void ) { UINT16 t; UINT8 r,i; IMMBYTE(i); IMMBYTE(r); t = RM(r) - i - ((pSR & SR_C) ? 0 : 1); WM(r,t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 9; }
static void adc_r2r( void ) { UINT16 t; UINT8 i,j; IMMBYTE(i); IMMBYTE(j); t = RM(i)+RM(j) + GET_C; WM(j,t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 10; }
static void dac_b2a( void ) { UINT16 t; t = bcd_add( RDA, RDB ); if (pSR & SR_C) t = bcd_add( t, 1 ); WRA(t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void dsb_b2a( void ) { UINT16 t; t = bcd_sub( RDA, RDB ); if( !(pSR & SR_C) ) t = bcd_sub( t, 1 ); WRA(t); CLR_NZC; SET_C8(~t); SET_N8(t); SET_Z8(t); tms7000_icount -= 7; }
static void inc_r( void ) { UINT16 t; UINT8 r; IMMBYTE(r); t = RM(r) + 1; WM( r, t ); CLR_NZC; SET_N8(t); SET_Z8(t); SET_C8(t); tms7000_icount -= 7; }
static void add_i2r( void ) { UINT16 t; UINT8 i,j; IMMBYTE(i); IMMBYTE(j); t = i+RM(j); WM(j,t); CLR_NZC; SET_C8(t); SET_N8(t); SET_Z8(t); tms7000_icount -= 9; }
static void rl_b( void ) { UINT16 t; t = RDB << 1; CLR_NZC; SET_C8(t); if( pSR & SR_C ) t |= 0x01; SET_N8(t); SET_Z8(t); WRB(t); tms7000_icount -= 5; }
static void cmp_rb( void ) { UINT16 t; UINT8 r; IMMBYTE(r); t = RDB - RM(r); CLR_NZC; SET_N8(t); SET_Z8(t); if( t==0 ) SETC; else SET_C8( ~t ); tms7000_icount -= 8; }
static void cmpa_inx( void ) { UINT16 t; PAIR i; IMMWORD( i ); t = RDA - RM(i.w.l + RDB); CLR_NZC; SET_N8(t); SET_Z8(t); if( t==0 ) SETC; else SET_C8( ~t ); tms7000_icount -= 14; }
static void cmp_ib( void ) { UINT16 t; UINT8 i; IMMBYTE(i); t = RDB - i; CLR_NZC; SET_N8(t); SET_Z8(t); if( t==0 ) SETC; else SET_C8( ~t ); tms7000_icount -= 7; }
void daa() { uint8_t m, l; uint16_t t, cf = 0; m = ra & 0xf0; l = ra & 0x0f; if (l > 0x09 || cch ) cf |= 0x06; if (m > 0x80 && l > 0x09 ) cf |= 0x60; if (m > 0x90 || ccc ) cf |= 0x60; t = cf + ra; SET_NZ8((uint8_t)t); SET_C8(t); PUT_V; ccv = 0; ra = (uint8_t)t; }
static void rl_r( void ) { UINT16 t; UINT8 r; IMMBYTE(r); t = RM(r) << 1; CLR_NZC; SET_C8(t); if( pSR & SR_C ) t |= 0x01; SET_N8(t); SET_Z8(t); WM(r,t); tms7000_icount -= 7; }
static void cmp_ir( void ) { UINT16 t; UINT8 i,r; IMMBYTE(i); IMMBYTE(r); t = RM(r) - i; CLR_NZC; SET_N8(t); SET_Z8(t); if( t==0 ) SETC; else SET_C8( ~t ); tms7000_icount -= 9; }