Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Lazarus - Inline assembly

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Hatschi
Master Cheater
Reputation: 2

Joined: 28 Jan 2010
Posts: 327

PostPosted: Sun Jun 23, 2019 10:38 am    Post subject: Lazarus - Inline assembly Reply with quote

I'm trying to write inline assembly in lazarus but I get several error messages like this:

Code:
Error: Unknown identifier "EAX"



Code:
unit unt_asm;
{$mode objfpc}{$H+}
//[...]
procedure TForm1.btnGoClick(Sender: TObject);
var
  num, answer : integer;
begin
  num := StrToInt(edtInput.Text);
  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;
end.


How can I fix these errors?

//edit: Fixed myself, I've missed the line {$ASMMODE intel}
Back to top
View user's profile Send private message
MrViZZion
Cheater
Reputation: 1

Joined: 13 Aug 2019
Posts: 35

PostPosted: Wed Aug 28, 2019 4:10 pm    Post subject: Reply with quote

Was gonna mention that hehe. By the way, here's a neat trick.

{$ASMMODE intel}
{$IFDEF CPUX86}
asm
//ASM
{$ELSE}
{$IFDEF CPUX64}
asm
//ASM
end;
{$ENDIF CPUX64}
{$ENDIF}

This way you can write different code for 32 and 64 bit (comes very handy).
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites