From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31077 invoked by alias); 24 Mar 2004 05:53:45 -0000 Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org Received: (qmail 31065 invoked from network); 24 Mar 2004 05:53:44 -0000 Received: from unknown (HELO web8107.mail.in.yahoo.com) (203.199.70.121) by sources.redhat.com with SMTP; 24 Mar 2004 05:53:44 -0000 Message-ID: <20040324055342.29299.qmail@web8107.mail.in.yahoo.com> Received: from [202.141.24.2] by web8107.mail.in.yahoo.com via HTTP; Wed, 24 Mar 2004 05:53:42 GMT Date: Wed, 24 Mar 2004 11:25:00 -0000 From: =?iso-8859-1?q?sashti=20srinivasan?= Subject: Re: Machine Instruction encoding To: Ian Lance Taylor , gcc-help@gcc.gnu.org In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-SW-Source: 2004-03/txt/msg00228.txt.bz2 --- Ian Lance Taylor wrote: > sashti srinivasan writes: > > > The following is a line in rtems' timer driver > > source. > > asm volatile(".byte 0x0F, 0x31" : "=A" > (result)); > > > > RTEMS mailing list clarified me saying that it > is > > encoding of pentium rdtsc instruction. Please > tell me > > how the above statement differs from the one > below. > > > > asm("rdtsc result"); > > (Assuming the instruction mnemonic is correct) > > First I'll note that the assembly instruction rdtsc > does not take an > argument. The only legal asm would be asm > ("rdtsc"). I assume that > the RTEMS example uses ".byte" because it was > written before all > assemblers supported rdtsc. Or something like that. > > The difference between the plan asm and the one > which appears above is > that the one which appears above explicitly states > that the > instruction stores a result into %eax/%edx, and gcc > will store that > value into the variable "result". > > > Only thing I found from gnu documentation for > gcc > > that '=' specifies that result is a output of the > > instruction. According to the document, there > must > > be an instruction pnemonic string first inside > the > > paranthesis. But there is the directive .byte > > there. Does this mean the opcode directly? > > In this case .byte is the instruction mnemonic. The > '=' does indeed > specify the result of the instruction. > > > The document also says that the arguments can > be > > referred like %0, %1 etc. But there is nothing > like > > this here. Is it because, since there is only > one > > operand, it is assumed to follow the opcode? > > No. The instruction takes no operand. The > instruction always stores > its value into %eax/%edx. See the Intel > documentation, which is > available on the web. > > Ian Hello, Lots of thanks for the clarifications. Sorry for further simple doubts. The rdtsc instruction stores the value(of time) in registers eax and edx, and you have said that compiler puts data from these registers into the variable 'result'. But we are not specifying the registers(eax,edx) in this statement. How the compiler knows that variable 'result' should be updated based on these registers?(eax,edx do not figure in this statement). If these are documented anywhere, please give me pointers. With Regards Srinivasan ________________________________________________________________________ Yahoo! India Insurance Special: Be informed on the best policies, services, tools and more. Go to: http://in.insurance.yahoo.com/licspecial/index.html