Talk:X86 Assembly/Other Instructions

Function to check for CPUID
the shift [shr] to position 2^0 is 1 to short, 0x15 [21] works just fine [tested on x86-64]. 62.216.215.59 (discuss) 23:17, 28 March 2023 (UTC)

Untitled
what does "cdq" do? I can't find it 137.148.5.13 23:59, 15 March 2006 (UTC)

cdq is "Convert Doubleword to Quadword". Essentially, it sign-extends eax into edx. See http://docs.sun.com/app/docs/doc/817-5477/6mkuavhri?a=view.

sysenter mention of protected system mode
This is also known as kernel mode or supervisor mode. Protected mode is the term used for the state the processor is in when 32 bit is enabled. The use of "protected system mode" may be confusing. I am going to add that the mode referring to is supervisor mode for clarification.

Good info on RDTSC, but not enough background on code snippet
The listing demonstrating a use of the RDTSC would assemble per the instructions, but would not link. I'm guessing the author's development environment has something set up that I don't. There appears to be enough information there for the topic at hand, but I'm going to have to do substantial digging to make use of it.
 * It could be that you are running on a 64bit system, I edited the instructions to be more portable, hopefully the modified instructions work for you.

Syaghmour (discuss • contribs) 02:22, 1 November 2012 (UTC)

I don't think that's the problem. I was running CygWin, getting a linker error "undefined reference to '_WinMain@16' ". I'm hoping to get Ubuntu running on my target system later today, and I will try it there. Meanwhile, I think I have enough information to make use of the RDTSC instruction for my purpose, which differs a bit from the example. What I need to do is output a 1 on an I/O line, and return it to a zero after a precise interval (from 1 to 25 us, depending on which test I'm running).
 * I was able to figure out how to get it working on cygwin, or at least a way to get it working. The code requires the following modifications:

 main has to be renamed to _WinMain@16 #printf needs to be changed to _printf The interrupt to call exit(3) needs to be replaced with a ret 16 

The full but reduced code is as follows:

To build you will need to do as follows:

The following article has good set of Linux and Windows assembly language programs and how to build across both platforms:x86 Assembly Language Programming

That material should eventually be incorporated under the Syntaxes and Assemblers section.

I don't follow your other comments on your intended use of RDTSC but if you look under the resources section there is a good pdf with more details on RDTSC that I put up a little while ago.

Syaghmour (discuss • contribs) 01:24, 3 November 2012 (UTC)