What is the jmpq command doing in this example

From the GAS-manual: An Intel syntax indirect memory reference of the form is translated into the AT&T syntax where base and index are the optional 32-bit base and index registers, disp is the optional displacement, and scale, taking the values 1, 2, 4, and 8, multiplies index to calculate the address of the operand. (https://sourceware.org/binutils/docs/as/i386_002dMemory.html#i386_002dMemory) … Read more

Difference between movq and movabsq in x86-64

In NASM / Intel syntax, mov r64, 0x… picks a MOV encoding based on the constant. There are four to choose from with immediate operands: 5 byte mov r32, imm32. (zero-extended to fill the 64-bit register like always). AT&T: mov/movl 6+ byte mov r/m32, imm32. only useful for memory destinations. AT&T: mov/movl 7+ byte mov r/m64, sign-extended-imm32. Can store 8 bytes to memory, or set … Read more

What does movslq do?

It’s movsxd: https://www.felixcloutier.com/x86/MOVSX:MOVSXD.html. You could figure this out yourself by assembling it with an AT&T assembler and disassembling with an Intel-syntax disassembler. (e.g. objdumpd -d -Mintel foo.o) And yes, it does 32->64-bit 2’s complement sign extension, extending by copying the sign-bit of the source to all the new upper bits. (i.e. dst[63:32] = src[31], and dst[31:0] = src[31:0].) Fun fact: it’s … Read more

movq assembly function

movq (assuming you’re talking about x86) is a move of a quadword (64-bit value). This particular instruction: looks very much like code that will walk up through stack frames. This particular instruction grabs the quadword pointed to by the current stack pointer, and loads it into the stack pointer, overwriting it. By way of example, this … Read more

What is callq instruction?

It’s just call. Use Intel-syntax disassembly if you want to be able to look up instructions in the Intel/AMD manuals. The q operand-size suffix does technically apply (it pushes a 64-bit return address and treats RIP as a 64-bit register), but there’s no way to override it with instruction prefixes. i.e. calll and callw aren’t encodeable in 64-bit mode, so it’s just … Read more

x86 cmpl and jne

Cmpl subtracts -0x10(%ebp) from $0x7 and modifies flags: AF CF OF PF SF ZF. If memory at -0x10(%ebp) equals immediate 0x7 then the flag ZF is set. This is below EBP so it’s probably a local variable, if this is an un-optimized build using EBP as a frame pointer. jne 80484db means that if the two compared numbers are different … Read more