HW4_S10RevA Solution

HW4_S10RevA Solution - CmpE 102 HW#4(Spring 2010...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CmpE 102 – HW#4 (Spring 2010) – SOLUTIONS (Rev. A) Chapter 5 Problems 1. Using the String Reverse program (text p. 133) as a starting point, modify the program so the user can input a string containing between 1 and 50 characters. INCLUDE Irvine32.inc .data aString BYTE 51 DUP(0) ; added null terminator byte = 0 byteCount DWORD ? .code main PROC call ReadChar ; read string size from keyboard movzv ecx, al ; initialize loop counter mov byteCount, ecx ; and save in memory for later use mov edi, 0 ; initialize string index L1: call ReadChar ; input character from keyboard mov aString[edi], al ; put in memory inc edi ; point to next string location loop L1 ; continue until all characters entered mov esi, 0 mov ecx, byteCount L2: movzx eax, aString[esi] ; get character from array push eax ; push on stack inc esi loop L2 ; Pop the string from the stack in reverse, and store in aString array. mov ecx, byteCount mov esi, 0 L3: pop eax ; get character from stack mov aString[esi], al ; store in string inc esi loop L3 ; continue until all characters in string ; Display the character data. mov edx, OFFSET aString call WriteString call Crlf exit main ENDP END main
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2. Using the String Reverse program as a starting point, modify the program so it
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

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