-2
:96: Error: `(%rax,%edx,4)' is not a valid base/index expression

:97: Error: `-4(%rax,%edx,4)' is not a valid base/index expression

101: Error: `(%rax,%edx,4)' is not a valid base/index expression

102: Error: `-4(%rax,%edx,4)' is not a valid base/index expression

i get these error messages not sure how to fix it this is my code

                 "movl        $0, %6\n"
     line96      "start:        \n\t"
     line97      "movl        (%1,%3,4),%4\n\t"       
                 "movl        -4(%1, %3, 4), %5\n\t"  
             "cmpl        %4, %5\n\t"    
    line 101     "jle             next\n\t"
     line102     xchgl        %4, %5\n\t"               
                 "movl        %4, (%1, %3, 4)\n\t"        
                 "movl        %5, -4(%1, %3, 4)\n\t"        
                 "movl        $1, %6\n\t"

... my code is long so i did not want to post the whole code but i am doing a bubble sort in asm ,, when i compile i get the above error messages am not quite sure how to fix it ... if any one could explain to what is wrong will be helpful .. thanks .. sorry if the format is a bit untidy am new to this ..

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
user1055916
  • 57
  • 3
  • 6

1 Answers1

-1

You've incorrectly use indirect addressing.

It is incorrectly use ax:dx pair as base pointers with displacement. Refer to this and this for examples.

Sergei Nikulov
  • 5,029
  • 23
  • 36
  • %rax and %rdx are valid registers for either the base or index of a 64-bit addressing mode. Your last link is about 16-bit, which [doesn't allow a SIB byte so it much more restricted in which registers you can use](https://stackoverflow.com/questions/55657904/why-dont-x86-16-bit-addressing-modes-have-a-scale-factor-while-the-32-bit-vers). The actual problem here is that both registers have to be the same size if you use two in one addressing mode. (And should match the mode, unless you explicitly want to truncate the address to 32-bit. i.e. use RDX, not RAX.) – Peter Cordes Sep 28 '22 at 06:11