Beginner Delphi Embedded Assembly [4]

Source: Internet
Author: User
Tags integer

CPU provides a lot of registers, but in the process and function of Delphi, only EAX ECX EDX three registers are free to use;

If you change the other registers, restore them before the procedure and function are finished.

Remember the previous learning Delphi process and function The default calling convention is register, the first three parameters are passed through registers, and other parameters are stored and stack.

The three registers it refers to should be EAX ECX EDX.

Read the information should be: EAX accept the first parameter and then accept the return value, ECX EDX accept the following two parameters.

But I can't do the full test.//测试三个自由寄存器: EAX ECX EDX
procedure Proc(x,y,z: Integer);
var
 a,b: Integer;
begin
 asm
  MOV a,ECX
  MOV b,EDX
 end;
 ShowMessage(Format('%d,%d',[a,b]));
{EAX 我测试不了}
end;
//测试
procedure TForm1.Button1Click(Sender: TObject);
begin
 Proc(11,22,33); {显示: 33,22}
{看来寄存器 ECX 储存的是第三个参数; EDX 储存第二个参数}
end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.