package miggy.cpupoet;

import junit.framework.TestCase;

public class InstructionTests extends TestCase {
	static {
		MacroPLA.decode(0);
	}

	public void testBCD() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("ABCD");
		test.executeBinTest("NBCD");
		test.executeBinTest("SBCD");
	}

	public void testMUL() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("MULU");
		test.executeBinTest("MULS");
	}

	public void testADD() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("ADD.b");
		test.executeBinTest("ADD.w");
		test.executeBinTest("ADD.l");
		test.executeBinTest("ADDA.w");
		test.executeBinTest("ADDA.l");
		test.executeBinTest("ADDX.b");
		test.executeBinTest("ADDX.w");
		test.executeBinTest("ADDX.l");
	}

	public void testAND() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("AND.b");
		test.executeBinTest("AND.w");
		test.executeBinTest("AND.l");

		test.executeBinTest("ANDItoCCR");
	}

	public void testOR() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("OR.b");
		test.executeBinTest("OR.w");
		test.executeBinTest("OR.l");

		test.executeBinTest("ORItoCCR");
	}

	public void testEOR() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("EOR.b");
		test.executeBinTest("EOR.w");
		test.executeBinTest("EOR.l");

		test.executeBinTest("NOT.b");
		test.executeBinTest("NOT.w");
		test.executeBinTest("NOT.l");

		test.executeBinTest("EORItoCCR");
	}

	public void testBIT() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("BCHG");
		test.executeBinTest("BCLR");
		test.executeBinTest("BSET");
		test.executeBinTest("BTST");
	}

	public void testShift() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("ASL.b");
		test.executeBinTest("ASL.w");
		test.executeBinTest("ASL.l");
		test.executeBinTest("ASR.b");
		test.executeBinTest("ASR.w");
		test.executeBinTest("ASR.l");
		test.executeBinTest("LSL.b");
		test.executeBinTest("LSL.w");
		test.executeBinTest("LSL.l");
		test.executeBinTest("LSR.b");
		test.executeBinTest("LSR.w");
		test.executeBinTest("LSR.l");
		test.executeBinTest("ROL.b");
		test.executeBinTest("ROL.w");
		test.executeBinTest("ROL.l");
		test.executeBinTest("ROR.b");
		test.executeBinTest("ROR.w");
		test.executeBinTest("ROR.l");
	}

	public void testBcc() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("Bcc");
		test.executeBinTest("BSR");
	}

	public void testDBcc() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("DBcc");
	}

	public void testMisc() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("CHK");
		test.executeBinTest("NOP");
		test.executeBinTest("EXG");
		test.executeBinTest("SWAP");
		test.executeBinTest("EXT.w");
		test.executeBinTest("EXT.l");
		test.executeBinTest("LEA");
		test.executeBinTest("PEA");
		test.executeBinTest("RTS");
		test.executeBinTest("RTR");
		test.executeBinTest("LINK");
		test.executeBinTest("UNLINK");
		test.executeBinTest("Scc");
		test.executeBinTest("TST.b");
		test.executeBinTest("TST.w");
		test.executeBinTest("TST.l");
		test.executeBinTest("CLR.b");
		test.executeBinTest("CLR.w");
		test.executeBinTest("CLR.l");
		test.executeBinTest("TRAP");
		test.executeBinTest("TRAPV");
		test.executeBinTest("RESET");
	}

	public void testJMP() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("JMP");
		test.executeBinTest("JSR");
	}

	public void testSUB() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("SUB.b");
		test.executeBinTest("SUB.w");
		test.executeBinTest("SUB.l");
		test.executeBinTest("SUBA.w");
		test.executeBinTest("SUBA.l");
		test.executeBinTest("CMP.b");
		test.executeBinTest("CMP.w");
		test.executeBinTest("CMP.l");
		test.executeBinTest("CMPA.w");
		test.executeBinTest("CMPA.l");
		test.executeBinTest("SUBX.b");
		test.executeBinTest("SUBX.w");
		test.executeBinTest("SUBX.l");
		test.executeBinTest("NEG.b");
		test.executeBinTest("NEG.w");
		test.executeBinTest("NEG.l");
		test.executeBinTest("NEGX.b");
		test.executeBinTest("NEGX.w");
		test.executeBinTest("NEGX.l");
	}

	public void testMOVE() {
		CoreTest test = new CoreTest(0xffffff + 1, true);

		test.executeBinTest("MOVE.b");
		test.executeBinTest("MOVE.w");
		test.executeBinTest("MOVE.l");
		test.executeBinTest("MOVE.q");

		test.executeBinTest("MOVEP.w");
		test.executeBinTest("MOVEP.l");

		test.executeBinTest("MOVEA.w");
		test.executeBinTest("MOVEA.l");

		test.executeBinTest("MOVEM.w");
		test.executeBinTest("MOVEM.l");

		test.executeBinTest("MOVEtoCCR");
		test.executeBinTest("MOVEtoUSP");
		test.executeBinTest("MOVEfromUSP");
	}

}
