0

I am trying to figure out what these lines of code do

movsbq (%rbx),%rcx

and

add (%rdx,%rcx,4),%eax

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
coder_gurl
  • 11
  • 2
  • This isn't really a good question for this site. Please see https://stackoverflow.com/help/on-topic – pcarter Oct 25 '19 at 17:31
  • Possible duplicate of [What is the meaning of MOV (%r11,%r12,1), %edx?](https://stackoverflow.com/questions/2883850/what-is-the-meaning-of-mov-r11-r12-1-edx) – Peter Cordes Oct 25 '19 at 23:08
  • And of [Please verify meaning of AT&T Assembly line](//stackoverflow.com/a/14954482) for the `movsbq` (I broke my duphammer by removing `[x86]` and adding `[x86-64]`, oops. Even though I have a gold badge in both tags) – Peter Cordes Oct 25 '19 at 23:09

1 Answers1

2

MOVSBQ reads one byte from the source, signs extends it to a quad word (64 bits, replicating bit 7 into bits 63:8) and writes the value to the destination register.

The addressing mode (%r1,%r2,4) computes the address of the operand as R1 + R2 * 4. The ADD instruction reads the DWORD at that address and adds it to EAX.

prl
  • 11,716
  • 2
  • 13
  • 31