100% found this document useful (2 votes)
96 views

Assembly Language Experiment #2

The document provides information about assembly language programming including the structure of conventional .EXE and .COM programs, basic screen operations using MOV, LEA, and INT instructions, and an experiment with exercises to practice displaying text on the screen by encoding, assembling, linking, and executing assembly language programs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
96 views

Assembly Language Experiment #2

The document provides information about assembly language programming including the structure of conventional .EXE and .COM programs, basic screen operations using MOV, LEA, and INT instructions, and an experiment with exercises to practice displaying text on the screen by encoding, assembling, linking, and executing assembly language programs.
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 8

NCP 312 (Computer Organization With

Assembly Language Laboratory)

STRUCTURE OF A CONVENTIONAL .EXE PROGRAM


stacksg segment para stack stack
;------------------------------------------------------------------------------------------------------------------stacksg ends
datasg segment para data
;------------------------------------------------------------------------------------------------------------------datasg ends
codesg segment para code
begin proc far
assume cs:codesg, ds:datasg, ss:stacksg
mov ax, datasg
mov ds, ax
--------------------------mov ah, 4Ch
;exit
int 21h
begin endp
codesg ends
end begin

STRUCTURE OF A CONVENTIONAL .COM PROGRAM


1 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

cseg segment para code


assume cs:cseg, ds:cseg, es:cseg, ss:cseg
org 100h
begin:
jmp begin
;-------------------------------------------------------------------------------------------------------------------; DATA DEFINITION
;-------------------------------------------------------------------------------------------------------------------begin:
;-------------------------------------------------------------------------------------------------------------------mov ax, 0003h
;clear screen
int 10h
; MAIN PROGRAM DEFINITION
;-------------------------------------------------------------------------------------------------------------------int 20h
cseg ends
end start

2 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

EXPERIMENT 2
BASIC SCREEN OPERATION
I.

OBJECTIVES
1. To practice assembling, linking and executing a program in assembly
2. To introduce the requirements in displaying information on the screen

II.

INSTRUCTION / SERVICES
A. MOV Instruction
Format: MOV [DESTINATION], [SOURCE]
Data transfer instruction can be used in the following ways:
MOV [REGISTER], [REGISTER]
MOV [MEMORY LOCATION], [REGISTER]
MOV [REGISTER], [MEMORY LOCATION]
MOV [REGISTER], [IMMEDIATE DATA]
MOV [MEMORY LOCATION], [IMMEDIATE DATA]
B. LEA (Load Effective Address) Instruction
LEA [REGISTER], [MEMORY LOCATION]
C. Printing a character
MOV AH, 02
MOV DL, [CHARACTER]
INT 21H
HEX
07
08
0A
0D

DEC
7
8
10
13

NAME
BELL
BACKSPACE
LINE FEED
CARRIAGE RETURN

FUNCTION
Emits a one-second beep
Moves the cursor one column to the left
Moves the cursor down one row
Moves the cursor to the beginning of the line

D. Printing a string
MOV AH, 09
LEA DX, [STRING]
INT 21H

3 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

EXERCISE
NAME:
SECTION:

DATE:

INSTRUCTOR:
GRADE:

1. Encode the given assembly language program, assemble, link and execute.
cseg segment para 'code'
assume cs:cseg, ds:cseg, es:cseg,
ss:cseg
org 100h
start:
JMP begin
;data declaration
val1 db 'NCP$'
val2 db '311$'
val3 db '#'
begin:
;clear screen
mov ax, 0003h
int 10h
;BLOCK A
mov ah, 02h
mov dl, val1

int 21h
;BLOCK B
mov ah, 09
lea dx, val2
int 21h
;BLOCK C
mov ah, 02
mov dl, val3
int 21h
;exit
int 20h
cseg ends
end start

a. What is the output of the given program?

b. Add the following instructions after the bold faced instructions in BLOCK B. What is
the output?
mov ah, 02
mov dl ,10
int 21h

4 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

c. Remove the codes added in b. then add the following instructions after the bold
faced instructions in BLOCK B. What is the output?
mov
mov
int
mov
int

ah, 02
dl ,10
21h
dl, 13
21h

d. Remove the codes added in c. then add int 21h after the bold faced instructions in
each block

e. Modify the given data declarations with the following:


val1 db 'NCP$'
val2 db 10,'311$'
val3 db 10,13,'#$'

Also replace all the bold faced codes with only the following:
mov
mov
int
mov
lea
int
lea
int

ah,
dl,
21h
ah,
dx,
21h
dx,
21h

02
val1
09
val2
val3

f. Modify the given data declarations again with the following:


val1 db 'NCP$'
val2 db '311',10,13,'$'
val3 db 10,13,'#$'

5 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

6 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

ACTIVITY
NAME:
SECTION:

DATE:

INSTRUCTOR:
GRADE:

Create an assembly language program that will display your first name diagonally on
the screen.

7 | Page

NCP 312 (Computer Organization With


Assembly Language Laboratory)

ACTIVITY
NAME:
SECTION:

DATE:

INSTRUCTOR:
GRADE:

Design an assembly language program that will output your family name on the screen.

8 | Page

You might also like