Skip to content

Commit

Permalink
feat(avm): add radix opcode to transpiler
Browse files Browse the repository at this point in the history
  • Loading branch information
IlyasRidhuan committed May 10, 2024
1 parent 170a65e commit 93a4ca0
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions avm-transpiler/src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,34 @@ fn handle_black_box_function(avm_instrs: &mut Vec<AvmInstruction>, operation: &B
..Default::default()
});
}
BlackBoxOp::ToRadix {
input,
radix,
output,
} => {
let num_limbs = output.size;
let input_offset = input.0;
let output_offset = output.pointer.0;
assert!(radix <= &256u32, "Radix must be less than or equal to 256");

avm_instrs.push(AvmInstruction {
opcode: AvmOpcode::TORADIXLE,
indirect: Some(FIRST_OPERAND_INDIRECT),
tag: Some(AvmTypeTag::FIELD),
operands: vec![
AvmOperand::U32 {
value: input_offset as u32,
},
AvmOperand::U32 {
value: output_offset as u32,
},
AvmOperand::U32 { value: *radix },
AvmOperand::U32 {
value: num_limbs as u32,
},
],
})
}
_ => panic!("Transpiler doesn't know how to process {:?}", operation),
}
}
Expand Down

0 comments on commit 93a4ca0

Please sign in to comment.