|
From: Michael D. <mic...@fr...> - 2007-07-18 11:00:12
|
haibin zhang a écrit : > --- Michael DOUBEZ <mic...@fr...>写道: > >> haibin zhang a écrit : >>> Hi All : >>> I test cpu id using as in >>> binutils-2.17.50-20070129-1.tar.gz, but it can't >>> compile pass, I have tested this in linux, it's >> ok. >>> I have two file :cpuidfunc.s stringtest.c >>> I use compile command : >>> gcc -o test.exe cpuidfunc.s stringtest.c >>> >>> It print error : >>> $ gcc -o test.exe cpuidfunc.s stringtest.c >>> cpuidfunc.s: Assembler messages: >>> cpuidfunc.s:5: Warning: .type pseudo-op used >> outside >>> of .def/.endef ignored. >>> cpuidfunc.s:5: Error: junk at end of line, first >>> unrecognized character is `c' >> [snip] > ------------------------------------------------------------------------ >>> # cpuidfunc.s - An example of returning a string >> value >>> .section .bss >>> .comm output, 13 >>> .section .text >>> .type cpuidfunc, @function >>> .globl cpuidfunc >>> cpuidfunc: >> [snip] >> >> From Gnu Assembler: >> http://tigcc.ticalc.org/doc/gnuasm.html#SEC133 >> >> .type >> >> Syntax: .type int >> >> This directive, permitted only within .def/.endef >> pairs, records the >> integer int as the type attribute of a symbol table >> entry. >> >> The line should be. >> .globl cpuidfunc >> .def .type cpuidfunc, @function; .endef >> >> > > I changed as you said, but it occur this error: > $ gcc -o haha cpuidfunc.s stringtest.c > cpuidfunc.s: Assembler messages: > cpuidfunc.s:7: Error: junk at end of line, first > unrecognized character is `c' > cpuidfunc.s:7: Error: unknown pseudo-op: `.enddef' Try the following: # cpuidfunc.s - An example of returning a string value .section .bss .comm output, 13 .global _cpuidfunc .section .text .def _cpuidfunc ; .scl 2 ; .type 32 ; .endef _cpuidfunc: pushl %ebp movl %esp, %ebp pushl %ebx movl $0,%eax cpuid movl $output, %edi movl %ebx, (%edi) movl %edx, 4(%edi) movl %ecx, 8(%edi) movl $output, %eax popl %ebx movl %ebp, %esp popl %ebp ret Michael |