Search in sources :

Example 1 with UnknownOpCodeException

use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.

the class Mos6502CompilerTest method testInvalidValuePrefix.

@Test
public void testInvalidValuePrefix() {
    try {
        final Mos6502Compiler compiler = new Mos6502Compiler("ADC @$10");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        fail("Invalid value prefix should throw an exception but was " + Arrays.toString(bytes));
    } catch (UnknownOpCodeException e) {
        assertFalse(e.getMessage().isEmpty());
        assertFalse(e.getOpCode() == null);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 2 with UnknownOpCodeException

use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.

the class Mos6502Test method testInvalidOpCode.

@Test
public void testInvalidOpCode() {
    Program program = new Program().with(231);
    memory.setBlock(0, program.getProgramAsByteArray());
    try {
        processor.step();
        fail("Invalid opCode exception expected!");
    } catch (UnknownOpCodeException e) {
        assertEquals("231", e.getOpCode());
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Test(org.junit.Test)

Example 3 with UnknownOpCodeException

use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.

the class DebuggerWindow method compile.

public void compile(String programText) {
    final Mos6502Compiler compiler = new Mos6502Compiler(programText);
    try {
        final Program program = compiler.compileProgram();
        final int[] programAsByteArray = program.getProgramAsByteArray();
        loadProgram(programAsByteArray);
    } catch (UnknownOpCodeException e) {
        JOptionPane.showMessageDialog(this, e.getMessage());
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler)

Example 4 with UnknownOpCodeException

use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.

the class Mos6502CompilerTest method testInvalidArgument.

@Test
public void testInvalidArgument() {
    try {
        final Mos6502Compiler compiler = new Mos6502Compiler("INC $12345");
        Program program = compiler.compileProgram();
        program.getProgramAsByteArray();
        fail("The argument for INC is too long, should throw an error");
    } catch (UnknownOpCodeException e) {
        assertNotNull(e);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Example 5 with UnknownOpCodeException

use of com.rox.emu.UnknownOpCodeException in project emuRox by rossdrew.

the class Mos6502CompilerTest method testInvalidIndirectIndexingMode.

@Test
public void testInvalidIndirectIndexingMode() {
    try {
        final Mos6502Compiler compiler = new Mos6502Compiler("ADC " + INDIRECT_PREFIX + "10(");
        Program program = compiler.compileProgram();
        int[] bytes = program.getProgramAsByteArray();
        fail("Invalid prefix for an indirect value should throw an exception but was " + Arrays.toString(bytes));
    } catch (UnknownOpCodeException e) {
        assertFalse(e.getMessage().isEmpty());
        assertFalse(e.getOpCode() == null);
    }
}
Also used : Program(com.rox.emu.processor.mos6502.util.Program) UnknownOpCodeException(com.rox.emu.UnknownOpCodeException) Mos6502Compiler(com.rox.emu.processor.mos6502.util.Mos6502Compiler) Test(org.junit.Test)

Aggregations

UnknownOpCodeException (com.rox.emu.UnknownOpCodeException)7 Program (com.rox.emu.processor.mos6502.util.Program)6 Mos6502Compiler (com.rox.emu.processor.mos6502.util.Mos6502Compiler)5 Test (org.junit.Test)5