Board index » delphi » Inline Assembly

Inline Assembly

I want to write the statement below using Delphi 2.01 in assembler
inside a Delphi unit, but keep getting a compile time error:

  ImgMain.Picture.LoadFromFile(Images[i]);

  asm {Begin Assembler Code}
      mov eax,[ebp-$04]
      mov eax,[eax+$000001d0]
      mov edx,[+$0042a6a8]
      mov eax,[ebp-$04]
      mov eax,[eax+$000001c4]
      mov eax,[eax+$000000ac]
      call -$0000db8c
  end; {End Assembler Code}

The error occurs on the call -$0000db8c line.

Also, the line below:

  Inc(i);

  asm {Begin Assembler Code}
      mov eax,[ebp-$04]
      inc [eax+$000001d0]
  end; {End Assembler Code}

The error occurs on the inc [eax+$000001d0] line.

Thank you very much if you can help me.

Enrique...

 

Re:Inline Assembly


[This followup was posted to comp.lang.pascal.delphi.misc and a copy was
sent to the cited author.]

In both cases you forgot to explicitly specify operand size:

Quote

>   asm {Begin Assembler Code}
>       mov eax,[ebp-$04]
>       mov eax,[eax+$000001d0]
>       mov edx,[+$0042a6a8]
>       mov eax,[ebp-$04]
>       mov eax,[eax+$000001c4]
>       mov eax,[eax+$000000ac]
>       call -$0000db8c

        {
        ^^^ that won't compile 'cause compiler doesn't now
        what -$blabla is, and what call type you mean. So,
        more correct form would be:
        }

        call  dword ptr -$0000db8c

Quote
>   end; {End Assembler Code}

>   Inc(i);

>   asm {Begin Assembler Code}
>       mov eax,[ebp-$04]
>       inc [eax+$000001d0]

        { Once again, compiler has no idea what you're
         going to increase: byte , word, or a dword value.
         For 32bit integer it will look like: }

        inc  dword [eax+$000001d0]

       { , or }

        inc  longint([eax+$000001d0])

Quote
>   end; {End Assembler Code}

Other Threads