分类: LINUX
2008-08-28 15:49:10
#cpuid.s Sample program
.section .data
output:
.ascii "The processor Vendor ID is 'xxxxxxxxxxxx'\n"
.section .text
.globl _start
_start:
nop //gdb中暂停程序用
movl $0, %eax
cpuid
movl $output, %edi
movl %ebx, 28(%edi)
movl %edx, 32(%edi)
movl %ecx, 36(%edi)
movl $4, %eax
movl $1, %ebx
movl $output, %ecx
movl $42, %edx
int $0x80
movl $1, %eax
movl $0, %ebx
int $0x80
$as -gstabs -o cpuid.o cpuid.s
$ld -o cpuid cpuid.o
$
$gdb cpuid
GNU gdb //此处为版权信息若干行
(gdb)
(gdb)run
Starting program: /home/path/cpuid
The processor Vendor ID is 'GenuineIntel'
Program exited normally
(gdb)
(gdb)break * _start+1
Breakpoint 1 at 0x12345678: file cpuid.s 12
(gdb)run
Starting program: /home/path/cpuid
Breakpoint 1,_start() at cpuid.s 12
12 movl $0, $eax
(gdb)
(gdb)next
_start() at cpuid.s:13
13 cpuid
(gdb)step
_start() at cpuid.s:14
14 movl $output, %edi
(gdb)cont
Continuing.
The processor Vendor ID is 'GenuineIntel'
Program exited normally
(gdb)
(gdb)next
_start() at cpuid.s:13
13 cpuid
(gdb)info registers
eax 0x0 0
ecx 0x0 0
... ... ... //其他寄存器省略
gs 0x0 0