Difference between revisions of "Lazarus Inline Assembler/vi"
From Lazarus wiki
Jump to navigationJump to searchm (Fixed syntax highlighting; deleted category included in page template) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 2: | Line 2: | ||
1 ví dụ đơn giản về sử dụng inline assembler trong Lazarus: | 1 ví dụ đơn giản về sử dụng inline assembler trong Lazarus: | ||
− | <syntaxhighlight> | + | |
+ | <syntaxhighlight lang=pascal> | ||
unit unt_asm; | unit unt_asm; | ||
{$mode objfpc}{$H+} | {$mode objfpc}{$H+} | ||
Line 50: | Line 51: | ||
* [[VirtualTreeview Example for Lazarus]] | * [[VirtualTreeview Example for Lazarus]] | ||
− | |||
− |
Latest revision as of 00:18, 19 February 2020
│
English (en) │
español (es) │
français (fr) │
日本語 (ja) │
한국어 (ko) │
русский (ru) │
Tiếng Việt (vi) │
1 ví dụ đơn giản về sử dụng inline assembler trong Lazarus:
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
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.