Bản sao wikibản sao

Đây là bản sao của wiki tại pascal.chat. Việc sửa, lịch sử và đăng nhập ở bên đó.

Lazarus Inline Assembler/vi

한국어 · English · Español · Français · Tiếng Việt · Русский · 日本語

1 ví dụ đơn giản về sử dụng inline assembler trong Lazarus:

pascal
unit unt_asm;
{$mode objfpc}{$H+}
interface
uses
  Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
type
  { TForm1 }
  TForm1 = class(TForm)
    btnGo: TButton;
    edtInput: TEdit;
    edtOutput: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    procedure btnGoClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 
var
  Form1: TForm1; 
implementation
{ TForm1 }

procedure TForm1.btnGoClick(Sender: TObject);
var
  num, answer : integer;
begin
  num := StrToInt(edtInput.Text);
  //This is required with Lazarus on x86:
  {$ASMMODE intel}
  asm//cộng thêm 110 (hệ cơ số 2)//trừ đi 2 (hệ cơ số 10)
    MOV EAX, num
    ADD EAX, 110B //cộng thêm 110 (hệ cơ số 2)
    SUB EAX, 2    //trừ đi 2 (hệ cơ số 10)
    MOV answer, EAX
  END;
  edtOutput.Text := IntToStr(answer);
end;

initialization
  {$I unt_asm.lrs}
end.

Xem thêm


From the Free Pascal wiki, page "Lazarus Inline Assembler/vi", as it stood on 2020-02-18 after a change by Trev, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Phiên bản 1, sửa lần cuối bởi WikiArchive .