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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:41:42+00:00 2026-05-17T23:41:42+00:00

I already asked similar question here, but I still get some errors, so I

  • 0

I already asked similar question here, but I still get some errors, so I hope you could tell me what am I doing wrong. Just know that I know assembler, and I have done several projects in 8051 assembler, and even it is not the same, is close to x86 asm.

There is block of code I tried in VC++ 2010 Express (I am trying to get information from CPUID instruction): `

int main()
{
char a[17]; //containing array for the CPUID string
a[16] = '\0'; //null termination for the std::cout
void *b=&a[0]; 
int c=0; //predefined value which need to be loaded into eax before cpuid

_asm
{
    mov eax,c;
    cpuid;
    mov [b],eax;
    mov [b+4],ebx;
    mov [b+8],ecx;
    mov [b+12],edx;
}
std::cout<<a;
}`

So, to quick summarize, I tried to create void pointer to the first element of array, and than using indirect addressing just move values from registers. But this approach gives me “stack around b variable is corrupted run-time error” but I don´t know why.

Please help. Thanks. And this is just for study purposes, i know there are functions for CPUID….

EDIT: Also, how can you use direct addressing in x86 VC++ 2010 inline assembler? I mean common syntax for immediate number load in 8051 is mov src,#number but in VC++ asm its mov dest,number without # sign. So how to tell the compiler you want to access memory cell adress x directly?

  • 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-17T23:41:43+00:00Added an answer on May 17, 2026 at 11:41 pm

    The reason your stack is corrupted is because you’re storing the value of eax in b. Then storing the value of ebx at the memory location b+4, etc. The inline assembler syntax [b+4] is equivalent to the C++ expression &(b+4), if b were a byte pointer.

    You can see this if you watch b and single-step. As soon as you execute mov [b],eax, the value of b changes.

    One way to fix the problem is to load the value of b into an index register and use indexed addressing:

    mov edi,[b]
    mov [edi],eax
    mov [edi+4],ebx
    mov [edi+8],ecx
    mov [edi+12],edx
    

    You don’t really need b at all, to hold a pointer to a. You can load the index register directly with the lea (load effective address) instruction:

    lea edi,a
    mov [edi],eax
    ... etc ...
    

    If you’re fiddling with inline assembler, it’s a good idea to open the Registers window in the debugger and watch how things change when you’re single stepping.

    You can also directly address the memory:

    mov dword ptr a,eax
    mov dword ptr a+4,ebx
    ... etc ...
    

    However, direct addressing like that required more code bytes than the indexed addressing in the previous example.

    I think the above, with the lea (Load Effective Address) instruction and the direct addressing I showed answers your final question.

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

Sidebar

Related Questions

I already asked a similar question but still can't get it to work. I
I'm afraid very similar question has been asked already here , but for some
I asked a similar question to this already, but I still can't see the
I already asked a similar question here , however I didn't really get the
I already asked a similar question, PE Header requirements , but I'm not really
I've already asked a similar question but this is slightly different so i Thought
I have already asked a similar question earlier but I have notcied that I
I have asked a similar question to this one already but I think it
I already asked a similar question but this one is a bit different/specific: I'm
I have asked a similar question previously but it was never resolved so here

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.