delorie.com/archives/browse.cgi | search |
X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
NNTP-Posting-Date: | Sat, 27 Oct 2007 23:48:39 -0500 |
Message-ID: | <472414A7.7070602@zytor.com> |
Date: | Sat, 27 Oct 2007 21:48:39 -0700 |
From: | "H. Peter Anvin" <hpa AT zytor DOT com> |
User-Agent: | Thunderbird 2.0.0.5 (X11/20070727) |
MIME-Version: | 1.0 |
Newsgroups: | comp.os.msdos.djgpp |
CC: | djgpp AT delorie DOT com |
Subject: | Re: Using inline asm |
References: | <471FEAC8 DOT 5179 DOT 2FAB88DB AT gerritvn DOT gpvno DOT co DOT za> <200710250120 DOT l9P1KEb2032374 AT envy DOT delorie DOT com> <ffp07f$66t$1 AT aioe DOT org> <200710250306 DOT l9P36dqi002391 AT envy DOT delorie DOT com> |
In-Reply-To: | <200710250306.l9P36dqi002391@envy.delorie.com> |
Lines: | 25 |
X-Usenet-Provider: | http://www.giganews.com |
NNTP-Posting-Host: | 67.169.144.158 |
X-Trace: | sv3-ZTEPNVqEV5NLgEt0NWpypR2+tgm7bfmrb2WwTdZnBFTawWpn17Fh+Py5nn6t0n4sDnfyhpJZF3wxqAJ!cAcpvNYdUZ1Iqn4TEJgHOdkaCmt7kRXha8dfrvEzt8YVAotPjB65N6Ax2apmZRUMnHRLDDh1t3Lq!WF2RD3Y= |
X-Complaints-To: | abuse AT comcast DOT net |
X-DMCA-Complaints-To: | dmca AT comcast DOT net |
X-Abuse-and-DMCA-Info: | Please be sure to forward a copy of ALL headers |
X-Abuse-and-DMCA-Info: | Otherwise we will be unable to process your complaint properly |
X-Postfilter: | 1.3.35 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
DJ Delorie wrote: >>>> asm ("cpuid" : "=a" (iRet)); >> Huh? I'm sure I missed something... That takes care of eax for cpuid, but >> that ignores ebx, ecx, and edx. cpuid trashes those four registers whether >> he returns them or not, correct? How does GCC correct the other three? > > asm ("cpuid" : "=a" (iRet) : : "ebx", "ecx", "edx"); > > Or something like that. CPUID takes %eax as an input (and sometimes %ecx): static inline unsigned int cpuid_eax(unsigned int level) { unsigned int eax; asm("cpuid" : "=a" (eax) : "a" (level) : "ebx", "ecx", "edx"); return eax; } Factoring inline assembly out into small inline functions is good programming practice. -hpa
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |