format, stack macro, remove prints

This commit is contained in:
Dmitry Vagner 2022-09-23 10:52:05 -07:00
parent 41ce8e94b9
commit 3cceede412
3 changed files with 8 additions and 16 deletions

View File

@ -240,13 +240,8 @@ mid_rol:
%jump(rol)
post_rol:
// stack: c, a, b, d, e, F, K, boxes , rounds, sides, virt
SWAP3
// stack: d, a, b, c, e, F, K, boxes , rounds, sides, virt
SWAP4
// stack: e, a, b, c, d, F, K, boxes , rounds, sides, virt
SWAP7
PUSH 1
SWAP1
%stack (c, a, b, d, e, F, K, boxes) -> (boxes, 1, a, b, c, d, F, K, e)
// stack: boxes, 1, a, b, c, d, F, K, e, rounds, sides, virt
SUB
SWAP7
// stack: e, a, b, c, d, F, K, boxes-1, rounds, sides, virt

View File

@ -282,7 +282,6 @@ impl<'a> Interpreter<'a> {
0xff => todo!(), // "SELFDESTRUCT",
_ => bail!("Unrecognized opcode {}.", opcode),
};
println!("{:X}", opcode);
Ok(())
}

View File

@ -6,25 +6,23 @@ use crate::cpu::kernel::interpreter::run_with_kernel;
#[test]
fn test_ripemd() -> Result<()> {
let expected = "f71c27109c692c1b56bbdceb5b9d2865b3708dbc";
println!("{:#}", expected);
let input: Vec<u32> = vec![
26, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a
26, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
];
let kernel = combined_kernel();
let stack_input: Vec<U256> = input.iter().map(|&x| U256::from(x as u32)).rev().collect();
let stack_output = run_with_kernel(&kernel, kernel.global_labels["ripemd_alt"], stack_input)?;
let actual: Vec<String> = stack_output
let actual: String = stack_output
.stack()
.iter()
.map(|&x| format!("{:x}", x))
.rev()
.collect();
println!("{:#?}", actual);
assert_eq!(expected, actual[0]);
let expected = "f71c27109c692c1b56bbdceb5b9d2865b3708dbc";
assert_eq!(expected, actual);
Ok(())
}