问题
I have an user input string, which was lowercased and all special characters removed target2
and I want to count how many times each letter appears on the string, and then print the array with 26 letters. However, it prints just a blank line. Is the error when I add to the array? when I print from the array, or both?
If I watch letterArray
, it says 1 '\x1'
What does that mean?
lettersArray byte 26 dup(0)
countingLetters proc
; clear esi and edi
mov esi, 0
mov edi, 0
charloop
mov al, target2[esi] ; Get a character from the string
cmp al, 97 ; Check if its not a letter
jb printloop ; If bellow, print
sub eax, 97 ; so that 'a' = 0, 'z' = 26.
mov dl, lettersArray[eax]
inc dl
mov lettersArray[eax], dl
inc esi
jmp charloop ; repeat
printloop:
mov bl, lettersArray[edx * type lettersArray]
add bl, 48
push edx
invoke WriteConsoleA, consoleOutHandle, ebx, 4, bytesWritten, 0
pop edx
inc edx
cmp edx, 25 ;Are we done?
ja done ;if yes
jmp printloop ; Repeat
done:
ret
countingLetters endp
This should count the appearances of each letter and print an array with 26 elements, i.e: 00102000000000[etc]
来源:https://stackoverflow.com/questions/57347621/counting-letters-and-printing-an-array-of-numbers-with-windows-api