From owner-freebsd-hackers@FreeBSD.ORG Sun Apr 24 11:06:21 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 385D116A4CE for ; Sun, 24 Apr 2005 11:06:21 +0000 (GMT) Received: from mailserv1.neuroflux.com (ns2.neuroflux.com [204.228.228.85]) by mx1.FreeBSD.org (Postfix) with ESMTP id C0B8C43D2F for ; Sun, 24 Apr 2005 11:06:20 +0000 (GMT) (envelope-from ryans@gamersimpact.com) Received: (qmail 32736 invoked by uid 1003); 24 Apr 2005 11:06:38 -0000 Received: from ryans@gamersimpact.com by mailserv1.neuroflux.com by uid 89 with qmail-scanner-1.22 (clamscan: 0.65. spamassassin: 2.60. Clear:RC:1(63.231.170.25):. Processed in 1.268871 secs); 24 Apr 2005 11:06:38 -0000 Received: from unknown (HELO ?192.168.0.5?) (63.231.170.25) by mailserv1.neuroflux.com with SMTP; 24 Apr 2005 11:06:37 -0000 Message-ID: <426B7DAE.4080502@gamersimpact.com> Date: Sun, 24 Apr 2005 06:06:22 -0500 From: Ryan Sommers User-Agent: Mozilla Thunderbird 0.7.3 (Windows/20040803) X-Accept-Language: en-us, en MIME-Version: 1.0 To: "Tetsuji \"Maverick\" Rai" References: <001601c548a5$bcdde6b0$6702a8c0@IBM6C6CDABCD41> <426B74C5.3090509@vfemail.net> In-Reply-To: <426B74C5.3090509@vfemail.net> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit cc: freebsd-hackers@freebsd.org cc: HHCHANG Subject: Re: about execute assembly exapmles under freebsd X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 24 Apr 2005 11:06:21 -0000 Something else than can be useful is to use inline assembly and the -S switch for GCC (gcc -S sourcefile, produces sourcesfile.s which is the assembly that would have been sent to gas if you had specified -o). Inline assembly example: (ryans@blue)~:cat test.c int main() { int input=0; void *edx, *ebx, *ecx, *eax; asm("cpuid" : "=a" (eax), "=b" (ebx), "=c" (ecx), "=d" (edx) : "a" (input)); printf("CPUid returned: EAX=%0.8x EBX=%0.8x ECX=%0.8x EDX=%0.8x\n", eax, ebx, ecx, edx); return 1; } (ryans@blue)~:./test CPUid returned: EAX=0001 EBX=68747541 ECX=444d4163 EDX=69746e65 (ryans@blue)~:perl -e 'print "\x41\x75\x74\x68\x65\x6e\x74\x69\x63\x41\x4d\x44\n";' AuthenticAMD (ryans@blue)~: NOTE: If the order in the Perl command confused you, remember, byte-ordering. :) Little-endian you have to reverse the bytes. -- Ryan Sommers ryans@gamersimpact.com