Hi I am trying to write a program that counts the number of letter in a string.
My code compiles fine but doesnt work when I run it.

My output should be "Capital letters appear x times in y"
Where x is the num (from my code) and y is (txt)

.model small
.stack 100h

txt db "A Student of Carleton University", 0dh, 0ah, "$"
rslt db "Capital Letter appear x times in y", 0dh, 0ah, "$"
num db ?

main PROC

        MOV AX, @data
        MOV DS, AX

        MOV BX, offset txt
        MOV SI, 0
        MOV rslt+ 33, AL

        CMP BYTE PTR [BX+SI], 0dh
        JE Done

        CMP BYTE PTR [BX+SI], 'A'
        JL NEXT
        CMP BYTE PTR [BX+SI], 'Z'
        JG NEXT
        ADD num, 1        

        ADD SI, 1
        JMP CheckForDone

        MOV AL, num
        MOV rslt+22, AL
        MOV AX, 09h
        MOV DX, offset rslt
        INT 21h
        MOV AX, 4C00h
        INT 21h

main ENDP
END main 
5 Years
Discussion Span
Last Post by ShiftLeft

At line 37, you need to covert the value in AL to a digit. See examples of converting Binary to ASCII. Simply, a value of 9 lets say in AL needs to be 39H so it will display as the digit 9. Otherwise it's interpreted on most systems as TAB.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.