I need to implement a function that finds the smallest letter in a given array of characters (according to its ASCII code), capitalizes it if necessary and then returns it. The function has the following input: an array of characters and the size of the array. Storing the result in dl.
I have this code but I can't get it to work properly
mov dl, 0x7f // initialize DL
mov dh, 0x61 // first value of small letter
mov ah, 0x20 // difference of small letter to capital letter
mov ecx, 0 // counter
mov ebx, arrayOfLetters // initialize array to ebx
cmp ecx, arraySize // loop from 0 to arraySize
mov al, byte ptr[ebx + ecx * 1] // reads the values of the array
cmp al, dl // compare max value to current item of the array
cmp dl, dh
mov dl, al
sub dl, ah // capitalizes the letter
The characters in the array is "cOmPuTeR"
When I try to run this code, I get the output "C" which is incorrect.(It should be "O") I figured that my code only goes through the first pass and doesn't loop so in my MIN_FOUND I added
mov dl, al
but when I try to compile it, it won't run and gives me an unhandled exception.
I appreciate any input or suggestions thanks.