Sie sind auf Seite 1von 17

ass-9

<program 1>
ddosseg
.model small
.8086

.data
num1 db 09h
num2 db 0ah
sum db 00h
carry db 00h
diff db 00h
borr db 00hd
.code
start:
mov ax,@data
mov ds,ax

mov al,num1
add al,num2
jnc skip
inc carry
skip: mov sum,al

mov al,num1
sub al,num2
jnc skip1
inc borr
skip1: mov diff,al

int 03h
end start

<program 2>
dosseg
.model small
.8086

.data
num1 dw 1020h
num2 dw 1081h
sum dw 0000h
carry dw 0000h
diff dw 0000h
borrow dw 0000h

.code
start:
mov ax,@data
mov ds,ax

mov ax,num1
add ax,num2
jnc skip1
inc carry
skip1: mov sum,ax
mov ax,num1
sub ax,num2
jnc skip2
inc borrow
skip2: mov diff,ax

mov ax,4c00h
int 21h

end start

<program 3>
dosseg
.model small
.8086

.data
num1 dw 0100h
num2 dw 0100h

.code
start:
mov ax,@data
mov ds,ax

mov ax,num1
mul num2

int 03h
end start

<program 4>
dosseg
.model small
.8086

.data
num1 dw 0011h
num2 db 00h
quo db 00h
rem db 00h
msg db "Divisor is zero$"
.code
start:
mov ax,@data
mov ds,ax

mov al,num2
or al,al
jnz next
mov ah,09h
lea dx,msg
int 21h
jmp last

next:
mov ax, num1
div num2
mov quo,al
mov rem,ah

last:
int 03h
end start

<program 5>
;GCD in AL and LCM in DX
dosseg
.model small
.8086
.stack 100h

data segment
num1 db 0Ah ;10
num2 db 0Fh ;15
gcd_ db ?
lcm_ db ?
temp db ?
msg1 db 13,10,"GCD IS : $"
msg2 db 13,10,"LCM IS : $"
data ends

code segment
assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

mov ah,num1
mov al,num2
cmp ah,al
jc labels
xchg ah,al

labels : call gcd_no


call lcm_no
;printing gcd and lcm
mov ah,09h
lea dx,msg1
int 21h

mov al,gcd_
mov temp,al
call print

mov ah,09h
lea dx,msg2
int 21h

mov al,lcm_
mov temp,al
call print

int 03h
gcd_no proc
;ah smaller no and al larger no
or ah,ah
jz skip
loops : mov dx,ax
mov ah,00h
div dh
mov al,dh
or ah,ah
jnz loops
skip: mov gcd_,al
ret
gcd_no endp

lcm_no proc
mov al,num1
mul num2
div gcd_
mov lcm_, al
ret
lcm_no endp

print proc
mov dl,temp
rol dl,04h
and dl,0fh
cmp dl,09h
jz skip3
jc skip3
add dl,07h
skip3: add dl,30h
mov ah,02h
int 21h
mov dl,temp
and dl,0fh
cmp dl,09h
jz skip4
jc skip4
add dl,07h
skip4: add dl,30h
mov ah,02h
int 21h

ret
print endp
code ends
end start

ass-10
<program1>
.model sm
<program1>
.model small
.8086

.data
a dw 0000h
b db 00h
.code
start: mov ax,@data
mov ds,ax

mov [si+0000h],0001h
mov [si+0002h],0002h
mov [si+0004h],0003h

mov cx,03h
mov ax,0000h
mov dx,ax

till: mov bx,[si+00h]


add ax,bx
jnc skip
inc dl
skip: inc si
inc si
loop till

mov a,ax
mov b,dl

int 03h
end start

<program3>
.model small
.8086

.data
a db 10h,05h,60h,02h

.code
start: mov ax,@data
mov ds,ax

mov cx,0004h
mov si,offset a
mov al,[si]
mov ah,[si]
inc si
dec cx

till: mov bl,[si]


inc si
cmp al,bl
jc skip
mov al,bl
skip: cmp ah,bl
jnc skip1
mov ah,bl
skip1: loop till

int 03h
end start
<program5>
.model small
.8086

data segment

a db 13,10,"hello kalp$"

data ends

extra segment
b db 10 dup('$')

extra ends

code segment
Assume cs:code,ds:data,es:extra

start:
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax

lea si,a+2
lea di,b+4

mov cx,0005h

back: cld
lodsb
std
stosb
loop back

mov ax,extra
mov ds,ax

mov ah,09h

lea dx,b
int 21h
int 03h

end start
<program2>
dosseg
.model small

.8086

data segment
a db 10,13,"Enter 1st string: $"
b db 10,13,"Enter 2nd string: $"

space db 10,13,"$"

c db 100 dup('$')
d db 100 dup('$')
count1 dw 0000h
count2 dw 0000h

data ends

extra segment
e db 200 dup('$')

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 ah,09h
lea dx,a
int 21h

mov ah,0ah
lea dx,c
int 21h

mov ah,09h
lea dx,b
int 21h

mov ah,0ah
lea dx,d
int 21h

mov ah,09h
lea dx,space
int 21h

lea si,c+2

mov cx,0000h

loop1: mov ax,[si]


cmp al,'$'
jz skip3
inc cx
inc si
jmp loop1

skip3: dec cx
mov count1,cx

mov cx,0000h

lea si,d+2

loop2: mov bx,[si]


cmp bx,'$'
jz skip4
inc cx
inc si
jmp loop2

skip4: dec cx
mov count2,cx

lea si,c+2
lea di,e
mov cx,count1
cld
rep movsb

lea si,d+2

mov cx,count2
rep movsb

mov ax,extra
mov ds,ax

mov ah,09h
lea dx,e
int 21h

int 03h
end start

code ends

<program4>
dosseg
.model small
.8086
.stack 100h

data segment
a db "Enter string: $"
b db 100 dup('$')
no db "Not a Pali$"
yes db "Yes a Pali$"
count dw 0000h

data ends

extra segment
c db 200 dup('$')

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 ah,09h
lea dx,a
int 21h

mov ah,0ah
lea dx,b
int 21h

mov ah,02h
mov dl,0ah
int 21h

mov ah,02h
mov dl,0dh
int 21h

mov cx,0000h
lea si,b+2

loop1: mov ax,[si]


cmp ah,'$'
jz skip
mov ah,00h
push ax
inc si
inc cx
jmp loop1

skip:
mov count,cx

mov ax,extra
mov ds,ax

lea di,c

loop2: pop ax
mov [di],ax
inc di
loop loop2

mov ax,data ; if print reverse only than remove both below lines and print c
string
mov ds,ax

lea si,b+2
lea di,c

mov cx,count
cld
repz cmpsb

jnz noo

mov ah,09h
lea dx,yes
int 21h
jmp endd

noo: mov ah,09h


lea dx,no
int 21h

endd: int 03h


code ends
end start

<program6>
dosseg
.model small
.8086

data segment
array db 09h,03h,04h,01h,0ah,00h
data ends

code segment
Assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

mov ch,05h
loop1:lea si,array
mov cl,05h
loop2:mov ax,[si]
cmp ah,al
jnc next
xchg ah,al
mov [si],ax
next: inc si
dec cl
jnz loop2
dec ch
jnz loop1

int 03h
code ends
end start
<program_substraction_16bit>
.model small
.8086

.data
a dw 0000h
b db 00h

.code
start: mov ax,@data
mov ds,ax

mov [si+0000h],0009h
mov [si+0002h],0004h
mov [si+0004h],0002h
mov cx,0002h
mov ax,[si+0000h]
inc si
inc si

till: sub ax,[si+0000h]


inc si
inc si
loop till

mov a,ax

int 03h
end start
.8086

.data
a dw 0000h
b db 00h

.code
start: mov ax,@data
mov ds,ax

mov [si+0000h],0001h
mov [si+0002h],0002h
mov [si+0004h],0003h

mov cx,03h
mov ax,0000h
mov dx,ax

till: mov bx,[si+00h]


add ax,bx
jnc skip
inc dl
skip: inc si
inc si
loop till

mov a,ax
mov b,dl

int 03h
end start

<program3>
.model small
.8086

.data
a db 10h,05h,60h,02h

.code
start: mov ax,@data
mov ds,ax
mov cx,0004h
mov si,offset a
mov al,[si]
mov ah,[si]
inc si
dec cx

till: mov bl,[si]


inc si
cmp al,bl
jc skip
mov al,bl
skip: cmp ah,bl
jnc skip1
mov ah,bl
skip1: loop till

int 03h
end start
<program5>
.model small
.8086

data segment

a db 13,10,"hello kalp$"

data ends

extra segment
b db 10 dup('$')

extra ends

code segment
Assume cs:code,ds:data,es:extra

start:
mov ax,data
mov ds,ax
mov ax,extra
mov es,ax

lea si,a+2
lea di,b+4

mov cx,0005h

back: cld
lodsb
std
stosb
loop back

mov ax,extra
mov ds,ax

mov ah,09h
lea dx,b
int 21h
int 03h

end start
<program2>
dosseg
.model small

.8086

data segment
a db 10,13,"Enter 1st string: $"
b db 10,13,"Enter 2nd string: $"

space db 10,13,"$"

c db 100 dup('$')
d db 100 dup('$')

count1 dw 0000h
count2 dw 0000h

data ends

extra segment
e db 200 dup('$')

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 ah,09h
lea dx,a
int 21h

mov ah,0ah
lea dx,c
int 21h

mov ah,09h
lea dx,b
int 21h

mov ah,0ah
lea dx,d
int 21h

mov ah,09h
lea dx,space
int 21h
lea si,c+2

mov cx,0000h

loop1: mov ax,[si]


cmp al,'$'
jz skip3
inc cx
inc si
jmp loop1

skip3: dec cx
mov count1,cx

mov cx,0000h

lea si,d+2

loop2: mov bx,[si]


cmp bx,'$'
jz skip4
inc cx
inc si
jmp loop2

skip4: dec cx
mov count2,cx

lea si,c+2
lea di,e
mov cx,count1
cld
rep movsb

lea si,d+2

mov cx,count2
rep movsb

mov ax,extra
mov ds,ax

mov ah,09h
lea dx,e
int 21h

int 03h
end start

code ends

<program4>
dosseg
.model small
.8086
.stack 100h
data segment
a db "Enter string: $"
b db 100 dup('$')
no db "Not a Pali$"
yes db "Yes a Pali$"
count dw 0000h

data ends

extra segment
c db 200 dup('$')

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 ah,09h
lea dx,a
int 21h

mov ah,0ah
lea dx,b
int 21h

mov ah,02h
mov dl,0ah
int 21h

mov ah,02h
mov dl,0dh
int 21h

mov cx,0000h
lea si,b+2

loop1: mov ax,[si]


cmp ah,'$'
jz skip
mov ah,00h
push ax
inc si
inc cx
jmp loop1

skip:
mov count,cx

mov ax,extra
mov ds,ax

lea di,c
loop2: pop ax
mov [di],ax
inc di
loop loop2

mov ax,data ; if print reverse only than remove both below lines and print c
string
mov ds,ax

lea si,b+2
lea di,c

mov cx,count
cld
repz cmpsb

jnz noo

mov ah,09h
lea dx,yes
int 21h
jmp endd

noo: mov ah,09h


lea dx,no
int 21h

endd: int 03h


code ends
end start

<program6>
dosseg
.model small
.8086

data segment
array db 09h,03h,04h,01h,0ah,00h
data ends

code segment
Assume cs:code,ds:data
start:
mov ax,data
mov ds,ax

mov ch,05h
loop1:lea si,array
mov cl,05h
loop2:mov ax,[si]
cmp ah,al
jnc next
xchg ah,al
mov [si],ax
next: inc si
dec cl
jnz loop2
dec ch
jnz loop1
int 03h
code ends
end start
<program_substraction_16bit>
.model small
.8086

.data
a dw 0000h
b db 00h

.code
start: mov ax,@data
mov ds,ax

mov [si+0000h],0009h
mov [si+0002h],0004h
mov [si+0004h],0002h

mov cx,0002h
mov ax,[si+0000h]
inc si
inc si

till: sub ax,[si+0000h]


inc si
inc si
loop till

mov a,ax

int 03h
end start