0
        mov edi, 4
    mov ecx, 10
    read:
        lea eax, [ebp-edi] ;error line
        push eax
        
        
        call readVal
        add edi, 4
    loop read

        add esp, 40

I am trying to allocate an array of 10 elements of a local variable in a function. I keep getting invalid effective address.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
Rheagar
  • 31
  • 4
  • 1
    There is no addressing mode that would allow subtraction of two registers as part of effective address calculation. You can only do `reg+reg*m+n` where `m` is 2, 4 or 8 (not -1). Consider making the calculation with regular arithmetic instructions beforehand and then using a single register for addressing. – CherryDT Nov 09 '22 at 07:08
  • You'll need two instructions, mov + sub, to get the value you want to push without overwriting EBP. – Peter Cordes Nov 09 '22 at 07:34

0 Answers0