disassembly

x86 instruction encoding how to choose opcode

筅森魡賤 提交于 2019-12-01 17:57:21
When encode instruction cmpw %ax -5 for x86-64, from Intel-instruction-set-reference-manual, I have two opcodes to choose: 3D iw CMP AX, imm16 I Valid Valid Compare imm16 with AX. 83 /7 ib CMP r/m16, imm8 MI Valid Valid Compare imm8 with r/m16. So there will be two encoding results: 66 3d fb ff ; this for opcode 3d 66 83 f8 fb ; this for opcode 83 Then which one is better? I tried some online-disassembler below https://defuse.ca/online-x86-assembler.htm#disassembly2 https://onlinedisassembler.com/odaweb/ Both can disassemble to origin instruction. But why 6683fb00 also works and 663dfb doesn't

How to disassemble a system call

拥有回忆 提交于 2019-12-01 13:59:50
If I have the virtual address of system call, can I disassemble that system call? I want to do it on running kernel to find what all address are handled by the particular system call while running. I am running 32 bit 2.6.38 kernel (x86). I am not sure you question is very meaningful. Please read more about system calls , kernels , operating systems , linux , and the linux kernel Essentially, a system call is (from the application point of view) an atomic operation implemented by one machine instruction ( int 0x80 , syscall , etc.) with a few book-keeping instructions before (e.g. loading the

Keep getting e8 00 00 00 00 as the machine code to call a function in assembly

跟風遠走 提交于 2019-12-01 12:22:25
I know when using objdump -dr in my file call shows up in machine code as e8 00 00 00 00 because it has not yet been linked. But I need to find out what the 00 00 00 00 will turn into after the linker has done it's job. I know it should calculate the offset, but I'm a little confused about that. As an example with the code below, after the linker part is done, how should the e8 00 00 00 00 be? And how do I get to that answer? I'm testing out with this sample code: (I'm trying to call moo) Disassembly of section .text: 0000000000000000 <foo>: 0: 55 push %rbp 1: 48 89 e5 mov %rsp,%rbp 4: 89 7d

What's the best way to view accurate disassembly in VC++ 2010 while in Win32 Release mode?

不打扰是莪最后的温柔 提交于 2019-12-01 11:58:58
问题 I am writing assembly-level optimized code, and I need to make sure that the C++ compiler is working with it correctly in Release-Mode. I used to be able to get Release-Mode programs to break on breakpoints in VS 2002 (and display the raw disassembly as I stepped through it), but I can't remember how I got that to work. Does VS 2010 have any options that might allow this to happen? 回答1: Compile with /Zi and link with /DEBUG and you'll be able to set breakpoints. Under a project's Properties

What's the best way to view accurate disassembly in VC++ 2010 while in Win32 Release mode?

ぐ巨炮叔叔 提交于 2019-12-01 11:39:38
I am writing assembly-level optimized code, and I need to make sure that the C++ compiler is working with it correctly in Release-Mode. I used to be able to get Release-Mode programs to break on breakpoints in VS 2002 (and display the raw disassembly as I stepped through it), but I can't remember how I got that to work. Does VS 2010 have any options that might allow this to happen? Compile with /Zi and link with /DEBUG and you'll be able to set breakpoints. Under a project's Properties dialog: /Zi can be enabled in C++ --> General --> Debug Information Format /DEBUG can be enabled in Linker --

How can I jump relative to the PC using the gnu assembler for AVR?

偶尔善良 提交于 2019-12-01 11:29:15
I have a binary file that I've disassembled using avr-objcopy. The interrupt vector table looks like: 00000000 : ; VECTOR TABLE 0: 13 c0 rjmp .+38 ; 0x28, RESET 2: b8 c1 rjmp .+880 ; 0x374, INT0 4: fd cf rjmp .-6 ; 0x0 6: fc cf rjmp .-8 ; 0x0 8: fb cf rjmp .-10 ; 0x0 a: fa cf rjmp .-12 ; 0x0 c: f9 cf rjmp .-14 ; 0x0 e: f8 cf rjmp .-16 ; 0x0 10: f7 cf rjmp .-18 ; 0x0 12: c7 c1 rjmp .+910 ; 0x3a2, TIMER1 OVF 14: f5 cf rjmp .-22 ; 0x0 16: f4 cf rjmp .-24 ; 0x0 18: f3 cf rjmp .-26 ; 0x0 1a: f2 cf rjmp .-28 ; 0x0 1c: 2b c2 rjmp .+1110 ; 0x474, ADC conversion complete 1e: f0 cf rjmp .-32 ; 0x0 20:

In which scenario it is useful to use Disassembly language while debugging

白昼怎懂夜的黑 提交于 2019-12-01 11:09:24
I have following basic questions : When we should involve disassembly in debugging How to interpret disassembly, For example below what does each segment stands for 00637CE3 8B 55 08 mov edx,dword ptr [arItem] 00637CE6 52 push edx 00637CE7 6A 00 push 0 00637CE9 8B 45 EC mov eax,dword ptr [result] 00637CEC 50 push eax 00637CED E8 3E E3 FF FF call getRequiredFields (00636030) 00637CF2 83 C4 0C add Language : C++ Platform : Windows sharptooth It's quite useful to estimate how efficient is the code emitted by the compiler. For example, if you use an std::vector::operator[] in a loop without

In which scenario it is useful to use Disassembly language while debugging

我只是一个虾纸丫 提交于 2019-12-01 09:02:03
问题 I have following basic questions : When we should involve disassembly in debugging How to interpret disassembly, For example below what does each segment stands for 00637CE3 8B 55 08 mov edx,dword ptr [arItem] 00637CE6 52 push edx 00637CE7 6A 00 push 0 00637CE9 8B 45 EC mov eax,dword ptr [result] 00637CEC 50 push eax 00637CED E8 3E E3 FF FF call getRequiredFields (00636030) 00637CF2 83 C4 0C add Language : C++ Platform : Windows 回答1: It's quite useful to estimate how efficient is the code

x86 find out operand size of instruction given only the hex machine code?

别说谁变了你拦得住时间么 提交于 2019-12-01 03:53:22
For example, given a hex: 83 E4 F0 By looking at the intel developer's manual, I can figure out that 83 means and and FO means the -16 . Looking at E4 , I can decode that the source/destination register is either SP or ESP. Therefore, I can conclude that the hex means either and $-16, %ESP or and $-16, %SP . However, in the manual, both of those are listed as 83 /4 ib . How can I differentiate between those two? As harold says, the default operand size is not encoded in the instruction but depends on the current processor mode. In real mode and 16-bit protected mode, the default operand size

SAR command in X86 assembly with one parameter

那年仲夏 提交于 2019-12-01 02:14:14
In a disassembled program I'm analyzing, I found the command sar %eax What does this do? I know that sar with two arguments performs a right shift, but I can't find what it means with only one parameter. This program was compiled for an Intel x86 processor. Looks like the dissembler used short-hand for SAR EAX,1 which has an opcode of 0xD1F8 . when the immediate is not 1, aka SAR EAX,xx , the opcode is 0xC1F8 xx , see the Intel Instruction reference, Vol. 2B, 4-353. Siri When there is only one operand the implied shift is 1. So.... SAR %EAX implies signed %EAX >> 1 therefor, SAR %eax = SAR $1,