public static final long DATA_SEGMENT = 0x2000_0000_0000_0000l; public static final long V_BIT = (1 << 6); // 0x40 public static void STB(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store8(proc.register(y) + proc.register(z), (byte) v);
	if (v != (v << 56 >>> 56)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STBI(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store8(proc.register(y) + (0xff & z), (byte) v);
	if (v != (v << 56 >>> 56)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STBU(Processor proc, Memory mem, int x, int y, int z) {
	mem.store8(proc.register(y) + proc.register(z),
			(byte) proc.register(x));
	proc.cost(1, 1);
} public static void STBUI(Processor proc, Memory mem, int x, int y, int z) {
	mem.store8(proc.register(y) + (0xff & z), (short) proc.register(x));
	proc.cost(1, 1);
} public static void STO(Processor proc, Memory mem, int x, int y, int z) {
	mem.store64(proc.register(y) + proc.register(z), proc.register(x));
	proc.cost(1, 1);
} public static void STOI(Processor proc, Memory mem, int x, int y, int z) {
	mem.store64(proc.register(y) + (0xff & z), proc.register(x));
	proc.cost(1, 1);
} public static void STOU(Processor proc, Memory mem, int x, int y, int z) {
	mem.store64(proc.register(y) + proc.register(z), proc.register(x));
	proc.cost(1, 1);
} public static void STOUI(Processor proc, Memory mem, int x, int y, int z) {
	mem.store64(proc.register(y) + (0xff & z), proc.register(x));
	proc.cost(1, 1);
} public static void STT(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store32(proc.register(y) + proc.register(z), (int) v);
	if (v != (v << 32 >>> 32)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STTI(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store32(proc.register(y) + (0xff & z), (int) v);
	if (v != (v << 32 >>> 32)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STTU(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store32(proc.register(y) + proc.register(z), (int) v);
	proc.cost(1, 1);
} public static void STTUI(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store32(proc.register(y) + (0xff & z), (int) v);
	proc.cost(1, 1);
} public static void STW(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store16(proc.register(y) + proc.register(z), (short) v);
	if (v != (v << 48 >>> 48)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STWI(Processor proc, Memory mem, int x, int y, int z) {
	long v = proc.register(x);

	mem.store16(proc.register(y) + (0xff & z), (short) v);
	if (v != (v << 48 >>> 48)) {
		proc.setRa(V_BIT, true);
	}
	proc.cost(1, 1);
} public static void STWU(Processor proc, Memory mem, int x, int y, int z) {
	mem.store16(proc.register(y) + proc.register(z),
			(short) proc.register(x));
	proc.cost(1, 1);
} public static void STWUI(Processor proc, Memory mem, int x, int y, int z) {
	mem.store16(proc.register(y) + (0xff & z), (short) proc.register(x));
	proc.cost(1, 1);
} @Factory
public static <T> Matcher<T> equalToHex(T operand) {
	return new IsEqualHex<T>(operand);
}
import static fr.broeglin.jmmix.simulator.Memory.DATA_SEGMENT;
import static fr.broeglin.jmmix.simulator.Processor.V_BIT;
import static fr.broeglin.jmmix.simulator.SpecialRegisterName.rA;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STB;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STBI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STBU;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STBUI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STO;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STOI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STOU;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STOUI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STT;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STTI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STTU;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STTUI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STW;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STWI;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STWU;
import static fr.broeglin.jmmix.simulator.instructions.StoreInstructions.STWUI;
import static fr.broeglin.jmmix.simulator.utils.IsEqualHex.equalToHex;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
package fr.broeglin.jmmix.simulator.instructions;



public class StoreInstructionsTest extends AbstractInstructionsTest {

	@Before
	public void initialize_memory_and_r2() {
		mem.store64(DATA_SEGMENT, 0x0123_4567_89ab_cdefl);

		proc.setRegister(0x02, DATA_SEGMENT);
	}

	//
	// Store Byte
	//

	@Test
	public void STB_should_work() {
		proc.setRegister(0x01, 0xf7l);
		proc.setRegister(0x03, 3);

		STB(proc, mem, 0x01, 0x02, 0x03);