Skip to content

Commit

Permalink
[#201] Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vbmacher committed Sep 3, 2021
1 parent af092a8 commit 0cb5c62
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,25 @@ public void testCopyrightIsKnown() {

@Test
public void testSTO() throws Exception {
compile(
"0 sto 22\n"
);
compile("00 STO 22\n");
assertProgram(0x68, 6, 0, 0);
}

// 01101000 00000110 0000 0000
assertProgram(
0x68, 6, 0, 0
);
@Test
public void testLDN() throws Exception {
compile("00 LDN 29");
assertProgram(0xB8,4,0,0);
}

@Test
public void testSUB() throws Exception {
compile("00 SUB 30");
assertProgram(0x78,8,0,0);
}

@Test
public void testSTP() throws Exception {
compile("00 STP");
assertProgram(0,0x0E,0,0);
}
}
2 changes: 1 addition & 1 deletion plugins/cpu/ssem-cpu/src/main/edigen/cpu.eds
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ data = data: data(32);

%%

"%s %d" = instruction line ignore8 ignore16;
"%s %d" = instruction line(bit_reverse) ignore8 ignore16;
"%s" = instruction ignore8 ignore16;
"%x" = data;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package net.emustudio.plugins.cpu.ssem;

import net.emustudio.cpu.testsuite.memory.ByteMemoryStub;
import net.emustudio.emulib.plugins.cpu.DecodedInstruction;
import net.emustudio.emulib.plugins.cpu.DisassembledInstruction;
import net.emustudio.emulib.plugins.cpu.InvalidInstructionException;
import net.emustudio.emulib.runtime.ApplicationApi;
import net.emustudio.emulib.runtime.ContextPool;
import net.emustudio.emulib.runtime.PluginSettings;
import net.emustudio.emulib.runtime.helpers.Bits;
import net.emustudio.emulib.runtime.helpers.NumberUtils;
import org.junit.Test;

import static net.emustudio.plugins.cpu.ssem.DecoderImpl.LINE;
import static org.easymock.EasyMock.*;
import static org.easymock.EasyMock.replay;
import static org.junit.Assert.assertEquals;

public class DisassemblerTest {
private final ByteMemoryStub memory = new ByteMemoryStub(NumberUtils.Strategy.LITTLE_ENDIAN);
private final DecoderImpl decoder = new DecoderImpl(memory);
private final DisassemblerImpl disassembler = new DisassemblerImpl(memory, decoder);

@Test
public void testLDN() {
memory.setMemory(new short[]{
0x9B, 0xE2, 0xFC, 0x3F
});

DisassembledInstruction instr = disassembler.disassemble(0);
assertEquals("LDN 25", instr.getMnemo());
assertEquals("9B E2 FC 3F", instr.getOpCode());
}

@Test
public void testSTO() {
memory.setMemory(new short[]{
0,0,0,0,
0x68, 0x06, 0x00, 0x00
});

DisassembledInstruction instr = disassembler.disassemble(4);
assertEquals("STO 22", instr.getMnemo());
assertEquals("68 06 00 00", instr.getOpCode());
}
}

0 comments on commit 0cb5c62

Please sign in to comment.