Lab Manual of MP

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 35

LABORATORY MANUAL

MICROPROCESSOR AND ASSEMBLY LANGUAGE


PROGRAMMING

1
STUDENT INFORMATION

Name: ____________________________________________

Registration No: ___________________________________

Semester: _________________________________________

Program: _________________________________________

Email Address: ____________________________________

2
INTRODUCTION

What is Assembly Language?


A specific set of instructions for a particular computer system. It provides a direct
correspondence between symbolic statements and machine language. A programming
language with a one-to-one correspondence between its statement and a computer’s machine
language

Assembly language is called a low-level language because it is close to machine language in


structure and function. Each assembly language instruction corresponds to one machine
instruction. In contrast, high-level languages such as Pascal, BASIC, FORTRAN and COBOL
contain powerful statements that are translated into many machine instructions by the compiler

This section is an attempt to provide details on Assembly Language Programming practice.


The problems have primarily been divided into 8 sessions covering simple, loops, functions,
interrupt handling, calling assembly program from C etc. You must attempt all the problems in
the specified number of sessions.

In order to complete the tasks as above, you must come prepared with paper-based assembly
programs and s h o u l d t e s t t h e m a t t h e c e n t e r f o r a n y p o s s i b l e e r r o r s .
P l e a s e n o t e , t h a t t h e a s s e m b l y programs may look cumbersome, but give you a
lot of power on machine. They allow you to understand the machine more closely and use it more
efficiently.

3
INDEX

Lab Objective Page No.


Session No.
1. To understand the basic concept and functionality of 5
Assembly Language.
2. To understand the concept of taking input in assembly 11
language.
3. To understand the concept of displaying string in assembly 13
language.
4. To understand the concept of new line using carriage return, 15
line feed and macros in assembly language.
5. To understand the concept of loop in assembly language. 17

6. To understand the concept of stack in assembly language. 19

7. To understand the concept how to perform arithmetic 21


operations in assembly language.
8. To understand the concept of jump instruction in assembly 22
language.
9. Explore debugger using different commands. 27

10. Introduction to MDA – 8086 Training Kit 31

11 To understand the concept of how to access a memory of 39


trainer 8086 and understand some Assembly instructions.

4
Lab Session 01

Object
To understand the basic concept and functionality of Assembly Language.

Theory
ASSEMBLY LANGUAGE
Assembly language is a machine specific programming language with a one-to-one
correspondence between its statements and the computer’s native machine language. There are
many different types of assembly language, each specific to a processor or processor family.
IBM-PC assembly language refers to instruction recognized by a number of different
microprocessors in the Intel family: 8086, 8088, 80186, 80286, 80386, 80486, and Pentium.

USES:
 Assembly language is used most often when either communicating with the operating
system or directly accessing computer hardware.

 Secondly, assembly language is used to optimize certain critical areas of application


programs to speed up their runtime execution.

ASSEMBLER
An assembler is a program that converts source code programs from the assembly
language into machine language. The assembler can optionally generate a source- listing file
with line numbers, memory addresses, source code statements and a cross-reference listing of
symbols and variables used in a program.
The most popular assemblers for the Intel family are MASM (Microsoft Assembler), TASM
(Turbo Assembler).

LINKER
A companion program that combines individual files created by an assembler into a
single executable file

ASSEMBLY PROGRAM SYNTAX


 Assembly language program consists of statements.
 A statement is either an instruction to be executed when the program runs or a directive
for the assembler.
 A program normally consists of three parts or segments.

5
DATA SEGMENT
 Variables are declared in the data segment.
 Each variable is assigned space in memory and may be initialized.
Exp:
 A DW 3501H
It sets memory for a variable called A, and initialize it to 3501H.
DW - Define word (16 bits = 2 memory locations)
 A DW (?) ; un- initialized variable
CODE SEGMENT
 Program instructions are placed in the code segment. Instructions are actually organized
into units called procedures. Every procedure starts with a line.
Exp:
 Main Proc;
Main is the name of procedure and PROC is the directive identify the start of the procedure
 Main Endp;
Main is again the name of the procedure and Endp is the direcitive ; identifies the
end of the procedure
STACK SEGMENT
 The stack segment is used for temporary storage of addresses and data. If no stack
segment is declared, an error message is generated, so there must be a stack segment
even if the program doesn’t utilize the stack.
 These segments begin with the directives .stack, .code, and .data

PROGRAM SYNTAX
TITLE first program syntax
.Model Small ;Specifies the memory model used
.Stack 100H ;allocate 100H memory locations for stack
.Data ;start of the data segment
; Data definitions here
A DB ?
……..
.Code ;start of the code segment
Main Proc ;start of the first procedure
; instructions here
……
Main Endp ;end of the first procedure
; Other procedures here
End Main ;end of the complete assembly program

BASIC DIRECTIVES
Following are the description of commonly used directives;
The .MODEL directive specifies the memory model for an assembler module that uses the
simplified segment directives. The .MODEL directive must precede .CODE, .DATA, and
.STACK. Note that near code is branched to (jumped to) by loading the IP register only, while

6
far code is branched to by loading both CS and IP. Similarly, near data is accessed with just an
offset, while far data must be accessed with a full segment:offset address. In short, far means
that full 32-bit segment:offset addresses are used, while near means that 16-bit offsets can be
used. The format of the .MODEL directive is:

.MODELmemorymodel[[,langtype]] [[,stackoption]]
The memorymodel can be TINY, SMALL, COMPACT, MEDIUM, LARGE, HUGE, or FLAT. The langtype
can be C, BASIC, FORTRAN, PASCAL, SYSCALL, or STDCALL. The stackoption can be NEARSTACK or
FARSTACK.

TINY One segment. Thus both program code and data together must fit within
the same 64 Kb segment. Both code and data are near.

SMALL Program code must fit within a single 64 Kb segment, and data must fit
within a separate 64 Kb segment. Both code and data are near.

MEDIUM More than one code-segment. One data-segment. Thus code may be
greater than 64K.

COMPACT One code-segment. More than one data-segment. Thus data may be greater
than 64K.

LARGE More than one code-segment. More than one data-segment. No array
larger than 64K. Thus both code and data may be greater than 64K.

HUGE More than one code-segment. More than one data-segment. Arrays may
be larger than 64K. Thus both code and data may be greater than 64K.

FLAT No segmentation, all code and data can reach any location up to 4 Gb.

All program models but TINY result in the creation of exe-format programs. The TINY
model creates com-format programs.

.STACK: Defines the size of stack used in program


.DATA: Defines the data segments for data used in the program. Mark the beginning of the
data segment
.CODE: Identifies the code segment which contains all the statements. Also .code marks the
beginning of the code segment.
PROC: Beginning of the procedure
ENDP: End of the procedure
END:End of assembly language program

7
BASIC MOV INSTRUCTION:
We already defined in the Lab#1
RESTRICTIONS:
 Move between memory to memory is not allowed.
 A number directly inside a segment register is not allowed.
 Segment to segment registers, move is not allowed.

The INTerrupt Instruction


Pentium processor has two memory architectures: real and protected. In real mode a Pentium
works like fast 8086 processor. Real mode uses 16 bit addresses. The Real mode is also called
as 16-bit mode, because all 20 bit physical address is constructed by 16 bit address. MS-DOS
Operating system was the first operating system to implement Real-Address mode on IBM
personal computer.

The INT instruction is the instruction which does the most work in any assembler program.
INT instruction calls a DOS interrupt service routine (like a function) to perform a special task.

INT InterruptNumber

Where Interrupt Number ranges from 00H to 0FFH (i.e., from 0 to 255).

MS-DOS Operating system provides many common services through INT 21h. INT 21h MS-
DOS services are procedures that provide input-output, file handling, and memory
management. They are also called “MS-DOS function calls.”

The execution of an INT instruction causes an Interrupt Service Routine (ISR) associated with
the InterruptNumber to be executed. Many of the ISRs have multiple sub-functions. To specify
which sub-function is to be executed under a particular InterruptNumber, the AH register is
assigned a sub-function number before the execution of the INT instruction. Example:

MOV AH , 02H
INT 21H

DOS FUNCTION CALLS (INT 21H)


DOS function calls preserve the contents of all the registers except the AX register and any
other register or registers in which they explicitly return data.

TERMINATE PROGRAM AND RETURN TO DOS


Every time you want to terminate the program and return to DOS, you have to put the
following codes:

8
Assembly Language C Language Meaning

mov AX , 4C00H exit(0) Program terminates normally


int 21h
mov AX, 4C01h exit(1) Program terminates with error code 1.
int 21h

CHARACTER OUTPUT
To display a character, you have to use the DOS function 02h.

The Initial requirement The result


AH = 02h The character stored in DL will be displayed.
DL = Character or ASCII Code

9
LAB #01
1. The following code fragment will display a string 'Hey'.

Source Code

.model small
.stack 100h
.code
Main proc
mov DL, 'H'
mov AH, 2
int 21h
mov DL, 'e'
mov AH, 2
int 21h
mov AH, 2
mov DL, 'y'
int 21h
mov ah,4ch
int 21h
main endp
end main

Output

2. The following code fragment will display a string 'Muzammil'.

Source Code

.model small
.stack 100h
.code
Main proc
mov DL, 'M'
mov AH, 2
int 21h
mov DL, 'u'
mov AH, 2
int 21h
mov AH, 2
mov DL, 'z'
int 21h
mov DL, 'a'
mov AH, 2

10
int 21h
mov DL, 'm'
mov AH, 2
int 21h
mov DL, 'm'
mov AH, 2
int 21h
mov DL, 'i'
mov AH, 2
int 21h
mov DL, 'l'
mov AH, 2
int 21h
mov ah,4ch
int 21h
main endp
end main

Output

11
Lab Session 03

Object
To understand the concept of displaying string in assembly language.

Theory
STRINGS:
A string is a list of characters treated as a unit. In programming languages we denote a string
constant by using quotation marks, e.g. “Enter first number”.
In 8086 assembly language, single or double quotes may be used.
Defining String Variables
The following 3 definitions are equivalent ways of defining a string ‘abc’:
Version1 db “abc”; string constant
Version2 db ‘a’, ‘b’, ‘c’ ; character constants
Version3 db 97, 98, 99; ASCII codes
The first version uses the method of high level languages and simply encloses the string in
quotes. This is the preferred method.
The second version defines a string by specifying a list of the character constants that make up
the string.
We may also combine the above methods to define a string as in the following
example:message db “Hello world”, 13, 10, ‘$’
STRING OUTPUT
MS-DOS provides subprogram number 9h to display strings which are terminated by the ‘$’
character. In order to use it we must:
1. Ensure the string is terminated with the ‘$’ character.
2. Specify the string to be displayed by storing its address in the dx register.
3. Specify the string output subprogram by storing 9h in ah.
4. Use int 21h to call MS-DOS to execute subprogram 9h.

Keyword : MSG
The message to be displayed in the output can also be declared in the data segment
using the keyword MSG, moving the string in the register DB and can be used afterwards.
MSG DB ‘HELLO!$’
The “$” marks the end of the string and is not displayed. If the string contains the ASCII code
of a control character, the control function is performed.

12
Character String Output
MOV AH, 09H ; input key function
MOV DX,OFFSET MSG ; moves the offset of the msg to the
register
INT 21h

Sample Code
Write a program to display a string.
.model small ; specify memory model
.stack 100h ; specify size of stack
.data ; start of the data segment
msg1db 'Type Character : $'
.code ; start of the code segment
main proc ; start of the first program
movax,@data
movds,ax ; mov content ax to ds
movdx,offset msg1
mov Ah,09h ; reads from offset and display on output
int 21h ; interrupt call
mov Ah,4ch ; exit dos function
int 21h
mainendp ; interrupt call
end main

13
LAB #02

1. Write a program that display a string “IQRA UNIVERSITY”

Source Code
.model small
.stack 100h
.data
msg1 db 'IQRA UNIVERSITY:$ '
.code
main proc
mov ax,@data
mov ds,ax
mov dx,offset msg1
mov Ah,09h
int 21h
mov Ah,4ch
int 21h
main endp
end main
Output

2. Write a program to display your name.

Source Code
.model small
stack 100h
.data
msg1 db 'Muhammad Muzammil:$ '
.code
main proc
mov ax,@data
mov ds,ax
mov dx,offset msg1
mov Ah,09h
int 21h
mov Ah,4ch
int 21h
end main

Output

14
Lab Session 05

Object
To understand the concept of loop in assembly language.

Theory
Loop
A loop is a sequence of instructions that is repeated. The number of times to repeat may be
known in advance, or it may depend on conditions i.e. it’s a count controlled loop.
KEYWORD: LOOP
A FOR loop is implemented using the LOOP instruction. The counter for the loop is the CX
register, which is initialized to loop_count, which is the number of times the loop is executed.
Execution of the LOOP instruction causes CX to be decremented automatically. If CX becomes
0, the next instruction after loop is done.

Sample Code
Write a program that prints a character 100 times.
.model small
.stack 100h
.code
main proc
mov ah, 02h ;display a character
mov cx, 100 ;number of times loop will execute
mov dl, ‘*’ ;ASCII code of character 0
print: ;loop starts from here
int 21h
loop print ;executes the FOR loop
mov ah, 4ch ;terminates the current process
int 21h
mainendp
end main

Lab Tasks
1. Write a program to print ‘*’ 100 times using linefeed and carriage return.
2. Write a program to print ASCII characters from A-Z and Z-A
3. Write a program to print ASCII characters from a-z and z-a
4. Write a program to print from 0-9 and 9-0
5. Write a program to print ASCII characters.

15
LAB #03
1. Write a program that prints a character 100 times.

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 100
mov dl, '*'
print:
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

2. Write a program to print ASCII characters from Z-A

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 26
mov dl, 91
print:
DEC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main
Output

16
3. Write a program to print ASCII characters from A-Z

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 26
mov dl, 64
print:
INC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

4. Write a program to print ASCII characters from a-z

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 26
mov dl, 96
print:
INC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

17
5. Write a program to print ASCII characters from z-a

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 26
mov dl, 123
print:
DEC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

6. Write a program to print from 9-0

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 10
mov dl, 58
print:
DEC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

18
7. Write a program to print from 0-9

Source Code
.model small
.stack 100h
.code
main proc
mov ah, 02h
mov cx, 10
mov dl, 47
print:
INC DL
int 21h
loop print
mov ah, 4ch
int 21h
main endp
end main

Output

19
Lab Session 08

Object
To understand the concept of jump instruction in assembly language.

Theory
Jump instructions are used to change the flow of a Assembly language program. Jump instructions
are two types:

Unconditional Jump
The JMP instruction, whose syntax is:
JMP target
Transfers unconditionally control to the target location.

Conditional Jump-Instructions
Conditional jumps are of the general form:
JconditionStatementLabel
where (i) condition is one, two, or three letters (ii) the Statement Label must in the current code
segment and within 128 to +127 bytes from the conditional jump instruction.

How the CPU implements a conditional jump


Except for the JCXZ (Jump if the value in the CX register is zero) instruction, every conditional jump
instruction must follow a status-flag modifying instruction, either immediately. It is the settings of
the flags by this status-flag modifying instruction to which the conditional jump reacts to.
When a conditional jump is executed, the CPU checks the flags register. If the conditions for the
jump (expressed as one or more status flag settings) are true, the CPU adjusts the IP register to point
to the destination label, so that the instruction at this label will be executed next. If the jump
condition is false, then the IP register is not altered; this means that the next sequential instruction
will be executed.
Note: The conditional jump instructions DO NOT MODIFY the flags; they only react to the current
flag values.
Example: . . .
SUB AX , BX
JZ L2 ; jump to L2 if the result is zero .
L2:

THE CMP (Compare) INSTRUCTION


The CMP instruction is used to compare either two signed numbers or two unsigned numbers.
 A signed number can be Greater, Less, or Equal to another signed number.
 An unsigned number can be Above, Below, or Equal to another unsigned number.

20
The CMP instruction, whose syntax is:
CMP Operand1 , Operand2
compares two operands, and then sets or clears the following flags: AF, CF, OF, PF, and ZF. The
instruction performs the subtraction:
Operand1 - Operand2
without modifying any of its operands.
Note:
 The two operands must be of the same size.
 Both operands may not be memory locations at the same time.
 No operand may be a segment register.
 Operand1 may not be an immediate value.
Conditional jumps can be classified into three: (1) Signed jumps, (2) Unsigned jumps, and (3) Single
flag jumps.

SIGNED JUMPS UNSIGNED JUMPS


condition Equivalent mnemonic jump condition mnemonic jump condition
condition

 not  JG , JNLE ZF = 0 and SF = OF JA , JNBE CF = 0 and ZF = 0

 not  JGE , JNL SF = OF JAE , JNB CF = 0

 not  JL , JNGE SF  OF JB , JNAE CF = 1

 not  JLE , JNG ZF = 1 or SF  OF JBE , JNA CF = 1 or ZF = 1

Single flag jumps

mnemonic jump condition description


JE , JZ ZF = 1 Jump if equal
JNE , JNZ ZF = 0 Jump if not equal
JC CF = 1 Jump if carry
JNC CF = 0 Jump if no carry

21
mnemonic jump condition description
JO OF = 1 Jump if overflow
JNO OF = 0 Jump if no overflow
JS SF = 1 Jump if sign negative
JNS SF = 0 Jump if sign is not negative
JP, JPE PF = 1 Jump if parity even, i.e., if there is an even number of 1 bits in
the result.
JNP, JPO PF = 0 Jump if parity odd, i.e., if there is an odd number of 1 bits in the
result.

Sample Code
Write a loop to display: AAAAAA
.model small
.stack 100h
.code
Mainproc
Mov cx , 6
l1: mov ah , 02h
mov dl , ‘a’
int 21h
dec cx
jnz l1
mov ah,4ch
int 21h
mainendp
Alternative solution is:
.model small
.stack 100h
.code
mainproc
Mov cx , 6
l1: mov ah , 02h
mov dl , ‘a’
int 21h
dec cx
jcxz l2
jmp l1
l2:
mov ah,4ch
int 21h
mainendp
end main

22
Write a loop to display: ABCDEFG
.model small
.stack 100h
.code
Mainproc
Movbl , 7
mov dl , ‘a’
start: mov ah , 02h
int 21h
inc dl
decbl
jnz start
mov ah,4ch
int 21h
mainendp
end main

Alternative solution is:


.model small
.stack 100h
.code
mainproc
Mov dl , ‘a’
@1: mov ah , 02h
int 21h
inc dl
cmp dl , ‘g’
jbe @1
mov ah,4ch
int 21h
mainendp
end main

Lab Tasks
1. Display ‘*’ 10 times each in new line

2. Display ASCII characters from A-Z and Z-A

3. Display ASCII characters from a-z and z-a.

4. Display ASCII characters from A-Z and z-a each on new line.

5. Display printable key strokes of a keyboard until user prints Escape “Esc” key (Hint:
ASCII code of Esc is 27)

23
LAB #04
1. Write a loop to display: aaaaaa
Source Code
.model small
.stack 100h
.code
Main proc
Mov cx , 6
l1:mov ah , 02h
mov dl , 'a'
int 21h
dec cx
jnz l1
mov ah,4ch
int 21h
main endp

Output

2. Write a loop to display: ABCDEFG

Source Code
.model small
.stack 100h
.code
Main proc
Mov bl , 7
mov dl , 'A'
start: mov ah , 02h
int 21h
inc dl
dec bl
jnz start
mov ah,4ch
int 21h
main endp
end main

Output

24
3. Display ‘*’ 10 times each in new line

Source Code
.model small
.stack 100h
include emu8086.inc
.code
main proc
mov cx,10
mov dl,'*'
BB:
mov ah,02h
int 21h
printn
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp

Output

4. Display ASCII characters from A-Z

Source Code

.model small
.stack 100h
.code
main proc
mov cx, 26
mov dl, 65

25
BB: mov ah,02h
int 21h
inc dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp

Output

5. Display ASCII characters from Z-A

Source Code

.model small
.stack 100h
.code
main proc
mov cx, 26
mov dl, 90
BB: mov ah,02h
int 21h
DEC dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp
Output

26
6. Display ASCII characters from a-z.

Source Code

.model small
.stack 100h
.code
main proc
mov cx, 26
mov dl, 97
BB: mov ah,02h
int 21h
INC dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp

Output

7. Display ASCII characters from z-a.

Source Code

.model small
.stack 100h
.code
main proc
mov cx, 26
mov dl, 122
BB: mov ah,02h
int 21h
dec dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp
Output

27
8. Display ASCII characters from A-Z on new line.

Source Code

.model small
.stack 100h
include emu8086.inc
.code
main proc
mov cx, 26
mov dl, 65
BB:
mov ah,02h
int 21h
printn
inc dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp

Output

28
9. Display ASCII characters from a-z on new line.

Source Code

.model small
.stack 100h
include emu8086.inc
.code
main proc
mov cx, 26
mov dl, 97
BB:
mov ah,02h
int 21h
printn
inc dl
dec cx
JNZ BB
mov ah,4ch
int 21h
main endp

Output

29
Lab Session 04

Object
To understand the concept of new line using carriage return, line feed and
macros in assembly language.

Theory
MACROS
A macro is a block of code that has been given a name and when the compiler encounters such
name, it expands the macro, copies the block of code at the place of invocation into the
program. The text may contain instructions or references to other macros.
The basic advantage of using a macro is to create new instructions. These macros can be a part
of the program or they can be written in a separate file and that file can be included in the
program. There is a list of useful macros which are helpful to be kept in the macro library of
the assembly language compiler and these can be used in other user programs.
These can also be written in the lines of code of the program without any name given to them.
A macro is an extension to the basic ASSEMBLER language. They provide a means for
generating a commonly used sequence of assembler instructions/statements. The sequence of
instructions/statements will be coded ONE time within the macro definition. Whenever the
sequence is needed within a program, the macro will be "called".

CARRIAGE RETURN and LINE FEED


This macro can be used to feed a new line in the output and is very useful as a new line is
needed many times during a formatted output.
NEW_LINE MACRO
MOV AH, 02H
MOV DL, 0DH
INT 21H
MOV DL, 0AH
INT 21H
ENDM
Once declared and defined, this macro can be invoked anywhere in the program to insert a new
line. The name of the macro can be any string as defined by the user.

Sample Code
.model small
.stack 100h
.data
Msgdb “IQRA UNIVERSITY $”

30
Msg1 db “ASIM $”
.code
Newline macro
Mov ah,02h
Mov dl,0dh // 0dh is quivalent to 13 in decimal and to carriage return ('\r') in ASCII
which moves the cursor to the beginning of the current row.
Int 21h
Mov ah,02h
Mov dl,0ah
Int 21h
Endm
Main proc
Movax,@data
Mov ds, ax
Mov ah, 09h //display string function
Mov dx, offset msg
Int 21h
Newline
Mov ah,09h
Movdx,offset msg1
Int 21h
Mov ah,4ch
Main endp
End main

Lab Tasks
1. Write a program to display your bio data using carriage return and line feed macro.
2. Write a program to make your 3rd semester marksheet.

31
LAB #05
Line Spacing Source Code
.model small
.stack 100h
.data
Msg db 'IQRA UNIVERSITY$'
Msg1 db 'Muzammil$'
.code
Newline macro
Mov ah , 02h
Mov dl , 0dh
int 21h
Mov ah ,02h
Mov dl,0ah
int 21h
Endm
main proc
Mov ax ,@data
Mov ds, ax
Mov ah, 09h
Mov dx, offset msg
int 21h
Newline
Mov dx ,offset msg
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg1
int 21h
Mov ah, 4ch
Main endp
End main

Output

32
1. Write a program to display your bio data using carriage return and line feed more.

SourceCode
.model small
.stack 100h
.data
Msg db 'Name: M.Muzammil$'
Msg1 db 'F.Name: M.Altaf$'
Msg2 db 'Education: Undergraducate$'
Msg3 db 'Semester: Six$'
Msg4 db 'Course: Micro Processor$'
Msg5 db 'Contact: 030....$'
.code
Newline macro
Mov ah , 02h
Mov dl , 0dh
int 21h
Mov ah ,02h
Mov dl,0ah
int 21h
Endm
main proc
Mov ax ,@data
Mov ds, ax
Mov ah, 09h
Mov dx, offset msg
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg1
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg2
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg3
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg4
int 21h
Newline

33
Mov ah, 09h
Mov dx, offset msg5
int 21h
Mov ah, 4ch
Main endp
End main

Output

2. Write a program to make your 3rd semester mark sheet.


SourceCode
.model small
.stack 100h
.data
Msg db 'Name: M.Muzammil$'
Msg1 db 'Semester: 3rd$'
Msg2 db 'Cleared: All$'
Msg3 db 'Failed: None$'
Msg4 db 'GPA: 3.5$'
.code
Newline macro
Mov ah , 02h
Mov dl , 0dh
int 21h
Mov ah ,02h
Mov dl,0ah
int 21h
Endm
main proc
Mov ax ,@data
Mov ds, ax
Mov ah, 09h
Mov dx, offset msg
int 21h
Newline
Mov ah, 09h

34
Mov dx, offset msg1
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg2
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg3
int 21h
Newline
Mov ah, 09h
Mov dx, offset msg4
int 21h
Mov ah, 4ch
Main endp
End main

Output

35

You might also like