Skip to content

Instantly share code, notes, and snippets.

@stryku
Created March 5, 2017 20:17
Show Gist options
  • Save stryku/f09ecda14cbf5ec010bde771d94b9c52 to your computer and use it in GitHub Desktop.
Save stryku/f09ecda14cbf5ec010bde771d94b9c52 to your computer and use it in GitHub Desktop.
template<typename state_t, size_t ip, size_t ...rest_of_opcodes>
struct ex_instruction<state_t, inst::to_size<inst::id_t::JGE>, ip, rest_of_opcodes...>
{
using state = to_machine_state<state_t>;
static constexpr auto flags_v = typename state::flags_t{};
static constexpr bool should_jmp = ((static_cast<int>(flags_v.SF) ^ static_cast<int>(flags_v.OF)) == 0);
using final_regs_state = std::conditional_t<
should_jmp,
set_reg<typename state::registers_state_t, regs::id_t::EIP, static_cast<uint32_t>(ip)>,
adjust_eip<typename state::registers_state_t, inst::id_t::JGE>>;
using type = machine_state<typename state::stack_t, typename state::flags_t, final_regs_state>;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment