程序集文件:.a .s .asm之间的区别 [英] Assembly Files: Difference between .a .s .asm
问题描述
在MIPS模拟器"QTSpim"中,接受三种类型的文件:
In the MIPS simulator "QTSpim", three types of files are accepted:
-
.a
-
.s
-
.asm
.a
.s
.asm
这些文件类型之间是否有区别,如果是,区别是什么?
Is there a difference between those filetypes, and if yes, what is the difference?
推荐答案
在Unix/Linux系统中:
In Unix/Linux systems:
-
.a
是静态库(也就是使用ar(1)
制作的多个.o
文件的存档)的常用扩展名.动态库(也称为共享库)使用.so
. -
.s
用于asm编译器输出. (gcc -S foo.c
生成asm输出,默认文件名为foo.s
) -
.S
用于手写的asm源文件.gcc -c foo.S
通过C预处理程序运行它(因此您可以使用#include<>
,#if
,#define
和C样式注释.)某些C头文件(例如asm/unistd.h
)仅具有#define
,依此类推.可以包含在.S中,以获取诸如__NR_write
系统调用号之类的定义.
.a
is the usual extension for static libraries (aka Archives of multiple.o
files, made withar(1)
). Dynamic libraries, aka Shared Objects, use.so
..s
is used for asm compiler output. (gcc -S foo.c
produces asm output, with a default filename offoo.s
).S
is used for hand-written asm source files.gcc -c foo.S
runs it through the C preprocessor (so you can use#include<>
,#if
,#define
, and C-style comments.) Some C headers, likeasm/unistd.h
only have#define
s, and so can be included in a .S to get definitions like__NR_write
system call numbers, for example.
在x86中,有两种不同版本的asm语法:AT& T(由gcc之类的Unix编译器使用)和Intel/NASM(有两种方言,如MASM与NASM本身).
In x86, there are two separate versions of asm syntax: AT&T (used by Unix compilers like gcc), and Intel/NASM (with a couple dialects, like MASM vs. NASM itself).
.S
适用于GNU as
语法中的asm,无论是否使用任何C预处理器功能.
.S
is appropriate for asm in GNU as
syntax, whether you use any C preprocessor features or not.
在x86中,.asm
通常与Intel语法NASM/YASM或MASM源代码关联.在x86之外,如果它使用
In x86, .asm
is more often associated with Intel-syntax NASM/YASM, or MASM, source code. Outside of x86, it's probably a good choice for asm source files that could be assembled by the platform-specific assembler, if it uses different directives than GNU as
.
具有gcc背景的人们可能会将其MIPS组件放入.S
或.s
文件中,而具有更多NASM/YASM经验(或Windows)的人可能会选择.asm
.
People with a gcc background might put their MIPS asm into .S
or .s
files, while people with more NASM/YASM experience (or Windows), might go for .asm
.
我建议不要使用.s
文件,因为很容易被gcc -S foo.c
意外覆盖.
I'd recommend against .s
files, because it's easy to accidentally overwrite with gcc -S foo.c
.
这篇关于程序集文件:.a .s .asm之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!