Skip to content

Commit

Permalink
Check if a64 before if is-64bit
Browse files Browse the repository at this point in the history
  • Loading branch information
wtfsck committed Oct 5, 2021
1 parent 77d90e7 commit cef183b
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/rust/iced-x86/src/decoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2153,18 +2153,17 @@ impl<'a> Decoder<'a> {
loop {
this.displ_index = this.data_ptr as u8;
let displ = read_u32_break!(this) as i32 as u64;
if this.is64b_mode {
if this.state.address_size == OpSize::Size64 {
this.state.flags |= StateFlags::IP_REL64;
instruction.set_memory_displacement64(displ);
instruction_internal::internal_set_memory_displ_size(instruction, 4);
instruction.set_memory_base(Register::RIP);
} else {
this.state.flags |= StateFlags::IP_REL32;
instruction.set_memory_displacement64(displ as u32 as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
instruction.set_memory_base(Register::EIP);
}
if this.state.address_size == OpSize::Size64 {
debug_assert!(this.is64b_mode);
this.state.flags |= StateFlags::IP_REL64;
instruction.set_memory_displacement64(displ);
instruction_internal::internal_set_memory_displ_size(instruction, 4);
instruction.set_memory_base(Register::RIP);
} else if this.is64b_mode {
this.state.flags |= StateFlags::IP_REL32;
instruction.set_memory_displacement64(displ as u32 as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
instruction.set_memory_base(Register::EIP);
} else {
instruction.set_memory_displacement64(displ as u32 as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
Expand Down Expand Up @@ -2518,18 +2517,17 @@ fn decoder_read_op_mem_vsib_0_5(
) -> bool {
this.displ_index = this.data_ptr as u8;
let d = this.read_u32();
if this.is64b_mode {
if this.state.address_size == OpSize::Size64 {
this.state.flags |= StateFlags::IP_REL64;
instruction.set_memory_displacement64(d as i32 as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 4);
instruction.set_memory_base(Register::RIP);
} else {
this.state.flags |= StateFlags::IP_REL32;
instruction.set_memory_displacement64(d as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
instruction.set_memory_base(Register::EIP);
}
if this.state.address_size == OpSize::Size64 {
debug_assert!(this.is64b_mode);
this.state.flags |= StateFlags::IP_REL64;
instruction.set_memory_displacement64(d as i32 as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 4);
instruction.set_memory_base(Register::RIP);
} else if this.is64b_mode {
this.state.flags |= StateFlags::IP_REL32;
instruction.set_memory_displacement64(d as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
instruction.set_memory_base(Register::EIP);
} else {
instruction.set_memory_displacement64(d as u64);
instruction_internal::internal_set_memory_displ_size(instruction, 3);
Expand Down

0 comments on commit cef183b

Please sign in to comment.