assembly language
assembly language
Machine language
What the computer sees and deals with
Every command is a sequence of one or more numbers
Set of fundamental instructions the machine can execute
Expressed as a pattern of 1’s and 0’s
Assembly language
Command numbers replaced by letter sequences that are easier to read
Still have to work with the specifics of the machine itself
Alphanumeric equivalent of machine language
Mnemonics more human-oriented than 1’s and 0’s
High-level language
Make programming easier by describing operations in a natural language
A single command replaces a group of low-level assembly language
commands
1. Assembly Language
Example:
MOV AX, 5 ; Move the value 5 into the AX register
ADD AX, 3 ; Add 3 to the value in the AX register
INT 21H ; Interrupt to terminate program or perform a function
Explanation:
Disadvantages:
Complexity and difficulty in programming
Lack of portability across different systems
The opcode specifies the operation or task that the CPU should
perform. It represents a specific machine instruction, such as addition,
subtraction, data transfer, or comparison.
Examples of Opcodes:
2. Operands
2. Assembler
Components:
1. Label:
o A label is an optional identifier used to mark a specific line or
memory location in the code. It helps with branching or looping
by serving as a reference point.
o Labels are followed by a colon (:).
Example:
START: MOV AX, 5 ; 'START' is the label
2. Mnemonic:
o A mnemonic is the symbolic name for a CPU instruction. It
specifies the operation to be performed (e.g., move, add,
subtract).
o Mnemonics are predefined keywords in assembly language.
Examples:
Types of operands:
Examples:
MOV AX, 10 ; Immediate value (10) to AX
ADD AX, BX ; Add the value of BX to AX
4. Comment:
o Comments begin with a semicolon (;) and are ignored by the
assembler.
o They explain the purpose of the code and improve readability.
Example:
MOV AX, 10 ; Load value 10 into AX
3. Syntax Rules
1. Case Sensitivity:
o Most assemblers are not case-sensitive (e.g., MOV and mov are
treated the same).
o However, consistency is recommended for readability.
2. Instruction Order:
o Typically, one instruction per line.
o Use proper order when defining data, instructions, and labels.
3. Alignment:
o Align instructions and comments neatly for clarity.
4. Comments:
o Always comment on complex logic to make the code
understandable.