Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3932848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:32:07+00:00 2026-05-19T23:32:07+00:00

I am running into some weird behaviour with Delphi’s inline assembly, as demonstrated in

  • 0

I am running into some weird behaviour with Delphi’s inline assembly, as demonstrated in this very short and simple program:

program test;

{$APPTYPE CONSOLE}

uses
    SysUtils;

type
    TAsdf = class
    public
        int: Integer;
    end;

    TBlah = class
    public
        asdf: TAsdf;

        constructor Create(a: TAsdf);

        procedure Test;
    end;

constructor TBlah.Create(a: TAsdf);
begin
    asdf := a;
end;

procedure TBlah.Test;
begin
    asm
        mov eax, [asdf]
    end;
end;

var
    asdf: TAsdf;
    blah: TBlah;

begin
    asdf := TAsdf.Create;

    blah := TBlah.Create(asdf);

    blah.Test;

    readln;
end.

It’s just for the sake of example (moving [asdf] into eax doesn’t do much, but it works for the example). If you look at the assembly for this program, you’ll see that

mov eax, [asdf]

has been turned into

mov eax, ds:[4]

(as represented by OllyDbg) which obviously crashes. However, if you do this:

var
    temp: TAsdf;
begin
    temp := asdf;

    asm
        int 3;
        mov eax, [temp];
    end;

It changes to
mov eax, [ebp-4]
which works. Why is this? I’m usually working with C++ and I’m used to using instance vars like that, it may be that I’m using instance variables wrong.

EDIT: Yep, that was it. Changing mov eax, [asdf] to mov eax, [Self.asdf] fixes the problem. Sorry about that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:32:08+00:00Added an answer on May 19, 2026 at 11:32 pm

    A method receives the Self pointer in the EAX register. You have to use that value as the base value for accessing the object. So your code would be something like:

    mov ebx, TBlah[eax].asdf
    

    See http://www.delphi3000.com/articles/article_3770.asp for an example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Flex 4 and running into some problems displaying a simple alert
I'm currently running into some issues resizing images using GD. Everything works fine until
I'm running into some little glitch on Internet Explorer. The site looks like it
Looking for some direction here as I'm running into some migration problems. We have
I am trying to get some XML data with LINQ, but running into a
I've just started doing some PowerShell scripting, and I'm running into a problem testing
Been running into this problem lately... When debugging an app in VS.Net 2005, breakpoints
It's been a long time since I've done C++ and I'm running into some
I having been running into some strange problems with a webpage that I have
I'm running into some issues when constructing a query using LINQ and Entity Framework.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.