Re: about execute assembly exapmles under freebsd
From: Ryan Sommers (ryans_at_gamersimpact.com)
Date: 04/24/05
- Previous message: Tetsuji \: "Re: about execute assembly exapmles under freebsd"
- In reply to: Tetsuji \: "Re: about execute assembly exapmles under freebsd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 24 Apr 2005 06:06:22 -0500 To: "Tetsuji \"Maverick\" Rai" <maverick31337@vfemail.net>
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 _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
- Previous message: Tetsuji \: "Re: about execute assembly exapmles under freebsd"
- In reply to: Tetsuji \: "Re: about execute assembly exapmles under freebsd"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|