0

I am working on some projects about assembly and I encountered following commands:

lea    (%rsi,%rsi,4),%rax
lea    (%r9,%rax,2),%rsi
lea    (%r8,%rdx,4),%rax
movzwl 0x402ac0(%rax,%rax,1),%eax
movslq 0x402740(,%rsi,4),%rdx

what's the meaning of movzwl and movslq here? I know they move bits from a source to a destination, but before that they also did some computation, and I don't understand how they compute and then move those bits in results.

Can anyone help me with this? Thanks!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
kyandy
  • 21
  • 6
  • 2
    As noted [here](https://stackoverflow.com/questions/53146459/assembler-code-need-help-understand-what-movzwl-0x40272e-rax-4-esi-is-doi), movzwl = move zero extend word to long. You can conclude by analogy that movzlq = move zero extend long to quad. The computation is according to AT&T syntax rules. [A description of AT&T memory operand syntax](https://stackoverflow.com/questions/13517083/assembly-leal-and-movl-difference). – Raymond Chen Oct 19 '19 at 13:47

1 Answers1

2

movzwl reads a word (16 bits) from the source, zero-extends it to a long (32 bits), and writes it into the destination register.

movslq reads a long (32 bits) from the source, sign extends it to a qword (64 bits, replicating bit 31 into bits 63:32), and writes it into the destination register.

The addressing mode 0x402ac0(%rax,%rax,1) computes rax+rax+0x402ac0 and uses that as the address of the operand.

The addressing mode 0x402740(,%rsi,4) computes rsi*4+0x402740 and uses that as the address of the operand.

prl
  • 11,716
  • 2
  • 13
  • 31