Why isn’t my assembly program setting r1 to the correct value?

HALT is just a “pseudo-instruction” for a TRAP instruction used to halt the machine. You could write: TRAP x25 ;HALT the machine But in this way you need to remember the position in the TRAP vector, in this case x25. So is better to just use HALT instead. Others common TRAPs also have pseduo-instructions: IN, … Read more

How to determine if the registers are loaded right to left or vice versa

Normally, Gnu tools use AT&T syntax. You can tell that it is AT&T syntax by the presence of little symbols, like the $ preceding literals, and the % preceding registers. For example, this instruction: sub $16, %rax is obviously using AT&T syntax. It subtracts 16 from the value in the rax register, and stores the … Read more

CPU TSC fetch operation especially in multicore-multi-processor environment

Straight from Intel, here’s an explanation of how recent processors maintain a TSC that ticks at a constant rate, is synchronous between cores and packages on a multi-socket motherboard, and may even continue ticking when the processor goes into a deep sleep C-state, in particular see the explanation by Vipin Kumar E K (Intel): http://software.intel.com/en-us/articles/best-timing-function-for-measuring-ipp-api-timing/ … Read more

What are the names of the new X86_64 processors registers?

The MSDN documentation includes information about the x64 registers. x64 extends x64’s 8 general-purpose registers to be 64-bit, and adds 8 new 64-bit registers. The 64-bit registers have names beginning with “r”, so for example the 64-bit extension of eax is called rax. The new registers are named r8 through r15. The lower 32 bits, … Read more

Reading a register value into a C variable [duplicate]

Editor’s note: this way of using a local register-asm variable is now documented by GCC as “not supported”. It still usually happens to work on GCC, but breaks with clang. (This wording in the documentation was added after this answer was posted, I think.) The global fixed-register variable version has a large performance cost for … Read more