From 22b51bcd2b820f2083b809cd970ace357766feea Mon Sep 17 00:00:00 2001 From: 0xd4d Date: Sat, 26 Dec 2020 12:00:47 +0100 Subject: [PATCH] Update README and docs --- src/rust/iced-x86-py/README.md | 14 ++++++++++---- src/rust/iced-x86-py/src/iced_x86/_iced_x86_py.pyi | 2 +- src/rust/iced-x86-py/src/instruction.rs | 4 ++-- src/rust/iced-x86-py/src/op_code_info.rs | 2 +- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/rust/iced-x86-py/README.md b/src/rust/iced-x86-py/README.md index 10aa04ec8..ea9b8d8e7 100644 --- a/src/rust/iced-x86-py/README.md +++ b/src/rust/iced-x86-py/README.md @@ -104,7 +104,6 @@ from iced_x86 import * # xchg ah,[rdx+rsi+16h] # xchgb %ah, %ds:0x16(%rdx,%rsi) -HEXBYTES_COLUMN_BYTE_LENGTH = 10 EXAMPLE_CODE_BITNESS = 64 EXAMPLE_CODE_RIP = 0x0000_7FFA_C46A_CDA4 EXAMPLE_CODE = \ @@ -171,7 +170,7 @@ print(f"{instr:gG_xSs}") # r RIP-relative memory operands use RIP register instead of abs addr (``[rip+123h]`` vs ``[123456789ABCDEF0h]``) # U Uppercase everything except numbers and hex prefixes/suffixes (ignored by fast fmt) # s Add a space after the operand separator -# S Always show the segment register +# S Always show the segment register (memory operands) # B Don't show the branch size (``SHORT`` or ``NEAR PTR``) (ignored by fast fmt) # G (GNU Assembler): Add mnemonic size suffix (eg. ``movl`` vs ``mov``) # M Always show the memory size (eg. ``BYTE PTR``) even when not needed @@ -694,7 +693,7 @@ def how_to_get_instruction_info() -> None: print(f" FPU TOP: the instruction overwrites TOP") else: print(f" FPU TOP inc: {fpu_info.increment}") - cond_write = "true" if fpu_info.conditional else "false" + cond_write = "True" if fpu_info.conditional else "False" print(f" FPU TOP cond write: {cond_write}") if offsets.has_immediate: print(f" Immediate offset = {offsets.immediate_offset}, size = {offsets.immediate_size}") @@ -703,7 +702,7 @@ def how_to_get_instruction_info() -> None: if instr.is_stack_instruction: print(f" SP Increment: {instr.stack_pointer_increment}") if instr.condition_code != ConditionCode.NONE: - print(f" Condition code: {instr.condition_code}") + print(f" Condition code: {condition_code_to_string(instr.condition_code)}") if instr.rflags_read != RflagsBits.NONE: print(f" RFLAGS Read: {rflags_bits_to_string(instr.rflags_read)}") if instr.rflags_written != RflagsBits.NONE: @@ -840,6 +839,13 @@ def memory_size_to_string(value: int) -> str: return str(value) + " /*MemorySize enum*/" return s +CONDITION_CODE_TO_STRING: Dict[int, str] = create_enum_dict(ConditionCode) +def condition_code_to_string(value: int) -> str: + s = CONDITION_CODE_TO_STRING.get(value) + if s is None: + return str(value) + " /*ConditionCode enum*/" + return s + def used_reg_to_string(reg_info: UsedRegister) -> str: return register_to_string(reg_info.register) + ":" + op_access_to_string(reg_info.access) diff --git a/src/rust/iced-x86-py/src/iced_x86/_iced_x86_py.pyi b/src/rust/iced-x86-py/src/iced_x86/_iced_x86_py.pyi index 20d98d9cc..3f5226124 100644 --- a/src/rust/iced-x86-py/src/iced_x86/_iced_x86_py.pyi +++ b/src/rust/iced-x86-py/src/iced_x86/_iced_x86_py.pyi @@ -2231,7 +2231,7 @@ class Instruction: r RIP-relative memory operands use RIP register instead of abs addr (`[rip+123h]` vs `[123456789ABCDEF0h]`) U Uppercase everything except numbers and hex prefixes/suffixes (ignored by fast fmt) s Add a space after the operand separator - S Always show the segment register + S Always show the segment register (memory operands) B Don't show the branch size (`SHORT` or `NEAR PTR`) (ignored by fast fmt) G (GNU Assembler): Add mnemonic size suffix (eg. `movl` vs `mov`) M Always show the memory size (eg. `BYTE PTR`) even when not needed diff --git a/src/rust/iced-x86-py/src/instruction.rs b/src/rust/iced-x86-py/src/instruction.rs index 2496d26f3..9e3f0d4ca 100644 --- a/src/rust/iced-x86-py/src/instruction.rs +++ b/src/rust/iced-x86-py/src/instruction.rs @@ -168,7 +168,7 @@ use std::collections::hash_map::DefaultHasher; /// r RIP-relative memory operands use RIP register instead of abs addr (``[rip+123h]`` vs ``[123456789ABCDEF0h]``) /// U Uppercase everything except numbers and hex prefixes/suffixes (ignored by fast fmt) /// s Add a space after the operand separator -/// S Always show the segment register +/// S Always show the segment register (memory operands) /// B Don't show the branch size (``SHORT`` or ``NEAR PTR``) (ignored by fast fmt) /// G (GNU Assembler): Add mnemonic size suffix (eg. ``movl`` vs ``mov``) /// M Always show the memory size (eg. ``BYTE PTR``) even when not needed @@ -2197,7 +2197,7 @@ impl Instruction { 'G' => fmt_opts.set_gas_show_mnemonic_size_suffix(true), 'M' => fmt_opts.set_memory_size_options(iced_x86::MemorySizeOptions::Always), '_' => fmt_opts.set_digit_separator("_"), - _ => return Err(PyValueError::new_err(format!("Unknown format code '{}' ('{}')", c, format_spec))), + _ => return Err(PyValueError::new_err(format!("Unknown format specifier '{}' ('{}')", c, format_spec))), } } diff --git a/src/rust/iced-x86-py/src/op_code_info.rs b/src/rust/iced-x86-py/src/op_code_info.rs index 6974ba38d..67fcecb0f 100644 --- a/src/rust/iced-x86-py/src/op_code_info.rs +++ b/src/rust/iced-x86-py/src/op_code_info.rs @@ -849,7 +849,7 @@ impl PyObjectProtocol for OpCodeInfo { match format_spec { "" | "i" => Ok(self.info.instruction_string()), "o" => Ok(self.info.op_code_string()), - _ => Err(PyValueError::new_err(format!("Unknown format code '{}'", format_spec))), + _ => Err(PyValueError::new_err(format!("Unknown format specifier '{}'", format_spec))), } }