⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 6808ops.c

📁 这个是延伸mame的在wince平台下的游戏模拟器的代码
💻 C
📖 第 1 页 / 共 3 页
字号:

/*

HNZVC

? = undefined
* = affected
- = unaffected
0 = cleared
1 = set
# = ccr directly affected by instruction
@ = special - carry set if bit 7 is set

*/

static void illegal( void )
{
}

#if macintosh
#pragma mark ____0x____
#endif

/* $00 ILLEGAL */

/* $01 NOP */
INLINE void nop( void )
{
}

/* $02 ILLEGAL */

/* $03 ILLEGAL */

/* $04 LSRD inherent -0*-* */
INLINE void lsrd (void)
{
	word t;
	CLR_NZC; t = GETDREG; cc|=(t&0x0001);
	t>>=1; SET_Z16(t); SETDREG(t);
}

/* $05 ASLD inherent ?**** */
INLINE void asld (void)
{
	int r;
	word t;
	t = GETDREG; r=t<<1;
	CLR_NZVC; SET_FLAGS16(t,t,r);
	SETDREG(r);
}

/* $06 TAP inherent ##### */
INLINE void tap (void)
{
	cc=areg;
}

/* $07 TPA inherent ----- */
INLINE void tpa (void)
{
	areg=cc;
}

/* $08 INX inherent --*-- */
INLINE void inx (void)
{
	++xreg;
	CLR_Z; SET_Z16(xreg);
}

/* $09 DEX inherent --*-- */
INLINE void dex (void)
{
	--xreg;
	CLR_Z; SET_Z16(xreg);
}

/* $0a CLV */

/* $0b SEV */

/* $0c CLC */

/* $0d SEC */

/* $0e CLI */

/* $0f SEI */


#if macintosh
#pragma mark ____1x____
#endif

/* $10 SBA inherent -**** */
INLINE void sba (void)
{
	word t;
	t=areg-breg;
	CLR_NZVC; SET_FLAGS8(areg,breg,t);
	areg=t;
}

/* $11 CBA inherent -**** */
INLINE void cba (void)
{
	word t;
	t=areg-breg;
	CLR_NZVC; SET_FLAGS8(areg,breg,t);
}

/* $12 ILLEGAL */

/* $13 ILLEGAL */

/* $14 ILLEGAL */

/* $15 ILLEGAL */

/* $16 TAB inherent -**0- */
INLINE void tab (void)
{
	breg=areg;
	CLR_NZV; SET_NZ8(breg);
}

/* $17 TBA inherent -**0- */
INLINE void tba (void)
{
	areg=breg;
	CLR_NZV; SET_NZ8(areg);
}

/* $18 XGDX inherent ----- */ /* HD63701YO only */
INLINE void xgdx( void )
{
	word t = xreg;
	xreg = GETDREG;
	SETDREG(t);
}

/* $19 DAA inherent (areg) -**0* */
INLINE void daa( void )
{
	byte msn, lsn;
	word t, cf = 0;
	msn=areg & 0xf0; lsn=areg & 0x0f;
	if( lsn>0x09 || cc&0x20 ) cf |= 0x06;
	if( msn>0x80 && lsn>0x09 ) cf |= 0x60;
	if( msn>0x90 || cc&0x01 ) cf |= 0x60;
	t = cf + areg;
	CLR_NZV; /* keep carry from previous operation */
	SET_NZ8((byte)t); SET_C8(t);
	areg = t;
}

/* $1a ILLEGAL */ /* SLEEP on the HD63701YO - no info available on the opcode! */

/* $1b ABA inherent ***** */
INLINE void aba (void)
{
	word t;
	t=areg+breg;
	CLR_HNZVC; SET_FLAGS8(areg,breg,t); SET_H(areg,breg,t);
	areg=t;
}

/* $1c ILLEGAL */

/* $1d ILLEGAL */

/* $1e ILLEGAL */

/* $1f ILLEGAL */

#if macintosh
#pragma mark ____2x____
#endif

/* $20 BRA relative ----- */
INLINE void bra( void )
{
	byte t;
	IMMBYTE(t);pcreg+=SIGNED(t);change_pc(pcreg);
	/* speed up busy loops */
	if (t==0xfe) m6808_ICount = 0;
}

/* $21 BRN relative ----- */
INLINE void brn( void )
{
	byte t;
	IMMBYTE(t);
}

/* $22 BHI relative ----- */
INLINE void bhi( void )
{
	byte t;
	BRANCH(!(cc&0x05));
}

/* $23 BLS relative ----- */
INLINE void bls( void )
{
	byte t;
	BRANCH(cc&0x05);
}

/* $24 BCC relative ----- */
INLINE void bcc( void )
{
	byte t;
	BRANCH(!(cc&0x01));
}

/* $25 BCS relative ----- */
INLINE void bcs( void )
{
	byte t;
	BRANCH(cc&0x01);
}

/* $26 BNE relative ----- */
INLINE void bne( void )
{
	byte t;
	BRANCH(!(cc&0x04));
}

/* $27 BEQ relative ----- */
INLINE void beq( void )
{
	byte t;
	BRANCH(cc&0x04);
}

/* $28 BVC relative ----- */
INLINE void bvc( void )
{
	byte t;
	BRANCH(!(cc&0x02));
}

/* $29 BVS relative ----- */
INLINE void bvs( void )
{
	byte t;
	BRANCH(cc&0x02);
}

/* $2a BPL relative ----- */
INLINE void bpl( void )
{
	byte t;
	BRANCH(!(cc&0x08));
}

/* $2b BMI relative ----- */
INLINE void bmi( void )
{
	byte t;
	BRANCH(cc&0x08);
}

/* $2c BGE relative ----- */
INLINE void bge( void )
{
	byte t;
	BRANCH(!NXORV);
}

/* $2d BLT relative ----- */
INLINE void blt( void )
{
	byte t;
	BRANCH(NXORV);
}

/* $2e BGT relative ----- */
INLINE void bgt( void )
{
	byte t;
	BRANCH(!(NXORV||cc&0x04));
}

/* $2f BLE relative ----- */
INLINE void ble( void )
{
	byte t;
	BRANCH(NXORV||cc&0x04);
}


#if macintosh
#pragma mark ____3x____
#endif

/* $30 TSX inherent ----- */
INLINE void tsx (void)
{
	xreg=( sreg + 1 );
}

/* $31 INS inherent ----- */
INLINE void ins (void)
{
	++sreg;
}

/* $32 PULA inherent ----- */
INLINE void pula (void)
{
	PULLBYTE(areg);
}

/* $33 PULB inherent ----- */
INLINE void pulb (void)
{
	PULLBYTE(breg);
}

/* $34 DES inherent ----- */
INLINE void des (void)
{
	--sreg;
}

/* $35 TXS inherent ----- */
INLINE void txs (void)
{
	sreg=( xreg - 1 );
}

/* $36 PSHA inherent ----- */
INLINE void psha (void)
{
	PUSHBYTE(areg);
}

/* $37 PSHB inherent ----- */
INLINE void pshb (void)
{
	PUSHBYTE(breg);
}

/* $38 PULX inherent ----- */
INLINE void pulx (void)
{
	PULLWORD(xreg);
}

/* $39 RTS inherent ----- */
INLINE void rts( void )
{
	PULLWORD(pcreg); change_pc(pcreg);
}

/* $3a ABX inherent ----- */
INLINE void abx( void )
{
	xreg += breg;
}

/* $3b RTI inherent ##### */
INLINE void rti( void )
{
	PULLBYTE(cc);
	PULLBYTE(areg);
	PULLBYTE(breg);
	PULLWORD(xreg);
	PULLWORD(pcreg);change_pc(pcreg);
}

/* $3c PSHX inherent ----- */
INLINE void pshx (void)
{
	PUSHWORD(xreg);
}

/* $3d MUL inherent --*-@ */
INLINE void mul( void )
{
	word t;
	t=areg*breg;
	CLR_ZC; SET_Z16(t); if(t&0x80) SEC;
	SETDREG(t);
}

/* $3e WAI inherent ----- */
INLINE void wai( void )
{
	/* WAI should stack the entire machine state on the hardware stack,
		then wait for an interrupt. We just wait for an IRQ. */
	m6808_ICount = 0;
	pending_interrupts |= M6808_WAI;
}

/* $3f SWI absolute indirect ----- */
INLINE void swi( void )
{
	PUSHWORD(pcreg);
	PUSHWORD(xreg);
	PUSHBYTE(breg);
	PUSHBYTE(areg);
	PUSHBYTE(cc);
	SEI;
	pcreg = M_RDMEM_WORD(0xfffa);change_pc(pcreg);
}

#if macintosh
#pragma mark ____4x____
#endif

/* $40 NEGA inherent ?**** */
INLINE void nega( void )
{
	word r;
	r=-areg;
	CLR_NZVC; SET_FLAGS8(0,areg,r);
	areg=r;
}

/* $41 ILLEGAL */

/* $42 ILLEGAL */

/* $43 COMA inherent -**01 */
INLINE void coma( void )
{
	areg = ~areg;
	CLR_NZV; SET_NZ8(areg); SEC;
}

/* $44 LSRA inherent -0*-* */
INLINE void lsra( void )
{
	CLR_NZC; cc|=(areg&0x01);
	areg>>=1; SET_Z8(areg);
}

/* $45 ILLEGAL */

/* $46 RORA inherent -**-* */
INLINE void rora( void )
{
	byte r;
	r=(cc&0x01)<<7;
	CLR_NZC; cc|=(areg&0x01);
	r |= areg>>1; SET_NZ8(r);
	areg=r;
}

/* $47 ASRA inherent ?**-* */
INLINE void asra( void )
{
	CLR_NZC; cc|=(areg&0x01);
	areg>>=1; areg|=((areg&0x40)<<1);
	SET_NZ8(areg);
}

/* $48 ASLA inherent ?**** */
INLINE void asla( void )
{
	word r;
	r=areg<<1;
	CLR_NZVC; SET_FLAGS8(areg,areg,r);
	areg=r;
}

/* $49 ROLA inherent -**** */
INLINE void rola( void )
{
	word t,r;
	t = areg; r = cc&0x01; r |= t<<1;
	CLR_NZVC; SET_FLAGS8(t,t,r);
	areg=r;
}

/* $4a DECA inherent -***- */
INLINE void deca( void )
{
	--areg;
	CLR_NZV; SET_FLAGS8D(areg);
}

/* $4b ILLEGAL */

/* $4c INCA inherent -***- */
INLINE void inca( void )
{
	++areg;
	CLR_NZV; SET_FLAGS8I(areg);
}

/* $4d TSTA inherent -**0- */
INLINE void tsta( void )
{
	CLR_NZV; SET_NZ8(areg);
}

/* $4e ILLEGAL */

/* $4f CLRA inherent -0100 */
INLINE void clra( void )
{
	areg=0;
	CLR_NZVC; SEZ;
}


#if macintosh
#pragma mark ____5x____
#endif


/* $50 NEGB inherent ?**** */
INLINE void negb( void )
{
	word r;
	r=-breg;
	CLR_NZVC; SET_FLAGS8(0,breg,r);
	breg=r;
}

/* $51 ILLEGAL */

/* $52 ILLEGAL */

/* $53 COMB inherent -**01 */
INLINE void comb( void )
{
	breg = ~breg;
	CLR_NZV; SET_NZ8(breg); SEC;
}

/* $54 LSRB inherent -0*-* */
INLINE void lsrb( void )
{
	CLR_NZC; cc|=(breg&0x01);
	breg>>=1; SET_Z8(breg);
}

/* $55 ILLEGAL */

/* $56 RORB inherent -**-* */
INLINE void rorb( void )
{
	byte r;
	r=(cc&0x01)<<7;
	CLR_NZC; cc|=(breg&0x01);
	r |= breg>>1; SET_NZ8(r);
	breg=r;
}

/* $57 ASRB inherent ?**-* */
INLINE void asrb( void )
{
	CLR_NZC; cc|=(breg&0x01);
	breg>>=1; breg|=((breg&0x40)<<1);
	SET_NZ8(breg);
}

/* $58 ASLB inherent ?**** */
INLINE void aslb( void )
{
	word r;
	r=breg<<1;
	CLR_NZVC; SET_FLAGS8(breg,breg,r);
	breg=r;
}

/* $59 ROLB inherent -**** */
INLINE void rolb( void )
{
	word t,r;
	t = breg; r = cc&0x01; r |= t<<1;
	CLR_NZVC; SET_FLAGS8(t,t,r);
	breg=r;
}

/* $5a DECB inherent -***- */
INLINE void decb( void )
{
	--breg;
	CLR_NZV; SET_FLAGS8D(breg);
}

/* $5b ILLEGAL */

/* $5c INCB inherent -***- */
INLINE void incb( void )
{
	++breg;
	CLR_NZV; SET_FLAGS8I(breg);
}

/* $5d TSTB inherent -**0- */
INLINE void tstb( void )
{
	CLR_NZV; SET_NZ8(breg);
}

/* $5e ILLEGAL */

/* $5f CLRB inherent -0100 */
INLINE void clrb( void )
{
	breg=0;
	CLR_NZVC; SEZ;
}

#if macintosh
#pragma mark ____6x____
#endif

/* $60 NEG indexed ?**** */
INLINE void neg_ix( void )
{
	word r,t;
	IDXBYTE(t); r=-t;
	CLR_NZVC; SET_FLAGS8(0,t,r);
	M_WRMEM(eaddr,r);
}

/* $61 AIM --**0- */ /* HD63701YO only */
INLINE void aim_ix( void )
{
	byte t, r;
	IMMBYTE(t);
	IDXBYTE(r);
	r &= t;
	CLR_NZV; SET_NZ8(r);
	M_WRMEM(eaddr,r);
}

/* $62 OIM --**0- */ /* HD63701YO only */
INLINE void oim_ix( void )
{
	byte t, r;
	IMMBYTE(t);
	IDXBYTE(r);
	r |= t;
	CLR_NZV; SET_NZ8(r);
	M_WRMEM(eaddr,r);
}

/* $63 COM indexed -**01 */
INLINE void com_ix( void )
{
	byte t;
	IDXBYTE(t); t = ~t;
	CLR_NZV; SET_NZ8(t); SEC;
	M_WRMEM(eaddr,t);
}

/* $64 LSR indexed -0*-* */
INLINE void lsr_ix( void )
{
	byte t;
	IDXBYTE(t); CLR_NZC; cc|=(t&0x01);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -