Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Access CPU register

Access CPU register

Scheduled Pinned Locked Moved C / C++ / MFC
tutorialquestion
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    ludi0423
    wrote on last edited by
    #1

    Hello, Could anyone tell me how to access the CPU register in C? Thanks

    _ 1 Reply Last reply
    0
    • L ludi0423

      Hello, Could anyone tell me how to access the CPU register in C? Thanks

      _ Offline
      _ Offline
      _Superman_
      wrote on last edited by
      #2

      In Windows and x86, you can use the __asm keyword to write inline assembly and then access the registers by its name (eax, ebx etc.). __asm is not supported in x64.

      «_Superman_» I love work. It gives me something to do between weekends.
      Microsoft MVP (Visual C++)

      L 1 Reply Last reply
      0
      • _ _Superman_

        In Windows and x86, you can use the __asm keyword to write inline assembly and then access the registers by its name (eax, ebx etc.). __asm is not supported in x64.

        «_Superman_» I love work. It gives me something to do between weekends.
        Microsoft MVP (Visual C++)

        L Offline
        L Offline
        ludi0423
        wrote on last edited by
        #3

        Thanks, Superman. And I wonder whether the keyword "register" is possible to be used to specify a register in the processor? :)

        _ R 2 Replies Last reply
        0
        • L ludi0423

          Thanks, Superman. And I wonder whether the keyword "register" is possible to be used to specify a register in the processor? :)

          _ Offline
          _ Offline
          _Superman_
          wrote on last edited by
          #4

          No. The register keyword is used as a hint to the compiler to store the variable into a general purpose register instead of a memory location.

          «_Superman_» I love work. It gives me something to do between weekends.
          Microsoft MVP (Visual C++)

          1 Reply Last reply
          0
          • L ludi0423

            Thanks, Superman. And I wonder whether the keyword "register" is possible to be used to specify a register in the processor? :)

            R Offline
            R Offline
            Rajesh R Subramanian
            wrote on last edited by
            #5

            There's no guarantee that the variable will be put into a register at all, so leave alone a "specific" register.

            “Follow your bliss.” – Joseph Campbell

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups