0% found this document useful (0 votes)
7 views8 pages

Programs

The document contains a series of assembly language programs demonstrating various operations such as 8-bit multiplication, division, finding the largest and smallest numbers, counting even/odd and positive/negative numbers, sorting in ascending and descending order, generating Fibonacci series, transferring data blocks, calculating factorial using macros, and reversing a string. Each program includes a data segment and code segment with specific instructions for execution. The examples illustrate fundamental programming concepts in assembly language.

Uploaded by

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

Programs

The document contains a series of assembly language programs demonstrating various operations such as 8-bit multiplication, division, finding the largest and smallest numbers, counting even/odd and positive/negative numbers, sorting in ascending and descending order, generating Fibonacci series, transferring data blocks, calculating factorial using macros, and reversing a string. Each program includes a data segment and code segment with specific instructions for execution. The examples illustrate fundamental programming concepts in assembly language.

Uploaded by

khushivj.917
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

8bit Multiplication
8bit addition data Segment (Write numbers as per
data Segment (Write numbers as per executed program)
executed program) no1 db 04h
no1 db 04h no2 db 01h
no2 db 01h data ends
data ends code segment
code segment assume cs:code,ds:data
assume cs:code,ds:data start:mov ax,data
start:mov ax,data mov ds,ax
mov ds,ax mov al,no1
mov al,no1 mov bl,no2
mov bl,no2 Mul bl
add al,bl int 3
int 3 code ends
code ends end start
end start
8bit Division
8bit Subtraction data Segment (Write numbers as per
executed program)
data Segment (Write numbers as per no1 db 04h
executed program) no2 db 01h
no1 db 04h data ends
no2 db 01h code segment
data ends assume cs:code,ds:data
code segment start:mov ax,data
assume cs:code,ds:data mov ds,ax
start:mov ax,data mov ah,00H
mov ds,ax mov al,no1
mov al,no1 mov bl,no2
mov bl,no2 Div bl
sub al,bl int 3
int 3 code ends
code ends end start
end start
2.
Largest Number Smallest Number
data segment data segment
series DB 12h,56h,99h,45h,36h series DB 12h,56h,99h,45h,36h
data ends data ends
code segment code segment
assume cs:code,ds:data assume cs:code,ds:data
start :mov ax,data start :mov ax,data
mov ds,ax mov ds,ax
mov ch,00h mov ch,00h
mov cl,04h mov cl,04h
lea Si,series lea Si,series
mov al,[SI] mov al,[SI]
X :Inc SI X :Inc SI
mov bl,[SI] mov bl,[SI]
cmp al,bl cmp al,bl
JNC next JC next
XCHG al,bl XCHG al,bl
next : dec cl next : dec cl
jnz x jnz x
int 3 int 3
code ends code ends
end start end start
3.
##count of even odd 4.
DATA SEGMENT ##count of Positive negative
LIST DB 11h,12h, 13h, 14h, 15h DATA SEGMENT
DATA ENDS LIST DB 11h,12h, 13h, 14h, 0FEh
CODE SEGMENT DATA ENDS
ASSUME CS: CODE, DS:DATA CODE SEGMENT
START: MOV Ax, DATA ASSUME CS: CODE, DS:DATA
MOV DS, AX START: MOV Ax, DATA
Lea SI, LIST MOV DS, AX
Mov BL, 05h Lea SI, LIST
Mov CL, 00H Mov BL, 05h
mov Ch,00h Mov CL, 00H
L2: MOV AL, [SI] mov Ch,00h
SHR AL, 01 L2: MOV AL, [SI]
JC L1 SHL AL, 01
INC CL JC L1
JMP L3 INC CL
L1: INC CH JMP L3
L3: INC SI L1: INC CH
DEC BL L3: INC SI
JNZ L2 DEC BL
CODE ENDS JNZ L2
END START CODE ENDS

END START
5.
PROGRAM FOR ASCENDING PROGRAM FOR
SORT: DESCENDING SORT:-
data segment DATA SEGMENT
series DB 99h,12h,56h,45h,36h STRING1 DB 99H,12H,56H,45H,36H
data ends DATA ENDS
code segment CODE SEGMENT
assume cs:code,ds:data ASSUME CS:CODE,DS:DATA
start :mov ax,data START: MOV AX,DATA
mov ds,ax MOV DS,AX
mov ch,04h MOV CH,04H
y :mov cl,04h Y: MOV CL,04H
lea SI,series LEA SI,STRING1
x :mov al,[SI] X:MOV AL,[SI]
mov bl,[SI+1] MOV BL,[SI+1]
cmp al,bl CMP AL,BL
JC next JNC DOWN
mov dl,[SI+1] MOV DL,[SI+1]
XCHG [SI],dl XCHG [SI],DL
mov [SI+1],dl MOV [SI+1],DL
next : inc SI DOWN: INC SI
dec cl DEC CL
jnz x JNZ X
dec ch DEC CH
jnz y JNZ Y
int 3 INT 3
code ends CODE ENDS
end start END START
6.
Fibonacci Series.

data segment
num1 db 05h
res db 10 dup(?)
data ends
code segment
assume cs:code,ds:data
start: mov ax,data
mov ds,ax
mov cx,05h
lea si,res
mov al,00h
mov bl,01h
mov [si],al
inc si
mov [si],bl
inc si
up: mov al,[si-2]
mov bl,[si-1]
add al,bl
mov [si],al
inc si
loop up
int 3
code ends
end start
7.
Transfer block of data
data segment
block1 db 02h,04h,08h
data ends
extra segment
block2 db 03h,05h,07h
extra ends
code segment
assume cs:code,ds:data,es:extra
start:mov ax,data
mov ds,ax
mov ax,extra
mov es,ax
mov cl,03h
lea si,block1
lea di,block2
x:mov ah,ds:[si]
mov bh,es:[di]
mov es:[di],ah
mov ds:[si],bh
inc si
inc di
dec cl
jnz x
int 3
code ends
end start
8.
Factorial of number using Macros.

factorial macro
mov ax,01h
mov bl,05h
y:mul bl
dec bl
cmp bl,01
jnz y
endm
data segment
num db 05h
data ends
code segment
assume ds:data,cs:code
start:mov ax,data
mov ds,ax
factorial 05h
int 3
code ends
end start
9.

Program to reverse a string.


data segment
str1 db 10 dup(?)
msg1 db "Enter a string:$"
msg2 db "Reverse of string:$"
data ends
code segment
assume cs:code,ds:data
start:
mov ax, data
mov ds, ax
mov dx, offset msg1;
mov ah, 09
int 21h
mov cl, 00h
mov si, offset str1;
nex: mov ah, 01h
int 21h;
cmp al, 0dh;
je out1
mov [si], al
inc si;
inc cl
jmp nex;
out1: mov dx, offset msg2
mov ah, 09
int 21h;
back: dec si
mov dl,[si]

mov ah, 02;


int 21h
loop back;
mov ax, 4c00h
int 21h
code ends
end start

You might also like