mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-18 02:06:43 +00:00
Test for ORG directive (#228)
This commit is contained in:
parent
ad0124508c
commit
319abad130
@ -192,7 +192,7 @@ public class Memory implements Target, MongoSerializable, Cloneable {
|
|||||||
public Memory clone() {
|
public Memory clone() {
|
||||||
Memory memory = new Memory(words.length);
|
Memory memory = new Memory(words.length);
|
||||||
memory.words = new char[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;
|
return memory;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ public class TestExecutionResult {
|
|||||||
|
|
||||||
public List<FakeHardwareHost.HwiCall> hwiHistory;
|
public List<FakeHardwareHost.HwiCall> hwiHistory;
|
||||||
|
|
||||||
private AssemblyResult ar;
|
public AssemblyResult ar;
|
||||||
|
|
||||||
public TestExecutionResult(CpuState state, List<FakeHardwareHost.HwiCall> hwiHistory, AssemblyResult ar) {
|
public TestExecutionResult(CpuState state, List<FakeHardwareHost.HwiCall> hwiHistory, AssemblyResult ar) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
|
@ -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"));
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user