This commit is contained in:
Dmitry Vagner 2022-10-18 01:31:28 -04:00
parent 6a6fbec9f5
commit c9bbd2dfa0

View File

@ -238,9 +238,9 @@ impl<'a> Interpreter<'a> {
0x09 => self.run_mulmod(), // "MULMOD",
0x0a => self.run_exp(), // "EXP",
0x0b => todo!(), // "SIGNEXTEND",
0x0c => self.run_add_p(), // "ADDFP254",
0x0d => self.run_mul_p(), // "MULFP254",
0x0e => self.run_sub_p(), // "SUBFP254",
0x0c => self.run_addfp254(), // "ADDFP254",
0x0d => self.run_mulfp254(), // "MULFP254",
0x0e => self.run_subfp254(), // "SUBFP254",
0x10 => self.run_lt(), // "LT",
0x11 => self.run_gt(), // "GT",
0x12 => todo!(), // "SLT",
@ -353,31 +353,30 @@ impl<'a> Interpreter<'a> {
self.push(x.overflowing_add(y).0);
}
fn run_add_p(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(U256::try_from((x + y) % 101).unwrap());
}
fn run_mul(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(x.overflowing_mul(y).0);
}
fn run_mul_p(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(U256::try_from(x.full_mul(y) % 101).unwrap());
}
fn run_sub(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(x.overflowing_sub(y).0);
}
fn run_sub_p(&mut self) {
fn run_addfp254(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(U256::try_from((x + y) % 101).unwrap());
}
fn run_mulfp254(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(U256::try_from(x.full_mul(y) % 101).unwrap());
}
fn run_subfp254(&mut self) {
let x = self.pop();
let y = self.pop();
self.push(U256::try_from((U256::from(101) + x - y) % 101).unwrap());