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

Info iconThis 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
Background image of page 1

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

View Full DocumentRight Arrow Icon
2. Using the String Reverse program as a starting point, modify the program so it inputs a list of 32-bit integers from the user, and then displays the integers in reverse order.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/08/2010 for the course CMPE 46 at San Jose State University .

Page1 / 5

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

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online