Sign in Join
Wiki copytemporary

Lazarus Inline Assembler/vi: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: Lazarus Inline Assembler/vi

OldNewLine
1+1 ví dụ đơn giản về sử dụng inline assembler trong Lazarus:
2+
3+``` pascal
4+unit unt_asm;
5+{$mode objfpc}{$H+}
6+interface
7+uses
8+ Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs, StdCtrls;
9+type
10+ { TForm1 }
11+ TForm1 = class(TForm)
12+ btnGo: TButton;
13+ edtInput: TEdit;
14+ edtOutput: TEdit;
15+ Label1: TLabel;
16+ Label2: TLabel;
17+ procedure btnGoClick(Sender: TObject);
18+ private
19+ { private declarations }
20+ public
21+ { public declarations }
22+ end;
23+var
24+ Form1: TForm1;
25+implementation
26+{ TForm1 }
27+
28+procedure TForm1.btnGoClick(Sender: TObject);
29+var
30+ num, answer : integer;
31+begin
32+ num := StrToInt(edtInput.Text);
33+ //This is required with Lazarus on x86:
34+ {$ASMMODE intel}
35+ asm
36+ MOV EAX, num
37+ ADD EAX, 110B //cộng thêm 110 (hệ cơ số 2)
38+ SUB EAX, 2 //trừ đi 2 (hệ cơ số 10)
39+ MOV answer, EAX
40+ end;
41+ edtOutput.Text := IntToStr(answer);
42+end;
43+
44+initialization
45+ {$I unt_asm.lrs}
46+end.
47+```
48+
49+## Xem thêm
50+
51+- [[VirtualTreeview Example for Lazarus]]
52+
53+---
54+*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](/wiki-contact).*

Back to history