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 assembly language and c language

2025-04-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces the difference between assembly language and c language, the article is very detailed, has a certain reference value, interested friends must read it!

Differences: 1, assembly language efficiency is high, C language efficiency is relatively low; 2, assembly language hardware controllability is strong, C language hardware controllability is relatively poor; 3, assembly language object code size is small, C language object code volume is large; 4, assembly language is not easy to maintain, C language is easy to maintain; 5, assembly language portability is very poor, C language portability is very good, and so on.

The operating environment of this tutorial: windows7 system, C99 version, Dell G3 computer.

The difference between assembly language and c language

1. Different efficiency

The efficiency of assembly is high, but the efficiency of C language is relatively low.

2. The controllability of hardware is different

The assembler has strong controllability of hardware, while the hardware controllability of C language is relatively poor.

3. The code size is different.

The object code of assembly is small, while the object code of C language is large.

4. Different maintainability

The assembly is not easy to maintain, and the C language is easy to maintain.

5. Portability is different.

The portability of assembly is poor, and the portability of C language is very good.

6. Learning difficulties are different.

The compilation knowledge required by assembly language is very complex and is often used by developers. And C language is a very simple and convenient language, programmers do not need to have too much professional knowledge.

Expand knowledge:

The reasons for the high efficiency of assembly language:

1. Assembly language is essentially a mnemonic of machine language.

CPU can only run the instruction sets it supports, and each instruction in these instruction sets is a sequence of binary numbers, that is, an ordered combination of "0" and "1"; the combination of "0" and "1" is not easy for programmers to remember, so they have mnemonic characters such as "MOV A 0x40".

So the assembly language is compiled into a CPU executable machine language that only needs to be translated. After the C language has finished writing the program, the C language needs to be compiled into the machine language corresponding to the corresponding CPU instruction set through the compiler.

Assembly language corresponds to machine language one by one. But what about C? Of course it's not so good.

The syntax of C language is fixed, and it is impossible for programs written in C language to be compiled into machine language instructions that CPU can read, so it needs to have compilation rules, so it is less efficient to run. It can also be said that C language is a language for programmers, while assembly language is a language directly oriented to CPU.

2. Assembler is a language directly facing CPU. As long as it is within the scope of instruction set support, assembly language can directly and flexibly manage every byte of special function registers, general registers, memory units, and even every bit.

The use and management of memory in C language is also very powerful, but it is still subject to grammar after all. To take the simplest example, there is no corresponding three-byte or five-byte variable type in C language, either int or long, so each application must be a fixed number of bytes, which is bound to cause a waste of memory.

And most assembly languages do not have such syntax at all, with the help of pseudo instructions (which is actually just to improve readability), assembly language programs can use variables with any number of bytes, which is of course much more troublesome than C language. in the end, it is a byte-by-byte splicing process, and it is easy to write programs in C language, regardless of these, the compiler will eventually fix it.

And the price of ease is waste. The inefficient use of memory will also affect the overall efficiency of the whole program.

The above is all the contents of this article entitled "what's the difference between assembly language and c language". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

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