From cef4feeaf9c64e03a6728f267750ac2fb32eb9ff Mon Sep 17 00:00:00 2001 From: iximeow Date: Sat, 21 Aug 2021 12:13:01 -0700 Subject: report memory sizes for push, pop, call, ret these instructions had memory sizes reported for the operand, if it was a memory operand, but for versions with non-memory operands the decoded `Instruction` would imply that non memory access would happen at all. now, decoded instructions in these cases will report a more useful memory size. --- test/real_mode/operand.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 test/real_mode/operand.rs (limited to 'test/real_mode/operand.rs') diff --git a/test/real_mode/operand.rs b/test/real_mode/operand.rs new file mode 100644 index 0000000..e037fee --- /dev/null +++ b/test/real_mode/operand.rs @@ -0,0 +1,20 @@ +use yaxpeax_x86::real_mode::{InstDecoder, Operand, RegSpec}; +use yaxpeax_x86::MemoryAccessSize; + +#[test] +fn test_implied_memory_width() { + fn mem_size_of(data: &[u8]) -> Option { + let decoder = InstDecoder::default(); + decoder.decode_slice(data).unwrap().mem_size().unwrap().bytes_size() + } + + // test push, pop, call, and ret + assert_eq!(mem_size_of(&[0xc3]), Some(2)); + assert_eq!(mem_size_of(&[0xe8, 0x11, 0x22, 0x33, 0x44]), Some(2)); + assert_eq!(mem_size_of(&[0x50]), Some(2)); + assert_eq!(mem_size_of(&[0x58]), Some(2)); + assert_eq!(mem_size_of(&[0x66, 0x50]), Some(2)); + assert_eq!(mem_size_of(&[0x66, 0x58]), Some(2)); + assert_eq!(mem_size_of(&[0xff, 0xf0]), Some(2)); + assert_eq!(mem_size_of(&[0x66, 0xff, 0xf0]), Some(4)); +} -- cgit v1.1