I’ve written a very basic C-function called “multby22”, which does exactly what its name implies: it takes a long and returns that long multiplied by 22. (I know it’s a pointless function but I wrote it to try and help me with x86 assembly.) So:
long multby22(long x) {
return 22 * x;
}
When I complied the program and ran “objdump” on the executable, I found the disassembled code for “multby22” to be the following:
080483ff <multby22>:
80483ff: 55 push %ebp
8048400: 89 e5 mov %esp,%ebp // Create the stack frame.
8048402: 8b 45 08 mov 0x8(%ebp),%eax // Grab the argument and put it into the %eax register.
8048405: 6b c0 16 imul $0x16,%eax,%eax // ???
8048408: 5d pop %ebp // Pop the buffer pointer and return.
8048409: c3 ret
I understand that “imul” is for integer multiplication, but I have been unable to find anything that helps me with this syntax! The closest I have found is:
imul [reg] [reg] [const]
…where the 2nd and 3rd arguments are multiplied together and then placed into the 1st argument, which must be a register. In the assembly I generated, the 1st argument is a constant!
You found the right instruction. AT&T assembly syntax just happens to be “backwards” from the way everyone else does it. The destination register is on the right.
Your code is multiplying EAX by 22 (0x16) and putting the result into EAX.
If you are trying to compare instructions against the documentation, you should probably look into a disassembler that can output Intel syntax disassembly.