Delphi Assembly Function Returning a Long String

后端 未结 2 1015
天命终不由人
天命终不由人 2021-01-15 13:26

I am trying to learn inline assembly programming in Delphi, and to this end I have found this article highly helpful.

Now I wish to write an assembly function return

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 13:51

    You have to use some kind of:

    function myfunc: AnsiString;
    asm
      push eax // save @result
      call system.@LStrClr
      mov    eax,3                 {Length}
    {$ifdef UNICODE}
      mov    edx,1252 // code page for Delphi 2009/2010
    {$endif}
      call   system.@NewAnsiString
      pop edx
      mov [edx],eax
      mov [eax],$303132
    end;
    

    It will return a '210' string...

    And it's always a good idea of putting a {$ifdef UNICODE} block to have your code compatible with version of Delphi prior to 2009.

提交回复
热议问题