Date: Sun, 24 Apr 2005 06:06:22 -0500 From: Ryan Sommers <ryans@gamersimpact.com> To: "Tetsuji \"Maverick\" Rai" <maverick31337@vfemail.net> Cc: HHCHANG <b8701143@tmu.edu.tw> Subject: Re: about execute assembly exapmles under freebsd Message-ID: <426B7DAE.4080502@gamersimpact.com> In-Reply-To: <426B74C5.3090509@vfemail.net> References: <001601c548a5$bcdde6b0$6702a8c0@IBM6C6CDABCD41> <426B74C5.3090509@vfemail.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?426B7DAE.4080502>
