Write an assembly language program that collects a string from the user then counts and displays the number of alphabets (characters range: a to z or A to Z), the number of digits (character range: 0 to 9) and number of any other characters which are not alphabets or digits. For example, below are examples of input/output. input string: abc number of alphabets: 3 number of digits: other characters: input string: abc123 number of alphabets: 3 number of digits: other characters: input string: abc,123 number of alphabets: 3 number of digits: 3 other characters: 1 input string: a*2 number of alphabets: number of digits: 1 other characters: 1 input string: number of alphabets: 0 number of digits: other characters: input string: AbC0? number of alphabets: 3 number of digits: other characters: Use the following procedures for input/output. For more details about these procedures see Chapter 5 of Irvine textbook. • ReadString: Reads a string from the keyboard and returns its length in the EAX register. WriteString: Writes a null-terminated string to the console window. m O O
You have to use Irvine32 library only
And there is sample code about the problem need to complete and write it in other shape as you can
INCLUDE Irvine32.inc
.data
str1 BYTE 81 DUP(0) ; buffer to store the string
maxStr DWORD 81 ; maximum number of characters to read
strLen DWORD 0 ; memory to store the length of string
msg1 BYTE "Input: ",0
msg2 BYTE "The string has ",0
msg3 BYTE " characters",0
.code
main PROC
call readStr
call printResult
exit
main ENDP
readStr PROC ; show msg1 in the screen MOV EDX, OFFSET msg1
call writeString ; read from the keyboard into str1
MOV EDX, OFFSET str1 ; EDX = memory address of string buffer
MOV ECX, maxStr ; save maximum chars to read from keyboard in ECX
call readString ; call Irvine readString procedure to read string
; store string length in strLen variable
MOV strLen, EAX
readStr ENDP
printResult
PROC
MOV EDX, OFFSET msg2
call writeString
MOV EAX, strLen
call writeDec
MOV EDX, OFFSET msg3
call writeString
call crlf
call crlf
printResult
ENDP
END main
Trending now
This is a popular solution!
Step by step
Solved in 2 steps