This commit is contained in:
Dmitry Vagner 2022-09-22 23:33:43 -07:00
parent 0dfd1b6450
commit 4a5ddfda0a
3 changed files with 9 additions and 3 deletions

View File

@ -77,7 +77,7 @@
ADD
// stack: label + shift
%mload_kernel_code_u32
// stack: byte
// stack: u32
%endmacro
// Load a big-endian u32, consisting of 4 bytes (c_3, c_2, c_1, c_0),

View File

@ -211,7 +211,7 @@ impl<'a> Interpreter<'a> {
0x19 => self.run_not(), // "NOT",
0x1a => self.run_byte(), // "BYTE",
0x1b => self.run_shl(), // "SHL",
0x1c => todo!(), // "SHR",
0x1c => self.run_shr(), // "SHR",
0x1d => todo!(), // "SAR",
0x20 => self.run_keccak256(), // "KECCAK256",
0x30 => todo!(), // "ADDRESS",
@ -412,6 +412,12 @@ impl<'a> Interpreter<'a> {
self.push(x << shift);
}
fn run_shr(&mut self) {
let shift = self.pop();
let value = self.pop();
self.push(value >> shift);
}
fn run_keccak256(&mut self) {
let offset = self.pop().as_usize();
let size = self.pop().as_usize();

View File

@ -20,7 +20,7 @@ fn test_ripemd() -> Result<()> {
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["compress"], stack_input)?;
let actual: Vec<String> = stack_output.stack().iter().map(|&x| format!("{:#?}", x)).collect();
let actual: Vec<String> = stack_output.stack().iter().map(|&x| format!("{:X}", x)).collect();
println!("{:#?}", actual);
assert_eq!(expected, actual);