Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the difference between the assembly language tutorial file suffix case S

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the difference between upper and lower case S in assembly language tutorial files?" friends who are interested may wish to have a look. The method introduced in this paper is simple, fast and practical. Next, let the editor take you to learn "what is the difference between the upper and lower case of assembly language tutorial files?"

I. difference between uppercase and lowercase suffixes

.s assembly language source program; assembly.

.s assembly language source code; preprocessing, assembly

The lowercase s file is not preprocessed at a later stage, so we cannot write preprocessing statements in it.

Uppercase S file will also perform preprocessing, assembly and other operations, so we can add preprocessing commands to it.

Second, the related process of compilation

Preprocessing (Pre-Processing)-- > compilation (Compiling)-- > assembly (Assembling)-- > link (Linking)

1. Preprocessor

Modify the original C program according to the command (directives) that begins with the character #.

This stage will not check for errors in the code, but will only convert the statements of # into C code.

2. Compilation phase

At this stage, Gcc first checks the standardization of the code, whether there are syntax errors, etc., to determine the actual work of the code, and after checking it correctly, Gcc translates the code into assembly language. Users can view it using the "- S" option, which only compiles and does not assemble to generate assembly code. Assembly language is very useful because it provides a common language for different high-level languages and different compilers. For example, both the C compiler and the Fortran compiler produce output files using the same assembly language.

3. Compilation stage

The assembly phase is to convert the ".s" file generated during the compilation phase into an object file, where the reader can use the option "- c" to see that the assembly code has been converted into the binary object code of ".o".

4. Link stage

Link the library functions (used in the header file) and so on to the target file.

After a successful compilation, you enter the linking phase. An important concept is involved here: function library.

There is only the declaration of the function in "stdio.h", but the implementation of the function is not defined, so where do the library functions of "printf" be implemented? The final answer is: the system to achieve these functions are called libc.so.6 library file to go, when there is no special specified, gcc will go to the system default search path "/ usr/lib" under the search, that is, link to the libc.so.6 library function, so you can achieve the function "printf", and this is the role of the link.

Function libraries are generally divided into static libraries and dynamic libraries. Static library means that when compiling a link, all the code of the library file is added to the executable file, so the resulting file is larger, but the library file is no longer needed at run time. It is generally renamed ".a" after it. On the contrary, the dynamic library does not add the code of the library file to the executable file when compiling the link, but the runtime link file loads the library when the program is executed, which can save the overhead of the system. Dynamic libraries are generally suffixed with ".so", and libc.so.6 is a dynamic library as described earlier. Gcc uses dynamic libraries by default when compiling.

Once the link is complete, gcc can generate the executable file.

At this point, I believe you have a deeper understanding of the "assembly language tutorial file suffix case S difference is what", might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report