0% found this document useful (0 votes)
46 views7 pages

Coal Lab 11

Task 1 searches a string for a character, finds the index if present, and displays it. Task 2 does the same with a separate character searching function. Task 3 compares two user-input strings and indicates if they are equal. Task 4 copies a user-input string to a new location and displays the copied string.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views7 pages

Coal Lab 11

Task 1 searches a string for a character, finds the index if present, and displays it. Task 2 does the same with a separate character searching function. Task 3 compares two user-input strings and indicates if they are equal. Task 4 copies a user-input string to a new location and displays the copied string.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

NAME: SYED MUNEEB ALI RIZVI

ROLL NO: 21K-4924


SEC: K
COAL LAB # 11
TASK NO 1:
Include Irvine32.inc
Include Macros.inc
.data
Str1 BYTE "127&j~3#^&*#*#45^",0
char BYTE ?
.code
MAIN PROC
mWrite " Enter the character to be searched: "
call readChar
mov char,al
call WriteChar
mov edi,OFFSET Str1
mov ecx,LENGTHOF Str1
cld
repne scasb
jnz quit
dec edi
quit:
call crlf
mov eax,LENGTHOF Str1
dec eax
sub eax,ecx
mWrite " Character Found at index #: "
call WriteDec
exit
MAIN ENDP
END MAIN
TASK NO 2:
Include Irvine32.inc
Include Macros.inc
.data
Str1 BYTE "127&j~3#^&*#*#45^",0
char BYTE ?
.code
MAIN PROC
mWrite " Enter the character to be searched: "
call readChar
mov char,al
call WriteChar
call scan_char
exit
MAIN ENDP

scan_char PROC
mov edi,OFFSET Str1
mov ecx,LENGTHOF Str1
mov al,char
cld
repne scasb
jnz quit
dec edi
quit:
call crlf
mov eax,LENGTHOF Str1
dec eax
sub eax,ecx
mWrite " Character Found at index #: "
call WriteDec
ret
scan_char ENDP
END MAIN
TASK NO 3:
Include Irvine32.inc
Include Macros.inc
.data
Str1 BYTE 50 DUP(?)
Str2 BYTE 50 DUP(?)
.code
MAIN PROC
mov ecx, Lengthof Str1
mWrite "Enter first string: "
mov edx,OFFSET Str1
call ReadString
mov [Str1 + eax],0
mov ecx, Lengthof Str2
mWrite "Enter second string: "
mov edx,OFFSET Str2
call ReadString
mov [Str2 + eax],0
call isCompare
exit
MAIN ENDP

isCompare PROC
mov esi,OFFSET Str1
mov edi,OFFSET Str2
cld
repe cmpsb
je equalStrings
quit:
mWrite "The strings are unequal"
ret
equalStrings:
mWrite "The strings are equal "
ret
isCompare ENDP
END MAIN
TASK NO 4:
Include Irvine32.inc
Include Macros.inc
.data
Str1 BYTE 50 DUP(?)
Str2 BYTE LENGTHOF Str1 DUP(?)
.code
MAIN PROC
mov ecx, Lengthof Str1
mWrite "Enter first string: "
mov edx,OFFSET Str1
call ReadString
mov [Str1 + eax],0
call Move
exit
MAIN ENDP

Move PROC
mov esi,OFFSET Str1
mov edi,OFFSET Str2
mov ecx,LENGTHOF Str1
cld
rep movsb
mWrite "The copied string is: "
mov edx,OFFSET Str2
call WriteString
ret
Move ENDP
END MAIN
TASK NO 5:
Include Irvine32.inc
Include Macros.inc
.data
Str1 BYTE 50 DUP(?)
actualSize DWORD ?
.code
MAIN PROC
mov ecx, Lengthof Str1
mWrite "Enter the string: "
mov edx,OFFSET Str1
call ReadString
mov actualSize,eax
mov [Str1 + eax],0
call Str_Reverse
mWrite "The Reversed String is: "
mov edx,OFFSET Str1
mov ecx,actualSize
call WriteString
exit
MAIN ENDP

Str_Reverse PROC
mov edx,actualSize
dec edx
mov ecx,actualSize
shr ecx,1
mov ebx,0
reverseTime:
mov al,[Str1 + ebx]
xchg al,[Str1 + edx]
mov [Str1 + ebx],al
inc ebx
dec edx
loop reverseTime
ret
Str_Reverse ENDP
END MAIN
TASK NO 6:
Include Irvine32.inc
Include Macros.inc

.data
arr DWORD 1,2,3,4,5,6,7,8,9,10
multiplier DWORD ?
.code
MAIN PROC
mWrite "Enter the number to multiply the array with: "
call ReadInt
mov multiplier,eax
call multiplyArray
mov ecx,LENGTHOF arr
mov ebx,0
printIt:
mov eax,[arr + ebx*TYPE arr]
call WriteDec
mWrite " "
inc ebx
loop printIt
MAIN ENDP

multiplyArray PROC
mov esi,OFFSET arr
mov edi,OFFSET arr
cld
mov ecx,LENGTHOF arr
loopIt:
LODSD
mul multiplier
STOSD
loop loopIt
ret
multiplyArray ENDP
END MAIN

You might also like