0

I was taught that I could use this instruction:

movl (arr,%r8,4),%eax

in case I wanted to do:

%eax=Mem[arr+4*%r8]

However this command doesn't seem to be recognized at all and I am getting an error:

Error: Found ',', expected ')'
Error: junk ',%r8,4)' after expression

I can't understand. Is this a real instruction or not?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
EL_9
  • 404
  • 2
  • 10
  • 1
    Your syntax is wrong. Try `movl arr(,%r8,4), %eax` instead. Also note that it's called “instruction,” not “command.” – fuz Apr 11 '20 at 09:37
  • @fuz From what I can tell this does Mem[%eax]=Mem[arr+4*%r8]? I get a seg fault for trying to approach the address of %eax using this instruction. – EL_9 Apr 11 '20 at 09:48
  • 1
    No, this loads `eax` (the register) with the content of the memory at address `arr+4*r8`. It does not load the memory at address `eax`. – fuz Apr 11 '20 at 09:50
  • For assembler there are two common, but different syntaxes: Intel & AT&T. Please check, which one you should use: https://imada.sdu.dk/~kslarsen/dm546/Material/IntelnATT.htm – Sebastian Apr 11 '20 at 10:28
  • 2
    Check the error message: it is not complaining about `mov`. – Erik Eidt Apr 11 '20 at 14:37
  • 1
    displacement (the symbol) goes outside the parens; only registers and the scale factor go in the parens. – Peter Cordes Apr 11 '20 at 15:09

0 Answers0