use of suite.assembler.Amd64Interpret in project suite by stupidsing.
the class ElfTest method test.
private void test(String program, String input, int code) {
Bytes bytes = Bytes.of(input.getBytes(Constants.charset));
if (RunUtil.isUnix()) {
// not Windows => run ELF
Execute exec = elf.exec(bytes.toArray(), offset -> Funp_.main().compile(offset, program).t1);
assertEquals(code, exec.code);
assertEquals(input, exec.out);
} else {
// Windows => interpret assembly
Pair<List<Instruction>, Bytes> pair = Funp_.main().compile(code, program);
Amd64Interpret interpret = new Amd64Interpret();
assertEquals(code, interpret.interpret(pair.t0, pair.t1, bytes));
assertEquals(bytes, interpret.out.toBytes());
}
}
use of suite.assembler.Amd64Interpret in project suite by stupidsing.
the class FunpTest method test.
private void test(int r, String p) {
LogUtil.info(p);
Pair<List<Instruction>, Bytes> pair = Funp_.main().compile(0, p);
Bytes bytes = pair.t1;
LogUtil.info("Hex" + bytes + "\n\n");
assertEquals(r, new Amd64Interpret().interpret(pair.t0, Bytes.of(), Bytes.of()));
assertTrue(bytes != null);
}
Aggregations