- Asked 4/14
- 2072 Asoj · 2+6 marks
- 2071 Magh · 8 marks
- 2069 Poush · 2+6 marks
- 2068 Bhadra · 2+6 marks
Assembler statements and directives
Short answer
An assembly statement may include label, opcode/directive, operands, and comment. Common directives: SEGMENT/ENDS define segments; DB/DW/DUP reserve data; EQU assigns constants; ASSUME links segment registers; PROC/ENDP define procedures; END marks the file end and entry point.
What is statement in an assembly language program? Explain frequently used directives with suitable example.
Statement
An assembly language statement is one line of source code. It is either an instruction (translated to machine code) or a directive (an instruction to the assembler). General format:
[label:] mnemonic/directive [operand(s)] [;comment]
START: MOV AX,BX ; copy BX into AX
Types of statements: instructions, assembler directives (pseudo-ops), macros, and comments.
Directives
Directives are commands to the assembler; they generate no machine code (except data definitions) and control memory allocation and program organisation.
| Directive | Purpose | Example |
|---|---|---|
| SEGMENT / ENDS | Start and end of a logical segment | DATA SEGMENT ... DATA ENDS |
| ASSUME | Tells assembler which segment is addressed by which segment register | ASSUME CS:CODE, DS:DATA |
| DB / DW / DD | Define byte / word / double word | NUM DB 25H, ARR DW 10 DUP(0) |
| EQU | Give a name to a constant | COUNT EQU 10 |
| ORG | Set the location counter | ORG 100H (COM program) |
| PROC / ENDP | Start and end of a procedure (NEAR or FAR) | ADD2 PROC NEAR ... ADD2 ENDP |
| END | End of the source file, optionally gives start label | END START |
| DUP | Repeat a data value | BUF DB 50 DUP(?) |
| OFFSET / PTR | Offset of a label; override data size | MOV BX,OFFSET ARR, MOV BYTE PTR [BX],5 |
| .MODEL, .DATA, .CODE, .STACK | Simplified segment directives | .MODEL SMALL |
Example program using directives
DATA SEGMENT
N1 DB 05H
N2 DB 07H
SUM DB ?
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START: MOV AX,DATA ; initialise DS
MOV DS,AX
MOV AL,N1
ADD AL,N2
MOV SUM,AL ; SUM = 0CH
MOV AH,4CH
INT 21H
CODE ENDS
END START
Here SEGMENT/ENDS define two segments, ASSUME links them to CS and DS, DB reserves memory, and END marks the end and entry point.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- 8086 assembly language operators · Microprocessor, chapter 3 · asked 3×
- Second law statements; Kelvin-Planck and Clausius equivalence · Fundamental of Thermodynamics & Heat Transfer, chapter 5
- Interpret: book for second-language readers · Communication English, chapter 1
- Purpose of continue statement · Computer Programming, chapter 5
- Assembly constraints and tolerance fit calculation · Computer Aided Design, chapter 5