0% found this document useful (0 votes)
5 views39 pages

b1a98546-1e7e-4b11-80df-23db6e7b78ba-

The document contains various assembly language programming tasks, including finding the largest and smallest numbers in an array, counting even and odd numbers, performing matrix addition, and string manipulation. It includes code examples and flowcharts for each task. The programs are designed for different scenarios, such as handling 8-bit and 16-bit numbers, and demonstrate basic operations like addition, searching, and comparison.

Uploaded by

nyasa.rajan23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views39 pages

b1a98546-1e7e-4b11-80df-23db6e7b78ba-

The document contains various assembly language programming tasks, including finding the largest and smallest numbers in an array, counting even and odd numbers, performing matrix addition, and string manipulation. It includes code examples and flowcharts for each task. The programs are designed for different scenarios, such as handling 8-bit and 16-bit numbers, and demonstrate basic operations like addition, searching, and comparison.

Uploaded by

nyasa.rajan23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 39

Assembly Language Program

Examples

1
UQ
• Write an assembly language program to find the largest and
smallest number from an unordered array of l6-bit numbers.
Assume the array contains l5 numbers and the starting location
as 2500H. Draw the flowchart for the program. (UQ DEC 2022-
14 marks)

• Write an assembly language program to find the total number


of even and odd numbers from an array of l6-bit numbers.
Assume the array contains 20 numbersand the starting location
as 5500H. Draw the flowchart for the program. (UQ DEC
2022-14 marks)

• Write an 8086-program to find the largest among 'n' numbers


(each numbers and count are of one yte only).Kindly assume
2
that the size of array(count) stored in 2000h, and the
1.Add 2 numbers

3
2.Addition of a series of 8 bit numbers

4
3.Largest number from a given unordered array of 8 bit numbers

5
4.Above pgm for a series of words

6
5.Pgm to find the number of even and odd numbers from a
given series of 16 bit hex numbers

7
8
6.Pgm to find out the number of +ve and –ve numbers from a given list

9
7.Pgm to move a string of data words from offset
2000H to Offset 3000H .The length of string is 0FH

10
8.WAP to perform one byte BCDaddition

11
12
9.

13
14
15
16
17
18
19
Matrix addition

• WAP for the addition of 3x3 matrices. The matrices


are stored in the form of lists(Row wise).Store the
result of addition in the third list??

20
21
22
Factorial of a given number
• DATA SEGMENT
• A EQU 5
• DATA ENDS
• CODE SEGMENT
• ASSUME DS:DATA,CS:CODE
• START:
• MOV AX,DATA
• MOV DS,AX
• MOV AH,00
• MOV AL,A
• L1: DEC A
• MUL A
• MOV CL,A
• CMP CL,01
• JNZ L1
• MOV AH,4CH
• INT 21H
• CODE ENDS 23
READ AND PRINT CHARACTER(MASM)

READ AND PRINT CHARACTER MOV AH,01H


DATA SEGMENT INT 21H
MSG1 DB 0AH,0DH ,”ENTER NO:$” SUB AL,30H
SUM DB 0AH,0DH, ”SUM :$ “
DATA ENDS
MOV DL,AL
MOV AH,02H
ASSUME CS:CODE,DS:DATA
INT 21H
CODE SEGMENT
START :
MOV AH,4CH
MOV AX,DATA
INT 21H
MOV DS,AX
CODE ENDS
LEA DX,MSG1 END START
MOV AH,09H
INT 21H

24
String reverse(MASM)(LAB)
DATA SEGMENT CODE SEGMENT L2: LEA DX,NEWLINE
ST1 DB 100 DUP(?) ASSUME CS:CODE MOV AH,09H
MSG1 DB "ENTER THE STRING$"
MSG2 DB "REVERSED STRING$"
START: INT 21H
NEWLINE DB 10,13,"$" MOV AX,DATA LEA DX,MSG2
DATA ENDS MOV DS,AX MOV AH,09H
LEA DX,MSG1 INT 21H
MOV AH,09H
INT 21H L3: MOV DL,[SI]
LEA SI,ST1 MOV AH,02H
MOV CL,00 INT 21H
DEC SI
L1:MOV AH,01H DEC CL
INT 21H CMP CL,00H
CMP AL,0DH JNZ L3
JZ L2 MOV AH,4CH
INC CL INT 21
INC SI
MOV [SI],AL CODE ENDS
INC SI END START
INC CL
JMP L1

25
MASM program for Linear Search(Lab)

assume cs:code,ds:data
data segment
g1 db 0dh,0ah,"Enter the count:$"
g2 db 0dh,0ah,"Enter the array:$"
g3 db 0dh,0ah," The array is given below :$"
g4 db 0dh,0ah," Enter the search element :$"
msg1 db 0dh,0ah," found: $"
msg2 db 0dh,0ah," not found: $"
nl db 0dh,0ah,"$"
ar db 10 dup(0)
data ends

26
disps macro msg lea si,ar up:
lea dx,msg disps g2 mov bl,[si]
mov ah,09h
int 21h cmp al,bl
endm loop1: jz fo
disps nl inc si
readc macro readc dec dl
mov ah,01h sub al,30h jnz up
int 21h
endm mov [si],al disps msg2
inc si jmp end1
code segment dec cl
start: jnz loop1 fo:
mov cx,data disps msg1
mov ds,cx
disps g4
disps g1 readc end1:
readc sub al,30h mov ah,4ch
sub al,30h int 21h
mov cl,al lea si,ar code ends
mov ch,al
mov bh,al mov dl,ch end start

27
Addition of 16 bit numbers

28
29
30
31
32
MASM program for SORT

assume cs:code,ds:data
data segment
g1 db 0dh,0ah,"Enter the count:$"
g2 db 0dh,0ah,"Enter the array:$"
g3 db 0dh,0ah," The sorted array is given below :$"
nl db 0dh,0ah,"$"
ar db 10 dup(0)
data ends

33
disps macro msg disps g1 lp1: loop2:
lea dx,msg readc lea si,ar disps nl
mov ah,09h
int 21h sub al,30h mov cl,ch dispc[di]
endm mov cl,al lp2: inc di
mov ch,al mov bl,[si+1] dec bh
readc macro mov bh,al cmp bl,[si] jnz loop2
mov ah,01h lea si,ar jnc nswap mov ah,4ch
int 21h int 21h
endm disps g2 xchg bl,[si]
mov [si+1],bl code ends
dispc macro ch loop1: nswap: end start
mov dl,ch disps nl inc si
mov ah,02h readc dec cl
int 21h
endm mov [si],al jnz lp2
inc si dec ch
code segment dec cl jnz lp1
start: jnz loop1 disp:
dec ch lea di,ar
mov cx,data
mov ds,cx jz disp disps g3

34
MASM program to find two strings are equal or not(STRING COMPARISON)
data segment
str1 db "enter first string here ->$"
str2 db "enter second string here ->$"
str11 db "first string : ->$"
str22 db "second string: ->$"

instr1 db 20 dup("$")
instr2 db 20 dup("$")
newline db 10,13,"$"
n db ?
s db ?
msg1 db "both string are same$"
msg2 db "both string are different$"

data ends

35
code segment mov ah,09h mov ah,09h
lea dx,str2
assume ds:data,cs:code int 21h lea dx,newline
start: mov ah,0ah int 21h
mov dx,di
mov ax,data int 21h
mov ds,ax mov ah,09h
lea dx,str22
lea si,instr1 mov ah,09h int 21h
lea di,instr2 lea dx,newline
int 21h
;get string mov ah,09h
mov ah,09h lea dx,instr2+2
lea dx,str1 ;print the string
int 21h
int 21h
mov ah,09h
mov ah,0ah lea dx,str11 mov ah,09h
mov dx,si int 21h lea dx,newline
int 21h
mov ah,09h int 21h
mov ah,09h lea dx,instr1+2
lea dx,newline int 21h
int 21h

36
;string comparision mov ah,09h
mov bx,00 lea dx,msg1
int 21h
mov bl,instr1+1
mov bh,instr2+1 jmp l5

cmp bl,bh l1:mov ah,09h


jne l1 lea dx,msg2
int 21h
add si,2
add di,2 l5:
mov ah,09h
l2:mov bl,byte ptr[si] lea dx,newline
cmp byte ptr[di],bl int 21h
jne l1
inc si mov ah,4ch
inc di int 21h
cmp byte ptr[di],"$" code ends
jne l2 end start

37
MASM number palindrome

38
39

You might also like