📄 sa1ops.s
字号:
/*** Renesas SH assembler ***************************************************** SH assembler code partly based on x86 assembler code (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se)******************************************************************************//****************************************************************************** Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. (c) Copyright 1996 - 2003 Gary Henderson (gary.henderson@ntlworld.com) and Jerremy Koot (jkoot@snes9x.com) (c) Copyright 2002 - 2003 Matthew Kendora and Brad Jorsch (anomie@users.sourceforge.net) C4 x86 assembler and some C emulation code (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), _Demo_ (_demo_@zsnes.com), and Nach (n-a-c-h@users.sourceforge.net) C4 C++ code (c) Copyright 2003 Brad Jorsch DSP-1 emulator code (c) Copyright 1998 - 2003 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, John Weidman (jweidman@slip.net), neviksti (neviksti@hotmail.com), and Kris Bleakley (stinkfish@bigpond.com) DSP-2 emulator code (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and Lord Nightmare (lord_nightmare@users.sourceforge.net OBC1 emulator code (c) Copyright 2001 - 2003 zsKnight, pagefault (pagefault@zsnes.com) Ported from x86 assembler to C by sanmaiwashi SPC7110 and RTC C++ emulator code (c) Copyright 2002 Matthew Kendora with research by zsKnight, John Weidman, and Dark Force S-RTC C emulator code (c) Copyright 2001 John Weidman Super FX x86 assembler emulator code (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault Super FX C emulator code (c) Copyright 1997 - 1999 Ivar and Gary Henderson. Specific ports contains the works of other authors. See headers in individual files. Snes9x homepage: http://www.snes9x.com Permission to use, copy, modify and distribute Snes9x in both binary and source form, for non-commercial purposes, is hereby granted without fee, providing that this license information and copyright notice appear with all copies and any derived work. This software is provided 'as-is', without any express or implied warranty. In no event shall the authors be held liable for any damages arising from the use of this software. Snes9x is freeware for PERSONAL USE only. Commercial users should seek permission of the copyright holders first. Commercial use includes charging money for Snes9x or software derived from Snes9x. The copyright holders request that bug fixes and improvements to the code should be forwarded to them so everyone can benefit from the modifications in future versions. Super NES and Super Nintendo Entertainment System are trademarks of Nintendo Co., Limited and its subsidiary companies.******************************************************************************/#define Registers SA1Registers#undef VAR_CYCLES#include "sa1struc.h"#if 0#define PCS SA1PCS#define PB SA1PB#define PP SA1PP#define PL SA1PL#define PH SA1PH#define AA SA1AA#define AL SA1AL#define AH SA1AH#define DD SA1DD#define DL SA1DL#define DH SA1DH#define SS SA1SS#define SL SA1SL#define SH SA1SH#define XX SA1XX#define XL SA1XL#define XH SA1XH#define YY SA1YY#define YL SA1YL#define YH SA1YH#endif#undef _Carry#define _Carry SA1_Carry#undef _Zero#define _Zero SA1_Zero#undef _Negative#define _Negative SA1_Negative#undef _Overflow#define _Overflow SA1_Overflow#include "sa1addr.h"#include "sa1ops.h"#include "sa1gs.S"#ifndef SA1TRACE#undef OOBTRACE#endif .data.zzz:.string "*** IRQ\n".text.macro call_S9xSA1GetByte mov.l S9xGetByte,r3 jsr @r3 nop.endm.macro call_S9xSA1GetWord mov.l S9xGetWord,r3 jsr @r3 nop.endm .globl _S9xSA1MainLoop_S9xSA1MainLoop: mov.l r14,@-r15 sts.l pr,@-r15 mov.l r13,@-r15 mov.l r12,@-r15 mov.l r11,@-r15 mov.l r10,@-r15 mov.l r9,@-r15 mov.l r8,@-r15 SETUP_PREDEF LOAD_REGISTERS mov.w .nIRQ_PENDING_FLAG,r2 mov.l SA1Flags,r1 tst r2,r1 bt .nosa1irq2 mov.b SA1IRQActive,r0 not r2,r2 tst r0,r0 bt/s .nosa1irq1 and r2,r1 mov #IRQ,r0 tst r0,FLAGS bf .nosa1irq2 mov.b WaitingForInterrupt,r0 tst r0,r0 bt .nosa1wait mov #0,r0 add #1,PC mov.b r0,WaitingForInterrupt.nosa1wait: mov.l S9xOpcode_IRQ,r3 jsr @r3 nop bra .nosa1irq2 nop.nosa1irq1: mov.l r1,SA1Flags.nosa1irq2: mov #3,r1.instruction_loop: mov.b SA1Executing,r0 tst r0,r0 bt .exit mov.l r1,@-r15#ifdef DEBUGGER testb $TRACE_FLAG, SA1Flags jz .NO_SA1_TRACE STORE_REGISTERS ccall S9xSA1Trace LOAD_REGISTERS.NO_SA1_TRACE:#endif#ifdef OOBTRACE SA1SAVE_CYCLES PUSH_REGISTERS S9xSA1PackStatus OOBTrace mov.l SA1PCBase,r0 mov PC,r4 sub r0,r4 mov A,r0 mov.w r0,AA mov.l SA1ShiftedPB,r0 add r0,r4 mov.l .oobtrace,r0 mov FLAGS,r6 jsr @r0 mov r11,r5 POP_REGISTERS SA1LOAD_CYCLES#endif#ifdef CPU_SHUTDOWN mov.l PC, SA1PCAtOpcodeStart#endif mov.b @PC+,r0 extu.b r0,r0 mov.l SA1Opcodes,r2 shll2 r0 mov.l @(r0,r2),r0 jmp @r0 nop.globl S9xSA1MainAsmLoopS9xSA1MainAsmLoop: mov.l @r15+,r1 dt r1 bf .instruction_loop.exit: STORE_REGISTERS mov.l @r15+,r8 mov.l @r15+,r9 mov.l @r15+,r10 mov.l @r15+,r11 mov.l @r15+,r12 mov.l @r15+,r13 lds.l @r15+,pr rts mov.l @r15+,r14.nIRQ_PENDING_FLAG: .word IRQ_PENDING_FLAG MISC#ifdef OOBTRACE .align 2.oobtrace: .long __Z8oobtraceiP10SRegistersi#endif /* ADC */Op69M1: Immediate8 ADC Adc8 IMM8Op69M0: Immediate16 ADC2 Adc16 IMM16Op65M1: Direct8 ADC2 call_S9xSA1GetByte Adc8 DIR8Op65M0: Direct8 ADC call_S9xSA1GetWord Adc16 DIR16 Op75M1: DirectIndexedX8 ADC call_S9xSA1GetByte Adc8 DIX8Op75M0: DirectIndexedX8 ADC2 call_S9xSA1GetWord Adc16 DIX16Op72M1: DirectIndirect8 ADC call_S9xSA1GetByte Adc8 DI8Op72M0: DirectIndirect8 ADC2 call_S9XSA1GetWord Adc16 DI16Op61M1: DirectIndexedIndirect8 ADC call_S9XSA1GetByte Adc8 DII8Op61M0: DirectIndexedIndirect8 ADC2 call_S9XSA1GetWord Adc16 DII16Op71M1: DirectIndirectIndexed8 ADC call_S9XSA1GetByte Adc8 DIIY8Op71M0: DirectIndirectIndexed8 ADC2 call_S9XSA1GetWord Adc16 DIIY16Op67M1: DirectIndirectLong8 ADC call_S9XSA1GetByte Adc8 DIL8Op67M0: DirectIndirectLong8 ADC2 call_S9XSA1GetWord Adc16 DIL16Op77M1: DirectIndirectIndexedLong8 ADC call_S9XSA1GetByte Adc8 DIIL8Op77M0: DirectIndirectIndexedLong8 ADC2 call_S9XSA1GetWord Adc16 DIIL8Op6DM1: Absolute8 ADC call_S9XSA1GetByte Adc8 ABS8Op6DM0: Absolute8 ADC2 call_S9XSA1GetWord Adc16 ABS16Op7DM1: AbsoluteIndexedX8 ADC call_S9XSA1GetByte Adc8 ABSX8Op7DM0: AbsoluteIndexedX8 ADC2 call_S9XSA1GetWord Adc16 ABSX16Op79M1: AbsoluteIndexedY8 ADC call_S9XSA1GetByte Adc8 ABSY8Op79M0: AbsoluteIndexedY8 ADC2 call_S9XSA1GetWord Adc16 ABSY16Op6FM1: AbsoluteLong8 ADC call_S9XSA1GetByte Adc8 ABSL8Op6FM0: AbsoluteLong8 ADC2 call_S9XSA1GetWord Adc16 ABSL16Op7FM1: AbsoluteLongIndexedX8 ADC call_S9XSA1GetByte Adc8 ALX8Op7FM0: AbsoluteLongIndexedX8 ADC2 call_S9XSA1GetWord Adc16 ALX16Op63M1: StackRelative8 ADC call_S9XSA1GetByte Adc8 SREL8Op63M0: StackRelative8 ADC2 call_S9XSA1GetWord Adc16 SREL16Op73M1: StackRelativeIndirectIndexed8 ADC call_S9XSA1GetByte Adc8 SRII8Op73M0: StackRelativeIndirectIndexed8 ADC2 call_S9XSA1GetWord Adc16 SRII16/* AND */Op29M1: Immediate8 AND And8 IMM8Op29M0: Immediate16 AND And16 IMM16Op25M1: Direct8 AND call_S9XSA1GetByte And8 DIR8Op25M0: Direct8 AND2 call_S9XSA1GetWord And16 DIR16Op35M1: DirectIndexedX8 AND call_S9XSA1GetByte And8 DIX8Op35M0: DirectIndexedX8 AND2 call_S9XSA1GetWord And16 DIX16Op32M1: DirectIndirect8 AND call_S9XSA1GetByte And8 DI8Op32M0: DirectIndirect8 AND2 call_S9XSA1GetWord And16 DI16Op21M1: DirectIndexedIndirect8 AND call_S9XSA1GetByte And8 DII8Op21M0: DirectIndexedIndirect8 AND2 call_S9XSA1GetWord And16 DII16Op31M1: DirectIndirectIndexed8 AND call_S9XSA1GetByte And8 DIIY8Op31M0: DirectIndirectIndexed8 AND2 call_S9XSA1GetWord And16 DIIY16Op27M1: DirectIndirectLong8 AND call_S9XSA1GetByte And8 DIL8Op27M0: DirectIndirectLong8 AND2 call_S9XSA1GetWord And16 DIL16Op37M1: DirectIndirectIndexedLong8 AND call_S9XSA1GetByte And8 DIIL8Op37M0: DirectIndirectIndexedLong8 AND2 call_S9XSA1GetWord And16 DIIL16Op2DM1: Absolute8 AND call_S9XSA1GetByte And8 ABS8Op2DM0: Absolute8 AND2 call_S9XSA1GetWord And16 ABS16Op3DM1: AbsoluteIndexedX8 AND call_S9XSA1GetByte And8 ABSX8Op3DM0: AbsoluteIndexedX8 AND2 call_S9XSA1GetWord And16 ABSX16Op39M1: AbsoluteIndexedY8 AND call_S9XSA1GetByte And8 ABSY8Op39M0: AbsoluteIndexedY8 AND2 call_S9XSA1GetWord And16 ABSY16Op2FM1: AbsoluteLong8 AND call_S9XSA1GetByte And8 ABSL8Op2FM0: AbsoluteLong8 AND2 call_S9XSA1GetWord And16 ABSL16Op3FM1: AbsoluteLongIndexedX8 AND call_S9XSA1GetByte And8 ALX8Op3FM0: AbsoluteLongIndexedX8 AND2 call_S9XSA1GetWord And16 ALX16Op23M1: StackRelative8 AND call_S9XSA1GetByte And8 SREL8Op23M0: StackRelative8 AND2 call_S9XSA1GetWord And16 SREL16Op33M1: StackRelativeIndirectIndexed8 AND call_S9XSA1GetByte And8 SRII8Op33M0: StackRelativeIndirectIndexed8 AND2 call_S9XSA1GetWord And16 SRII16/* ASL */Op0AM1: extu.b A,r1 sub r1,A shll r1 extu.b r1,r2 mov #Carry,r0 or r2,A cmp/eq r1,r2 bf/s .Asl8Carry or r0,FLAGS add #-Carry,FLAGS.Asl8Carry: SetZNjmp AOp0AM0: extu.w A,r1 shll r1 mov #Carry,r0 extu.w r1,A cmp/eq r1,A bf/s .Asl16Carry or r0,FLAGS add #-Carry,FLAGS.Asl16Carry: Set16ZNjmp A Op06M1: Direct8 ASL Asl8 DIR8Op06M0: Direct8 ASL2 Asl16 DIR16Op16M1: DirectIndexedX8 ASL Asl8 DIXOp16M0: DirectIndexedX8 ASL2 Asl16 DIXOp0EM1: Absolute8 ASL Asl8 ABSOp0EM0: Absolute8 ASL2 Asl16 ABSOp1EM1: AbsoluteIndexedX8 ASL Asl8 ABSXOp1EM0: AbsoluteIndexedX8 ASL2 Asl16 ABSX/* BIT */Op89M1: Immediate8 BIT and A, r0 extu.w r7,r3 sub r3,r7 jmp @r13 or r0,r7Op89M0: Immediate16 BIT and A, r0 extu.w r7,r3 sub r3,r7 jmp @r13 or r0,r7Op24M1: Direct8 BIT Bit8 DIROp24M0: Direct8 BIT Bit16 DIROp34M1: DirectIndexedX8 BIT Bit8 DIXOp34M0: DirectIndexedX8 BIT2 Bit16 DIXOp2CM1: Absolute8 BIT Bit8 ABSOp2CM0: Absolute8 BIT2 Bit16 ABSOp3CM1: AbsoluteIndexedX8 BIT Bit8 ABSXOp3CM0: AbsoluteIndexedX8 BIT2 Bit16 ABSX/* CMP */OpC9M1: Immediate8 CMP Cmp8 IMMOpC9M0: Immediate16 CMP Cmp16 IMMOpC5M1: Direct8 CMP call_S9XSA1GetByte Cmp8 DIROpC5M0: Direct8 CMP2 call_S9XSA1GetWord Cmp16 DIROpD5M1: DirectIndexedX8 CMP call_S9XSA1GetByte Cmp8 DIXOpD5M0: DirectIndexedX8 CMP2 call_S9XSA1GetWord Cmp16 DIXOpD2M1: DirectIndirect8 CMP call_S9XSA1GetByte Cmp8 DIOpD2M0: DirectIndirect8 CMP2 call_S9XSA1GetWord Cmp16 DIOpC1M1: DirectIndexedIndirect8 CMP call_S9XSA1GetByte Cmp8 DIIOpC1M0: DirectIndexedIndirect8 CMP2 call_S9XSA1GetWord Cmp16 DIIOpD1M1: DirectIndirectIndexed8 CMP call_S9XSA1GetByte Cmp8 DIIYOpD1M0: DirectIndirectIndexed8 CMP2 call_S9XSA1GetWord Cmp16 DIIYOpC7M1: DirectIndirectLong8 CMP call_S9XSA1GetByte Cmp8 DILOpC7M0: DirectIndirectLong8 CMP2 call_S9XSA1GetWord Cmp16 DILOpD7M1: DirectIndirectIndexedLong8 CMP call_S9XSA1GetByte Cmp8 DIILOpD7M0: DirectIndirectIndexedLong8 CMP2 call_S9XSA1GetWord Cmp16 DIILOpCDM1: Absolute8 CMP call_S9XSA1GetByte Cmp8 ABSOpCDM0: Absolute8 CMP2 call_S9XSA1GetWord Cmp16 ABSOpDDM1: AbsoluteIndexedX8 CMP call_S9XSA1GetByte Cmp8 ABSXOpDDM0: AbsoluteIndexedX8 CMP2 call_S9XSA1GetWord Cmp16 ABSXOpD9M1: AbsoluteIndexedY8 CMP call_S9XSA1GetByte Cmp8 ABSYOpD9M0: AbsoluteIndexedY8 CMP2 call_S9XSA1GetWord Cmp16 ABSYOpCFM1: AbsoluteLong8 CMP call_S9XSA1GetByte Cmp8 ABSLOpCFM0: AbsoluteLong8 CMP2 call_S9XSA1GetWord Cmp16 ABSLOpDFM1: AbsoluteLongIndexedX8 CMP call_S9XSA1GetByte Cmp8 ALXOpDFM0: AbsoluteLongIndexedX8 CMP2 call_S9XSA1GetWord Cmp16 ALXOpC3M1: StackRelative8 CMP call_S9XSA1GetByte Cmp8 SRELOpC3M0: StackRelative8 CMP2 call_S9XSA1GetWord Cmp16 SRELOpD3M1: StackRelativeIndirectIndexed8 CMP call_S9XSA1GetByte Cmp8 SRIIOpD3M0: StackRelativeIndirectIndexed8 CMP2 call_S9XSA1GetWord Cmp16 SRII/* CPX */OpE0X1: Immediate8 CPX Cpx8 IMMOpE0X0: Immediate16 CPX Cpx16 IMMOpE4X1: Direct8 CPX call_S9XSA1GetByte Cpx8 DIROpE4X0: Direct8 CPX2 call_S9XSA1GetWord Cpx16 DIROpECX1: Absolute8 CPX call_S9XSA1GetByte Cpx8 ABSOpECX0: Absolute8 CPX2 call_S9XSA1GetWord Cpx16 ABS/* CPY */OpC0X1: Immediate8 CPY Cpy8 IMMOpC0X0: Immediate16 CPY Cpy16 IMMOpC4X1: Direct8 CPY call_S9XSA1GetByte Cpy8 DIROpC4X0: Direct8 CPY2 call_S9XSA1GetWord Cpy16 DIROpCCX1: Absolute8 CPY call_S9XSA1GetByte Cpy8 ABSOpCCX0: Absolute8 CPY2 call_S9XSA1GetWord Cpy16 ABS/* DEC */Op3AM1: extu.b A,r0 sub r0,A add #-1,r0 extu.b r0,r0 or r0,A SetZNjmp r0Op3AM0: add #-1,A extu.w A,A Set16ZNjmp AOpC6M1: Direct8 DEC Dec8 DIROpC6M0: Direct8 DEC2 Dec16 DIROpD6M1: DirectIndexedX8 DEC Dec8 DIXOpD6M0: DirectIndexedX8 DEC2 Dec16 DIXOpCEM1: Absolute8 DEC Dec8 ABSOpCEM0: Absolute8 DEC2 Dec16 ABSOpDEM1: AbsoluteIndexedX8 DEC Dec8 ABSXOpDEM0: AbsoluteIndexedX8 DEC2 Dec16 ABSX/* EOR */Op49M1: Immediate8 EOR Eor8 IMMOp49M0: Immediate16 EOR Eor16 IMMOp45M1: Direct8 EOR call_S9XSA1GetByte Eor8 DIROp45M0: Direct8 EOR2 call_S9XSA1GetWord Eor16 DIROp55M1: DirectIndexedX8 EOR call_S9XSA1GetByte Eor8 DIXOp55M0: DirectIndexedX8 EOR2 call_S9XSA1GetWord Eor16 DIXOp52M1: DirectIndirect8 EOR call_S9XSA1GetByte Eor8 DIOp52M0: DirectIndirect8 EOR2 call_S9XSA1GetWord Eor16 DIOp41M1: DirectIndexedIndirect8 EOR call_S9XSA1GetByte Eor8 DIIOp41M0: DirectIndexedIndirect8 EOR2 call_S9XSA1GetWord Eor16 DIIOp51M1: DirectIndirectIndexed8 EOR call_S9XSA1GetByte Eor8 DIIYOp51M0: DirectIndirectIndexed8 EOR2 call_S9XSA1GetWord Eor16 DIIYOp47M1: DirectIndirectLong8 EOR call_S9XSA1GetByte Eor8 DILOp47M0: DirectIndirectLong8 EOR2 call_S9XSA1GetWord Eor16 DILOp57M1: DirectIndirectIndexedLong8 EOR call_S9XSA1GetByte Eor8 DIILOp57M0: DirectIndirectIndexedLong8 EOR2 call_S9XSA1GetWord Eor16 DIILOp4DM1: Absolute8 EOR call_S9XSA1GetByte Eor8 ABSOp4DM0: Absolute8 EOR2 call_S9XSA1GetWord Eor16 ABSOp5DM1: AbsoluteIndexedX8 EOR call_S9XSA1GetByte Eor8 ABSXOp5DM0: AbsoluteIndexedX8 EOR2 call_S9XSA1GetWord Eor16 ABSXOp59M1: AbsoluteIndexedY8 EOR call_S9XSA1GetByte Eor8 ABSYOp59M0: AbsoluteIndexedY8 EOR2 call_S9XSA1GetWord Eor16 ABSYOp4FM1: AbsoluteLong8 EOR call_S9XSA1GetByte Eor8 ABSLOp4FM0: AbsoluteLong8 EOR2 call_S9XSA1GetWord Eor16 ABSLOp5FM1: AbsoluteLongIndexedX8 EOR call_S9XSA1GetByte Eor8 ALXOp5FM0: AbsoluteLongIndexedX8 EOR2 call_S9XSA1GetWord Eor16 ALXOp43M1: StackRelative8 EOR call_S9XSA1GetByte Eor8 SRELOp43M0: StackRelative8 EOR2 call_S9XSA1GetWord Eor16 SRELOp53M1: StackRelativeIndirectIndexed8 EOR call_S9XSA1GetByte Eor8 SRIIOp53M0: StackRelativeIndirectIndexed8 EOR2 call_S9XSA1GetWord Eor16 SRII/* INC */Op1AM1: extu.b A,r0 sub r0,A add #1,r0 extu.b r0,r0 or r0,A SetZNjmp r0Op1AM0: add #1,A extu.w A,A Set16ZNjmp A OpE6M1: Direct8 INC Inc8 DIROpE6M0: Direct8 INC2 Inc16 DIR OpF6M1: DirectIndexedX8 INC Inc8 DIXOpF6M0: DirectIndexedX8 INC2 Inc16 DIXOpEEM1: Absolute8 INC Inc8 ABSOpEEM0: Absolute8 INC2 Inc16 ABS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -