1. Assembly Language Syntax
1.1 Definition
Assembly language is a low-level programming language that uses mnemonics to
represent machine instructions. It is hardware specific and closely tied to the
processor architecture.
C/Java → Human friendly
Assembly → Machine friendly
Machine Code → CPU friendly
Assembly is 1 step above machine code.
1.2 Structure of an Assembly Instruction
Each instruction generally consists of:
Label (optional): Assigning a label to an address or line in a program like
START
Mnemonic (required): The name of the instruction (MOV, ADD, INT, etc.).
Operands (optional): The data on which the instruction performs its operation.
Comment (optional)
Syntax Format:
[label] mnemonic operand(s) ; comment
1.3 Example
START: MOV AX, BX ; Move BX contents into AX
2. Program Data
2.1 Data Representation
Data in assembly is stored in bytes (8 bits), words (16 bits), or double words (32 bits).
We define data using data definition directives.
2.2 Common Directives
Directive Meaning
DB Define Byte It stores 1 byte of data
(range 0–255).
DW Define Word It stores 2 bytes of data
, (range 0–65535).
DD Define Double Word It stores 4 bytes of data.
2.3 Example
NUM1 DB 10 ;A byte variable named NUM1 has been created, which stores the value 10.
NUM2 DW 250 ;NUM2 is a word variable (2 bytes) that stores the number 250.
3. Variables
3.1 Definition
(A variable is a memory location given a symbolic name.) In assembly, a variable is a
memory location to which we assign a name (label). When the program runs, the
processor reads from or writes to data at this memory location.
3.2 Types
Byte Variable: It can hold values from 0 to 255. It occupies 1 byte of space.
Word Variable: It can store values from 0 to 65,535. It occupies 2 bytes of space.
String Variable: Its “range” is determined by how many characters you define in it.
A string variable is used to store a sequence of characters (letters, numbers, or
symbols).Each character in the string usually occupies 1 byte of memory.
Array: In an array, memory locations are consecutive. That is, memory cells are used
one after another. For example: NUMBERS DB 5, 10, 15, 20.
3.3 Example
COUNT DB 5
MARKS DW 90, 85, 70
Explanation:
Here COUNT DB 5
COUNT is a byte variable. It holds the value 5. It will use only 1 byte of memory.
MARKS DW 90, 85, 70
MARKS becomes an array of words. Since DW is used here, each value will take 2
bytes.
There are 3 values → total 6 bytes of memory will be used.
4. Program Structure