Difference between revisions of "Lazarus Inline Assembler/es"
From Lazarus wiki
Jump to navigationJump to searchLine 46: | Line 46: | ||
{$I unit_asm.lrs} | {$I unit_asm.lrs} | ||
end.</syntaxhighlight> | end.</syntaxhighlight> | ||
+ | |||
+ | En el siguiente enlace podéis encontrar una muy buena descripción al respecto en la documentación de FreePascal: | ||
+ | |||
+ | [http://www.freepascal.org/docs-html/prog/progse9.html Utilizando lenguaje ensamblador en el codigo fuente] | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Revision as of 12:44, 25 June 2014
│
English (en) │
español (es) │
français (fr) │
日本語 (ja) │
한국어 (ko) │
русский (ru) │
Tiếng Việt (vi) │
Esto es un esbozo para alentar a otros a contribuir con más información. A continuación un ejemplo sencillo como punto de partida:
unit unit_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);
// Se requiere esto con Lazarus en x86, definimos el modo ensamblador de Intel:
{$ASMMODE intel}
asm
MOV EAX, num
ADD EAX, 110B //add binary 110
SUB EAX, 2 //subtract decimal 2
MOV answer, EAX
end;
edtOutput.Text := IntToStr(answer);
end;
initialization
{$I unit_asm.lrs}
end.
En el siguiente enlace podéis encontrar una muy buena descripción al respecto en la documentación de FreePascal: