Q4.txt - TITLE My First Program(Test.asm INCLUDE Irvine32.inc.data string1 BYTE"Saad is bas,0 stringL DWORD $-OFFSET string1-1 string2 BYTE source

Q4.txt - TITLE My First Program(Test.asm INCLUDE...

This preview shows page 1 - 2 out of 2 pages.

TITLE My First Program (Test.asm) INCLUDE Irvine32.inc .data string1 BYTE "Saad is bas",0 stringL DWORD $-OFFSET string1-1 string2 BYTE ? source BYTE "Faseeh" dest BYTE "Faseeh" msg1 BYTE "Strings are not equal",0dh,0ah,0 msg2 BYTE "Strings are equal",0dh,0ah,0 string BYTE "Antiseptic",0 strlen1 WORD $-string search BYTE "Anti",0 msgF Byte "String Found",0 msgNF BYTE "String Not Found",0 .code ;Q4c StringCmp PROC, str1: ptr byte, str2: ptr byte cld; direction = forward mov esi, str1 mov edi, str2 mov ecx,LENGTHOF str1 repz cmpsb jb source_smaller mov edx, OFFSET msg1; "Strings are equal" jmp done source_smaller: mov edx, OFFSET msg2; "Strings are not equal" done: call WriteString ret StringCmp ENDP ;Q4d ;Function that copies contents of one string into another StringCopy PROC, str1: ptr byte, str2: ptr byte,strLen:DWORD
Image of page 1

Subscribe to view the full document.

Image of page 2

Unformatted text preview: cld; clear direction flag mov esi, str1 ; ESI points to source mov edi, str2 ; EDI points to target mov ecx, strLen rep movsb; move 10 bytes mov edx, str2 call WriteString ret StringCopy ENDP ;Q4b ;Find a particular string in another string StringFind PROC, str1: ptr byte, str2: byte mov cx,lengthof str1 mov edi,str1 mov al,str2 repne scasb jz yes mov edx,OFFSET msgNF call WriteString call crlf jmp E yes: mov edx,OFFSET msgF call WriteString call crlf jmp E E: ret StringFind ENDP main proc ;mov eax, stringL ;call WriteInt ;INVOKE StringCopy, OFFSET string1, OFFSET string2, stringL call Crlf ;INVOKE StringCmp, OFFSET source, OFFSET dest INVOKE StringFind, OFFSET string, search exit main ENDP END main...
View Full Document

  • Fall '19

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes