System Programming: System Programming Tutorial-concept of assembly language-Assembler and it’s working with diagram

System Programming: System Programming Tutorial-concept of assembly language-Assembler and it’s working with diagram.



play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

System Programming: Assembly Language and Assembler

1. Introduction to Assembly Language

Assembly Language is a low-level programming language that provides a direct mapping to a computer’s machine code. It is written using mnemonics instead of binary opcodes, making it easier for humans to read and write.

Features of Assembly Language

 Uses symbolic mnemonics (e.g., MOV, ADD, SUB).
 Provides direct hardware control.
 Faster execution compared to high-level languages.
 Requires an Assembler to convert it into machine code.

2. What is an Assembler?

An Assembler is a system program that translates assembly language into machine code (binary form) that a computer’s CPU can execute.

Assembler Functions:

  1. Converts mnemonics into opcodes (e.g., MOV A, B78H).
  2. Allocates memory for instructions and data.
  3. Handles labels and addresses (symbol table management).
  4. Detects syntax errors in the assembly code.

3. Working of an Assembler (With Diagram)

Step-by-Step Assembler Workflow:

  1. Input: Assembly Program

    • Programmer writes instructions using mnemonics.
    • Example code:
      assembly
      START: MOV A, B ; Move B into A
      ADD C ; Add C to A
      JMP END ; Jump to END
      END: HLT ; Stop execution
  2. Lexical Analysis

    • The assembler scans the program and extracts mnemonics, labels, and operands.
  3. Syntax Analysis

    • Checks for errors like invalid mnemonics or incorrect operand usage.
  4. Symbol Table Generation

    • Creates a table of labels and their corresponding addresses.
  5. Opcode Conversion

    • Converts mnemonics into machine code instructions.
  6. Address Resolution

    • Assigns memory addresses to instructions and data.
  7. Output: Machine Code (Object File)

    • Generates an executable binary code.

Diagram: Working of an Assembler

+-------------------------+
| Assembly Source Code |
+-----------+-------------+
|
v
+-------------------------+
| Lexical Analysis | ---> Extract mnemonics, labels, operands
+-------------------------+
|
v
+-------------------------+
| Syntax Analysis | ---> Check for syntax errors
+-------------------------+
|
v
+-------------------------+
| Symbol Table Creation | ---> Assign labels to memory addresses
+-------------------------+
|
v
+-------------------------+
| Opcode Conversion | ---> Convert mnemonics to machine code
+-------------------------+
|
v
+-------------------------+
| Output: Machine Code | ---> Final executable binary
+-------------------------+

4. Types of Assemblers

1. Single-Pass Assembler

  • Processes code in one scan.
  • Fast but struggles with forward references.
  • Example: Basic 8-bit microcontrollers.

2. Two-Pass Assembler

  • Pass 1: Creates a symbol table.
  • Pass 2: Converts mnemonics to machine code using the symbol table.
  • Example: Intel 8086 assembler.

5. Conclusion

  • Assembly Language provides direct hardware control and efficient execution.
  • Assemblers translate it into machine code using symbol tables, opcode conversion, and address resolution.
  • Multi-pass assemblers handle forward references more efficiently.

Would you like a real-world example of an assembly program and its machine code conversion?

System Programming: System Programming Tutorial-concept of assembly language-Assembler and it’s working with diagram

The Art of Assembly Language

Unit 1 What is System Programming?



Diznr International

Diznr International is known for International Business and Technology Magazine.

Leave a Reply

Your email address will not be published. Required fields are marked *

error: