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 8230201
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T17:03:28+00:00 2026-06-07T17:03:28+00:00

I got some trouble accessing a static Variable with Inline Assembler in the D

  • 0

I got some trouble accessing a static Variable with Inline Assembler in the D Programming Language. The documentation says that I have to access local variables with

mov EAX, var[EBP]; //or mov EAX, var;

and class Variables with

mov EBX, this;
mov EAX, var[EBX];

But it isnt documented how to access a static Variable. Here is my code that throws an error:

module test;

static int A = 1234;

static void SetA()
{
    asm
    {
        mov A, 5432; //compiles, but throws an error
        //tried it with "mov dword ptr [A], 5432; too
    }
}

I really need a way of some “global storage” for integers that are accessible from both, assembler and D, I would be very happy about any help with this (or an alternative way).

  • 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-06-07T17:03:30+00:00Added an answer on June 7, 2026 at 5:03 pm

    Global variables are placed in thread-local storage by default in D2. Use __gshared to declare a “classic” static variable.

    This works:

    module test;
    
    __gshared int A = 1234;
    
    void SetA()
    {
        asm
        {
            mov A, 5432;
        }
    }
    
    unittest
    {
        SetA();
        assert(A == 5432);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into some trouble while creating a C-Extension for ruby that got me
I've got some trouble with the <video> element I guess. I have a little
i got some trouble to understand scope in OOP. What i want is that
I got some trouble submitting a form with ajax. Since HTML5 Form already have
I've got some trouble with .NET's ThreadPool (.NET 4). I've read that by default
I've got a program that's having some trouble during shutdown, raising exceptions that I
I've got some trouble trying to make this work. I have 2 models, User_Pro
I have real trouble understanding mod_rewrite, and got some help in creating a RewriteRule
I'm having some trouble getting my head around the jquery queue method. I've got
I'm having some trouble understanding a bit of code. I've got 2 classes Company

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.