I wrote a very basic C function called "multby22" that does exactly what its name implies: it takes a lot of time and returns that it multiplies by 22 for a long time. (I know this is a meaningless function, but I wrote it try and help me with x86 build.) So:
long multby22(long x) { return 22 * x; }
When I ran the program and ran "objdump" in the executable, I found the disassembled code for "multby22" as follows:
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 could not find anything that would help me with this syntax! The closest I found:
imul [reg] [reg] [const]
... where the 2nd and 3rd arguments are multiplied together and then placed in the 1st argument, which should be a register. In the assembly that I generated, the first argument is a constant!
source share