Search code examples
assemblyx86-64inline-assemblyaddressing-mode

asm compile issue


: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 ..


Solution

  • 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.