Open In App

What is Assembly Language?

Last Updated : 20 Oct, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

When we talk about programming languages the first thing that comes to our mind is languages like C, C++, Java, Python etc. But those languages hide the actual working i.e., that abstracts many things from users. But there is a language that really lies on basic concepts behind the programming or interaction between computer hardware.

What is Assembly Language?

Assembly language is a low-level language that helps to communicate directly with computer hardware. It uses mnemonics to represent the operations that a processor has to do. Which is an intermediate language between high-level languages like C++ and the binary language. It uses hexadecimal and binary values, and it is readable by humans.

How Assembly Language Works?

Assembly languages contain mnemonic codes that specify what the processor should do. The mnemonic code that was written by the programmer was converted into machine language (binary language) for execution. An assembler is used to convert assembly code into machine language. That machine code is stored in an executable file for the sake of execution.

It enables the programmer to communicate directly with the hardware such as registers, memory locations, input/output devices or any other hardware components. Which could help the programmer to directly control hardware components and to manage the resources in an efficient manner.

How to execute Assembly Language?

  • Write assembly code: Open any text editor in device and write the mnemonic codes in it and save the file with a proper extension according to your assembler. Extension can be .asm, .s, .asmx.
  • Assembling the code: Convert your code to machine language using an assembler.
  • Generating object file: It will generate an object file corresponding to your code. It will have an extension .obj.
  • Linking and creating executables: Our assembly language might contain multiple source codes. And we have to link them to libraries to make it executable. We can use a linker like lk for this purpose.
  • Running program: After creating an executable file we can run it as usual. It will depend on the software that how to run the program.

Components of Assembly Language

  • Registers: Registers are the fast memory locations situated inside the processor. Which helps ALU to perform arithmetic operations and temporary storing of data. Example: Ax (Accumulator), Bx, Cx.
  • Command: An instruction in assembly code known as a command informs the assembler what to do. Assembly language instructions typically employ self-descriptive abbreviations to make the vocabulary simple, as “ADD” for addition and “MOV” for data movement.
  • Instructions: Instructions are the mnemonic codes that we give to the processor to perform specific tasks like LOAD, ADDITION, MOVE. Example: ADD
  • Labels: It is a symbolic name/identifier given to indicate a particular location or address in the assembly code. Example: FIRST to indicate starting of execution part of code.
  • Mnemonic: A mnemonic is an acronym for an assembly language instruction or a name given to a machine function. Each mnemonic in assembly corresponds to a specific machine instruction. Add is an illustration of one of these machine commands. CMP, Mul, and Lea are among further instances.
  • Macro: Macros are the program codes that can be used anywhere in the program through calling it once we define it. And it is often embedded with assemblers and compilers. We should define it using a directive %macro. Example: %macro ADD_TWO_NUMBERS 2
    add eax, %1
    add eax, %2
    %endmacro
  • Operands: These are the data or values that we are given through instruction to perform some operation on it. Example: In ADD R1,R2 ; R1 and R2 are operands.
  • Opcode: These are the mnemonic codes that specify to the processor which operation has to be done. Example: ADD means Addition.

Advantages of Assembly Language

  • It provides precise control over hardware and hence increased code optimization.
  • It allows direct access to hardware components like registers, so it enables tailored solutions for hardware issues.
  • Efficient resource utilization because of low level control, optimized code, resource awareness, customization etc.
  • It is ideal for programming microcontrollers, sensors and other hardware components.
  • It is used in security researches for finding security vulnerabilities, reverse engineering software for system security.
  • It is very essential for the making the operating systems, kernel and device controllers that requires hardware interaction for its functionality.

Disadvantages of Assembly Language

  • Complex and very hard to learn the language especially for beginners.
  • It is highly machine dependent. So, it limits portability.
  • It is really hard to maintain the code, especially for large scale projects.
  • It is very time consuming since it is really hard to understand and very length of code.
  • Debugging is very challenging to programmers.

FAQs on Assembly Language

Q.1: Where is assembly language used for?

Answer:

  • Operating system development
  • Device driver creation
  • Embedded systems programming
  • Real-time applications
  • Security research

Q.2: Difference between Assembly language and High Level Language?

Answer:

Assembly Language is mnemonic codes and closely related to CPU’s instruction set. In HLL there is abstraction.

Q.3: Which CPU Architecture Should I Learn for Assembly Programming?

Answer:

8085 and 8086 micro processor architectures are very far better to understand concepts.

Q.4: Is Assembly Language Still Relevant in Modern Computing?

Answer:

Yes. Assembly language remains relevant.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads