0% found this document useful (0 votes)
41 views11 pages

CSE2006-Microprocessor and Interfacing Lab Assessment 3 - L11 +L12

This document contains an assembly language program written for an 8086 microprocessor. It includes 3 questions involving binary to hexadecimal conversion, hexadecimal to binary conversion and 2's complement, and string manipulation operations. Code segments are provided to reverse a string, count the number of occurrences of a substring within a given string, and convert binary numbers to and from hexadecimal representation.

Uploaded by

TANMAY MEHROTRA
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)
41 views11 pages

CSE2006-Microprocessor and Interfacing Lab Assessment 3 - L11 +L12

This document contains an assembly language program written for an 8086 microprocessor. It includes 3 questions involving binary to hexadecimal conversion, hexadecimal to binary conversion and 2's complement, and string manipulation operations. Code segments are provided to reverse a string, count the number of occurrences of a substring within a given string, and convert binary numbers to and from hexadecimal representation.

Uploaded by

TANMAY MEHROTRA
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
You are on page 1/ 11

Name-Tanmay Mehrotra

Regno-20BCE2251

CSE2006-Microprocessor and Interfacing


Lab Assessment 3 – L11 +L12

Q1)Write an ALP to convert each of the following binary string to


hexadecimal
a)10011011B
Code
.model small
.stack 64
.data
.code
start:mov ah,10011011b
mov al,ah
mov cl,04h
shr al,cl
mov bl,al
mov al,ah
shl al,cl
shr al,cl
mov cl,al
end start
.end
b) 11001110B
Code

.model small
.stack 64
.data
.code
start:mov ah,11001110b
mov al,ah
mov cl,04h
shr al,cl
mov bl,al
mov al,ah
shl al,cl
shr al,cl
mov cl,al
end start
.end
2)Write an ALP to convert the given hexadecimal number to binary and
perform 2’s complement of the resultant.

a)7EH
Code
.model small
.stack 64
.data
.code
start:jmp here
x db 7eh
here: mov cl,x
mov bl,02h
mov si,2001h
again: mov al,cl
div bl
mov cl,al
mov [si],ah
mov ah,00h
inc si
cmp al,00h
jnz again
hlt
end start
.end
b) 6CF1H

Code
.model small
.stack 64h
.data
.code
start:jmp here
x db 6cf1h
here: mov cl,x
mov bl,02h
mov si,2001h
again: mov al,cl
div bl
mov cl,al
mov [si],ah
mov ah,00h
inc si
cmp al,00h
jnz again
hlt
end start
.end
3)Write 8086 ALP to perform string manipulation.
a)Reverse the string

Code
.model small
.stack 64h
.data
.code
start:jmp here
str1 db 'Tanmay$'
count equ 14h
here: mov cl,count
mov si,offset str1
mov di,offset str1
add di,13
back: mov al,[si]
xchg [di],al
mov [si],al
inc si
dec di
dec cl
jnz back
hlt
end start
.end
b)Number of occurrences of a sub-string in the given string.
Code
.model small
.stack 64h
.data
scall macro xx,yy
lea dx,xx
mov ah,yy
int 21h
endm
m1 db 10d,13d,"Enter first string: $"
m2 db 10d,13d,"Enter second string: $"
s1 db 20 dup('$')
s2 db 20 dup('$')
s3 db 40 dup('$')
nwline db 10d,"$"
m4 db 10d,13d,"Second String is Substring.$"
m5 db 10d,13d,"Second String is not a Substring.$"
m6 db 10d,13d,"No. Of Occurrence: $"
count db 0
.code
mov ax,@data
mov ds,ax
scall m1,09h
scall s1,0Ah
scall m2,09h
scall s2,0Ah
lea si,s1
inc si
lea di,s2
inc di
mov ch,[di]
inc di
mov dh,ch
mov [count],0
loop3:
mov al,[si]
mov bp,si
cmp al,[di]
je loop4
inc si
dec cl
jnz loop3
mov dl,[count]
cmp dl,0
je fail
jmp result
loop4:
dec ch
cmp ch,0
je success
inc si
inc di
mov al,[si]
cmp al,[di]
je loop4
jmp loop3
success:
add [count],01
lea di,s2
add di,2
inc bp
mov si,bp
dec cl
mov ch,dh
jmp loop3
fail:
scall m5,09h
ret
result:
scall m4,09h
scall m6,09h
mov dl,[count]
add dl,30h
mov ah,02h
int 21h
ret
end

You might also like