Skip to main content

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.

DirectivePurposeExample
SEGMENT / ENDSStart and end of a logical segmentDATA SEGMENT ... DATA ENDS
ASSUMETells assembler which segment is addressed by which segment registerASSUME CS:CODE, DS:DATA
DB / DW / DDDefine byte / word / double wordNUM DB 25H, ARR DW 10 DUP(0)
EQUGive a name to a constantCOUNT EQU 10
ORGSet the location counterORG 100H (COM program)
PROC / ENDPStart and end of a procedure (NEAR or FAR)ADD2 PROC NEAR ... ADD2 ENDP
ENDEnd of the source file, optionally gives start labelEND START
DUPRepeat a data valueBUF DB 50 DUP(?)
OFFSET / PTROffset of a label; override data sizeMOV BX,OFFSET ARR, MOV BYTE PTR [BX],5
.MODEL, .DATA, .CODE, .STACKSimplified 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)

All Microprocessor chapter 3 questions →