TITLE DemoString (demo6.asm) ; Author: Roger ; CS271 in-class demo 2/22/2022 ; Description: This program asks the user to enter a string, ; and then displays the string in all caps. ; Finally, the string is displayed backwards. INCLUDE Irvine32.inc MAXSIZE = 100 ; constant .data inString BYTE MAXSIZE DUP(?) ; User's string outString BYTE MAXSIZE DUP(?) ; User's string capitalized prompt1 BYTE "Enter a string: ",0 sLength DWORD 0 .code main PROC ; Get user input: mov edx, offset prompt1 call WriteString mov edx, offset inString mov ecx, MAXSIZE call ReadString call Crlf ; Set up the loop counter, put the string addresses in the source ; and index registers, and clear the direction flag: mov sLength, eax mov ecx, eax mov esi, offset inString mov edi, offset outString cld ; Check each character to determine if it is a lower-case letter. ; If yes, change it to a capital letter. Store all characters in ; the converted string: ; while inString[i] >= 97 && inString[i] <= 122 (97-'a', 122-'z', 65-'A', 90-'Z') counter: lodsb ; mov al , [esi] inc esi cmp al, 97 jl notLC cmp al, 122 jg notLC sub al, 32 notLC: stosb loop counter ; Display the converted string: mov edx, offset outString call WriteString call Crlf ; Reverse the string mov ecx, sLength mov esi, offset inString add esi, ecx dec esi mov edi, offset outString reverse: std lodsb cld stosb loop reverse ; Display reversed string mov edx, offset outString call WriteString call Crlf exit ;exit to operating system main ENDP END main