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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:05:59+00:00 2026-05-19T13:05:59+00:00

I’m trying to get some c & ASM sample code I found running in

  • 0

I’m trying to get some c & ASM sample code I found running in Visual Studio 2008. I don’t think the problem is the difference between VS 2005-2008. This example is supposed to get the CPUID on 64-bit systems. (My attempts getting the ASM-only 32-bit examples to compile failed too)

I can copy and paste this code into a new project, but I have not been able to build it. I’ve tried a few different VS project templates with no success. I believe I followed the instructions all the way. Can someone provide a step-by-step to get this running in Visual Studio 2008 with the project template and project settings?

One thing I’ve noticed is that although I can make the environment be 64-bit, I can’t seem to target x64 for this project – the only options for adding new platforms are mobile platforms. And I’ve had to manually define _M_X64 in the command-line options, which I suspect I shouldn’t have to do.

Not to be debugged directly, but just for your info – Errors, as far as I got, are as follows:

1> Assembling: .\cpuid64.asm
1>.\cpuid64.asm(4) : error A2013:.MODEL must precede this directive
1>.\cpuid64.asm(5) : error A2034:must be in segment block
1>.\cpuid64.asm(7) : error A2034:must be in segment block : cpuid64
1>.\cpuid64.asm(11) : error A2034:must be in segment block
1>.\cpuid64.asm(12) : error A2008:syntax error : .
1>.\cpuid64.asm(13) : error A2034:must be in segment block
1>.\cpuid64.asm(14) : error A2008:syntax error : .
1>.\cpuid64.asm(15) : error A2008:syntax error : .
1>.\cpuid64.asm(17) : error A2034:must be in segment block
1>.\cpuid64.asm(18) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(19) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(20) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(21) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(22) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(23) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(24) : error A2085:instruction or register not accepted in current CPU mode
1>.\cpuid64.asm(26) : error A2034:must be in segment block
1>.\cpuid64.asm(27) : error A2034:must be in segment block
1>.\cpuid64.asm(29) : error A2034:must be in segment block
1>.\cpuid64.asm(30) : error A2034:must be in segment block
1>.\cpuid64.asm(31) : fatal error A1010:unmatched block nesting : cpuid64
  • 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-19T13:05:59+00:00Added an answer on May 19, 2026 at 1:05 pm

    Well, if you can’t target x64, you have a slight problem because you’re not using the x64 toolchain. I strongly suggest you use the VS install wizard to add in the x64 tools. You should be able to go to new platform, call it x64 and base it on win32.

    Having said that, I actually recommend using YASM because it allows you to integrate with VS, and YASM is by far a nicer assembler than Microsoft’s.

    Since I happen to have a project that would benefit from this anyway, I thought I’d do it using yasm:

    gcpuid.asm:

    ; CPUID on x64-Win32
    ; Ref: 
    
    section .code
    global gcpuid
    
    ; void cpuid(uint32_t* cpuinfo, char* vendorstr);
    
    gcpuid:
    
        push rbp
        mov  rbp, rsp
    
        mov  r8, rcx   ; capture the first and second arguments into 1-> r8, 2-> r9
        mov  r9, rdx   ; cause cpuid will obliterate the lower half of those regs
    
        ; retrive the vendor string in its
        ; three parts
        mov eax, 0
        cpuid
        mov [r9+0], ebx    
        mov [r9+4], edx
        mov [r9+8], ecx
    
        ; retrieve the cpu bit string that tells us
        ; all sorts of juicy things
        mov eax, 1
        cpuid
        mov [r8], eax
        mov eax, 0
    
        leave
        ret
    

    cpuid-w32.c:

    #include <stdio.h>
    #include <stdint.h>
    
    void gcpuid(uint32_t* cpuinfo, char* vendorstr);
    
    int main(int argc, char** argv)
    {
        char vendor[13] = { 0 };
        uint32_t flags;
    
        gcpuid(&flags, vendor);
        printf("Flags: %u, Vendor: %s\n", flags, vendor);
    
        return 0;
    }
    

    Following readme.txt in the vs2010 archive supplied on the links download page, it was a doddle to get vs to assemble this, and this solution is much clearer, I think, than intels.

    As to what you do with the cpuinfo parameter, well, you can try various masks to find out all sorts of info about the cpu type. I might update if I finish the implementation.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
Basically, what I'm trying to create is a page of div tags, each has
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
I have just tried to save a simple *.rtf file with some websites and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.