@Test public void throwsInvalidMnemonicException() { SetccInstruction instruction = new SetccInstruction(); boolean hasThrown = false; try { ByteArrayOutputStream stream = new ByteArrayOutputStream(); Operand operand = new Operand(OperandType.MEMORY_REG16, 1); instruction.encode(stream, operand, 0); } catch (AssemblyException exception) { if (exception instanceof InvalidMnemonicException) { hasThrown = true; } } assertTrue(hasThrown); }
@Override public void encode(ByteArrayOutputStream out, Operand o1, int currentLine) throws AssemblyException { String mnemonic = getMnemonic().toLowerCase(); Character familyOpCode = mnemonicFamilyOpCodeMap.get(mnemonic); if (familyOpCode == null) { throw new InvalidMnemonicException(getMnemonic(), currentLine); } if (!operandValid(o1)) { throw new IllegalOperandException("Illegal operand combination: " + o1.getType() + " (none)", currentLine); } MachineCode code = new MachineCode(); code.writeOpcode(getOpCode()); code.writeSourceOperand(Operand.IMMEDIATE_VALUE); code.appendWord(familyOpCode); if (o1.getType() == OperandType.REGISTER16 || o1.getType() == OperandType.MEMORY_REG16) { code.writeDestinationOperand(o1.getValue()); } else { code.writeDestinationOperand(o1.getValue()); code.appendWord((char) o1.getData()); } for (byte b : code.bytes()) { out.write(b); } }
SetccInstruction extends Instruction { @Override public void encode(ByteArrayOutputStream out, Operand o1, int currentLine) throws AssemblyException { String mnemonic = getMnemonic().toLowerCase(); Character familyOpCode = mnemonicFamilyOpCodeMap.get(mnemonic); if (familyOpCode == null) { throw new InvalidMnemonicException(getMnemonic(), currentLine); } if (!operandValid(o1)) { throw new IllegalOperandException("Illegal operand combination: " + o1.getType() + " (none)", currentLine); } MachineCode code = new MachineCode(); code.writeOpcode(getOpCode()); code.writeSourceOperand(Operand.IMMEDIATE_VALUE); code.appendWord(familyOpCode); if (o1.getType() == OperandType.REGISTER16 || o1.getType() == OperandType.MEMORY_REG16) { code.writeDestinationOperand(o1.getValue()); } else { code.writeDestinationOperand(o1.getValue()); code.appendWord((char) o1.getData()); } for (byte b : code.bytes()) { out.write(b); } } }
SetccInstruction extends Instruction { @Override public void encode(ByteArrayOutputStream out, Operand o1, int currentLine) throws AssemblyException { String mnemonic = getMnemonic().toLowerCase(); Character familyOpCode = mnemonicFamilyOpCodeMap.get(mnemonic); if (familyOpCode == null) { throw new InvalidMnemonicException(getMnemonic(), currentLine); } if (!operandValid(o1)) { throw new IllegalOperandException("Illegal operand combination: " + o1.getType() + " (none)", currentLine); } MachineCode code = new MachineCode(); code.writeOpcode(getOpCode()); code.writeSourceOperand(Operand.IMMEDIATE_VALUE); code.appendWord(familyOpCode); if (o1.getType() == OperandType.REGISTER16 || o1.getType() == OperandType.MEMORY_REG16) { code.writeDestinationOperand(o1.getValue()); } else { code.writeDestinationOperand(o1.getValue()); code.appendWord((char) o1.getData()); } for (byte b : code.bytes()) { out.write(b); } } SetccInstruction();  SetccInstruction(String alias); }
SetccInstruction extends Instruction { @Override public void encode(ByteArrayOutputStream out, Operand o1, int currentLine) throws AssemblyException { String mnemonic = getMnemonic().toLowerCase(); Character familyOpCode = mnemonicFamilyOpCodeMap.get(mnemonic); if (familyOpCode == null) { throw new InvalidMnemonicException(getMnemonic(), currentLine); } if (!operandValid(o1)) { throw new IllegalOperandException("Illegal operand combination: " + o1.getType() + " (none)", currentLine); } MachineCode code = new MachineCode(); code.writeOpcode(getOpCode()); code.writeSourceOperand(Operand.IMMEDIATE_VALUE); code.appendWord(familyOpCode); if (o1.getType() == OperandType.REGISTER16 || o1.getType() == OperandType.MEMORY_REG16) { code.writeDestinationOperand(o1.getValue()); } else { code.writeDestinationOperand(o1.getValue()); code.appendWord((char) o1.getData()); } for (byte b : code.bytes()) { out.write(b); } } SetccInstruction();  SetccInstruction(String alias); @Override Status execute(Target dst, int dstIndex, int familyOpCode, Status status); @Override boolean operandsValid(Operand o1, Operand o2); @Override boolean operandValid(Operand o1); @Override void encode(ByteArrayOutputStream out, Operand o1, int currentLine); }
SetccInstruction extends Instruction { @Override public void encode(ByteArrayOutputStream out, Operand o1, int currentLine) throws AssemblyException { String mnemonic = getMnemonic().toLowerCase(); Character familyOpCode = mnemonicFamilyOpCodeMap.get(mnemonic); if (familyOpCode == null) { throw new InvalidMnemonicException(getMnemonic(), currentLine); } if (!operandValid(o1)) { throw new IllegalOperandException("Illegal operand combination: " + o1.getType() + " (none)", currentLine); } MachineCode code = new MachineCode(); code.writeOpcode(getOpCode()); code.writeSourceOperand(Operand.IMMEDIATE_VALUE); code.appendWord(familyOpCode); if (o1.getType() == OperandType.REGISTER16 || o1.getType() == OperandType.MEMORY_REG16) { code.writeDestinationOperand(o1.getValue()); } else { code.writeDestinationOperand(o1.getValue()); code.appendWord((char) o1.getData()); } for (byte b : code.bytes()) { out.write(b); } } SetccInstruction();  SetccInstruction(String alias); @Override Status execute(Target dst, int dstIndex, int familyOpCode, Status status); @Override boolean operandsValid(Operand o1, Operand o2); @Override boolean operandValid(Operand o1); @Override void encode(ByteArrayOutputStream out, Operand o1, int currentLine); static final int OPCODE; static final int SETA; static final int SETAE; static final int SETBE; static final int SETB; static final int SETE; static final int SETNE; static final int SETG; static final int SETGE; static final int SETLE; static final int SETL; static final int SETO; static final int SETNO; static final int SETS; static final int SETNS; }