Past exam question: 2082 Chaitra (Regular), Q6(b)
Open in the Padhaiko appQuestion
Explain different assembler directives used in assembly language programming.
Solution
1. Data Definition Directives: These directives allocate memory and initialize variables with initial values:
DB(Define Byte): Reserves 1 byte (8 bits) of memory per operand (e.g.COUNT DB 25H,MSG DB 'HELLO', 0).DW(Define Word): Reserves 2 bytes (16 bits) in little-endian order (e.g.VAL DW 1234H).DD(Define Double Word): Reserves 4 bytes (32 bits) (e.g.PTR DD 12345678H).DUP(Duplicate Operator): Allocates repeated blocks of memory (e.g.ARRAY DB 50 DUP(0)reserves 50 zero-initialized bytes).
2. Segment Organization Directives: Define logical segment boundaries and segment register associations:
SEGMENT/ENDS: Enclose statements belonging to a specific logical segment (e.g.DATA_SEG SEGMENT ... DATA_SEG ENDS).ASSUME: Informs the assembler which segment register corresponds to which segment name (e.g.ASSUME CS:CODE_SEG, DS:DATA_SEG).- Simplified Memory Directives: Modern assemblers support shorthand declarations:
.MODEL SMALL: Specifies standard memory model (code <= 64KB, data <= 64KB)..STACK 100H: Allocates 256 bytes for stack operations..DATA: Marks start of the initialized data segment..CODE: Marks start of the code segment.
3. Value Assignment & Procedure Directives:
EQU(Equate): Defines a numeric constant or text macro without allocating memory (e.g.MAX_SIZE EQU 100).ORG(Origin): Sets the assembler location counter to a specific starting offset address (e.g.ORG 100Hin .COM executables).PROC/ENDP: Demarcates the beginning and end of a procedure/subroutine, qualified withNEARorFAR(e.g.PRINT_CHAR PROC NEAR ... PRINT_CHAR ENDP).END: Marks the physical termination of the assembly source module and designates the execution entry point (e.g.END MAIN).
Answer:
Assembler directives include data allocation directives (DB, DW, DD, DUP), segment control directives (SEGMENT/ENDS, ASSUME, .MODEL, .DATA, .CODE), and procedure/symbol directives (EQU, ORG, PROC/ENDP, END).