Test for ORG directive (#228)

This commit is contained in:
simon987 2020-07-30 18:29:37 -04:00
parent ad0124508c
commit 319abad130
3 changed files with 29 additions and 2 deletions

View File

@ -192,7 +192,7 @@ public class Memory implements Target, MongoSerializable, Cloneable {
public Memory clone() {
Memory memory = new Memory(words.length);
memory.words = new char[words.length];
System.arraycopy(memory.words, 0, words, 0, words.length);
System.arraycopy(words, 0, memory.words, 0, words.length);
return memory;
}
}

View File

@ -11,7 +11,7 @@ public class TestExecutionResult {
public List<FakeHardwareHost.HwiCall> hwiHistory;
private AssemblyResult ar;
public AssemblyResult ar;
public TestExecutionResult(CpuState state, List<FakeHardwareHost.HwiCall> hwiHistory, AssemblyResult ar) {
this.state = state;

View File

@ -0,0 +1,27 @@
package net.simon987.mar.server.assembly;
import net.simon987.mar.server.TestExecutionResult;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class OrgDirectiveTest {
@Test
public void orgWikiExample() {
String code = "" +
"ORG 0x8000 \n" +
"my_var: DW 0x1234 \n" +
".text \n" +
"MOV A, my_var \n" +
"brk \n";
TestExecutionResult res = TestHelper.executeCode(code);
assertTrue(res.ar.exceptions.isEmpty());
assertEquals(0x8000, res.ar.origin);
assertEquals(0x1234, res.memValue(0x8000));
assertEquals(0x8000, res.regValue("A"));
}
}