Coal - Lab Sol, 4
Coal - Lab Sol, 4
BS-INFT 4A,4B,4C
Spring Semester 2025
Roll No INFT231102005
Class INFT-4C
THE
CONCEPT OF DISPLAYING
STRING IN
ASSEMBLY LANGUAGE
Lab-04
Note:
• Each code Screenshot must Include your name and roll number in comments at the
start
• Carefully read each statement before attempting the tasks.
• To receive full credit, students must attempt all tasks and questions.
• Paste screenshots of both code and output in each task
• Your solution must be properly formatted, easy to read, and comprehensive.
• Plagiarism is strictly prohibited.
• To attempt Lab Task You are only allowed to use the concepts that have been covered
in the Lab Manual.
Lab Objectives:
To understand the concept of displaying string in assembly language
Contents / Sub Contents
Understanding STRING, .DATA Segment, Loading the Data Segment, LEA Instruction, Function 09h
(INT 21h)
EMU 8086 is an 8086 microprocessor emulator designed for learning and practicing
assembly language programming. It provides an easy-to-use environment for writing,
assembling, debugging, and executing x86 assembly code.
.DATA SEGMENT
The .DATA segment is used to define variables and constants that the program will use.
• Stores Variables and Constants: Any string, integer, or array that needs to be
stored is placed in the .DATA section.
• Allows Easy Access to Data: By setting DS (Data Segment Register), the program can
access these values efficiently.
• Required for Programs that Use Static Data: Programs printing strings or using
predefined values must declare them in .DATA.
Whenever your Program Contains Data Segment you need to Write these statement in the
Code Segments
Loads the starting address of the .DATA segment into the Accumulator Register (AX).
• The 8086 processor does not allow moving an immediate value (such as @DATA)
directly into a segment register (DS, CS, SS, ES).
• This restriction is built into the CPU architecture to ensure memory segmentation
consistency.
• Example of an invalid instruction: MOV DS, @DATA ; This is not allowed in 8086
assembly
• The only way to load a segment register (DS) is to first store the value in a
generalpurpose register (AX, BX, CX, or DX) and then move it into DS.
• The Accumulator Register (AX) is typically used because it is the fastest and most
commonly used register for such operations.
• Example of a valid method:
LEA INSTRUCTION
LEA stands for Load Effective Address. It is an instruction used in 8086 assembly language
to load the memory address of a variable into a register.
Purpose of LEA
Syntax:
Usage: The string must be terminated with a dollar sign ($) to indicate the end of the string.
Task no 3: Write an assembly language program that prints two strings using INT 21h,
function 09h. (Paste Screenshot of Code & Output)
The end ☺