Skip to content

Commit

Permalink
bytecode: Add bytecode API for exmmax instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
rodiazet committed Jan 9, 2024
1 parent 4bc340e commit 0697ce6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/utils/bytecode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,37 @@ inline bytecode blobhash(bytecode index)
return index + OP_BLOBHASH;
}

inline bytecode setupx(
bytecode num_val_slots, bytecode mod_size, bytecode mod_offset, bytecode mod_id)
{
return num_val_slots + mod_size + mod_offset + mod_id + OP_SETUPX;
}

inline bytecode storex(bytecode num_vals, bytecode val_offset, bytecode val_slot)
{
return num_vals + val_offset + val_slot + OP_STOREX;
}

inline bytecode loadx(bytecode num_vals, bytecode val_idx, bytecode mem_offset)
{
return num_vals + val_idx + mem_offset + OP_LOADX;
}

inline bytecode addmodx(uint8_t result_slot_idx, uint8_t x_slot_idx, uint8_t y_slot_idx)
{
return hex(OP_ADDMODX) + hex(result_slot_idx) + hex(x_slot_idx) + hex(y_slot_idx);
}

inline bytecode submodx(uint8_t result_slot_idx, uint8_t x_slot_idx, uint8_t y_slot_idx)
{
return hex(OP_SUBMODX) + hex(result_slot_idx) + hex(x_slot_idx) + hex(y_slot_idx);
}

inline bytecode mulmodx(uint8_t result_slot_idx, uint8_t x_slot_idx, uint8_t y_slot_idx)
{
return hex(OP_MULMODX) + hex(result_slot_idx) + hex(x_slot_idx) + hex(y_slot_idx);
}

template <Opcode kind>
struct call_instruction
{
Expand Down

0 comments on commit 0697ce6

Please sign in to comment.