add tests for all SETcc instructions

This commit is contained in:
Kevin Ramharak 2019-01-23 14:25:58 +01:00
parent a3253e8e3a
commit fb8fdac9c3
26 changed files with 1231 additions and 0 deletions

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetaInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETA;
public SetaInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetaInstruction();
}
/**
* SETA, SETNBE Above, Not Below or Equal CF=0 AND ZF=0
*/
@Test
public void execution() {
status.setCarryFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(true);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetaeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETAE;
public SetaeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetaeInstruction();
}
/**
* SETAE,SETNB,SETNC Above or Equal, Not Below, No Carry CF=0
*/
@Test
public void execution() {
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetbInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETB;
public SetbInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetbInstruction();
}
/**
* SETB, SETC,SETNAE Below, Carry, Not Above or Equal CF=1
*/
@Test
public void execution() {
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetbeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETBE;
public SetbeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetbeInstruction();
}
/**
* SETBE, SETNA Below or Equal, Not Above CF=1 OR ZF=1
*/
@Test
public void execution() {
status.setCarryFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetcInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETB;
public SetcInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetcInstruction();
}
/**
* SETB, SETC,SETNAE Below, Carry, Not Above or Equal CF=1
*/
@Test
public void execution() {
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SeteInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETE;
public SeteInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SeteInstruction();
}
/**
* SETE, SETZ Equal, Zero ZF=1
*/
@Test
public void execution() {
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,64 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetgInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETG;
public SetgInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetgInstruction();
}
/**
* SETG, SETNLE Greater, Not Less or Equal SF=OF AND ZF=0
*/
@Test
public void execution() {
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(true);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetgeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETGE;
public SetgeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetgeInstruction();
}
/**
* SETGE, SETNL Greater or Equal, Not Less SF=OF
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetlInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETL;
public SetlInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetlInstruction();
}
/**
* SETL, SETNGE Less, Not Greater or Equal SF<>OF
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,62 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetleInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETLE;
public SetleInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetleInstruction();
}
/**
* SETL, SETNGE Less, Not Greater or Equal SF<>OF
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnaInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETBE;
public SetnaInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnaInstruction();
}
/**
* SETBE, SETNA Below or Equal, Not Above CF=1 OR ZF=1
*/
@Test
public void execution() {
status.setCarryFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnaeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETB;
public SetnaeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnaeInstruction();
}
/**
* SETB, SETC,SETNAE Below, Carry, Not Above or Equal CF=1
*/
@Test
public void execution() {
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnbInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETAE;
public SetnbInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnbInstruction();
}
/**
* SETAE,SETNB,SETNC Above or Equal, Not Below, No Carry CF=0
*/
@Test
public void execution() {
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnbeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETA;
public SetnbeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnbeInstruction();
}
/**
* SETA, SETNBE Above, Not Below or Equal CF=0 AND ZF=0
*/
@Test
public void execution() {
status.setCarryFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setCarryFlag(true);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetncInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETAE;
public SetncInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetncInstruction();
}
/**
* SETAE,SETNB,SETNC Above or Equal, Not Below, No Carry CF=0
*/
@Test
public void execution() {
status.setCarryFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setCarryFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetneInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETNE;
public SetneInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetneInstruction();
}
/**
* SETNE, SETNZ Not Equal, Not Zero ZF=0
*/
@Test
public void execution() {
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
}
}

View File

@ -0,0 +1,63 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetngInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETLE;
public SetngInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetngInstruction();
}
/**
* SETLE, SETNG Less or Equal, Not Greater SF<>OF OR ZF=1
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetngeInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETL;
public SetngeInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetngeInstruction();
}
/**
* SETL, SETNGE Less, Not Greater or Equal SF<>OF
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,54 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnlInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETGE;
public SetnlInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnlInstruction();
}
/**
* SETGE, SETNL Greater or Equal, Not Less SF=OF
*/
@Test
public void execution() {
status.setSignFlag(true);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(true);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
}
}

View File

@ -0,0 +1,64 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnleInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETG;
public SetnleInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnleInstruction();
}
/**
* SETG, SETNLE Greater, Not Less or Equal SF=OF AND ZF=0
*/
@Test
public void execution() {
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(true);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
status.setOverflowFlag(false);
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(true);
status.setOverflowFlag(false);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
status.setSignFlag(false);
status.setOverflowFlag(true);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnoInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETNO;
public SetnoInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnoInstruction();
}
/**
* SETNO No Overflow OF=0
*/
@Test
public void execution() {
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetnsInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETNS;
public SetnsInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetnsInstruction();
}
/**
* SETS No Sign SF=0
*/
@Test
public void execution() {
status.setSignFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetoInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETO;
public SetoInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetoInstruction();
}
/**
* SETO Overflow OF=1
*/
@Test
public void execution() {
status.setOverflowFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setOverflowFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetsInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETS;
public SetsInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetsInstruction();
}
/**
* SETS Sign SF=1
*/
@Test
public void execution() {
status.setSignFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setSignFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}

View File

@ -0,0 +1,42 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.Register;
import net.simon987.server.assembly.RegisterSet;
import net.simon987.server.assembly.Status;
import org.junit.Test;
import static org.junit.Assert.*;
public class SetzInstructionTest {
private RegisterSet registers;
private Status status;
private SetccInstruction instruction;
private int SETCCOPCODE = SetccInstruction.SETE;
public SetzInstructionTest() {
registers = new RegisterSet();
registers.put(1, new Register("R"));
registers.clear();
status = new Status();
status.clear();
instruction = new SetzInstruction();
}
/**
* SETE, SETZ Equal, Zero ZF=1
*/
@Test
public void execution() {
status.setZeroFlag(true);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 1);
status.setZeroFlag(false);
instruction.execute(registers, 1, SETCCOPCODE, status);
assertEquals(registers.get(1), 0);
}
}