I have a problem with my code. I suppose to input a string ans output to all caps. But then, I output is nothing.

09219e4acd73eb0184487c54b207c04f

TITLE   LAB TUTORIAL 1

.model  small
.stack  100h

.data
msg1    db  "Enter a string: $"
msg2    db  "Output: $"
msg3    db  "Number of characters: $"
blank   db  0dh, 0ah,'$'
string  db  99 dup(?)

.code
main    proc
    mov     ax, @data
    mov     ds, ax  
    mov dx, offset msg1
    mov ah, 9
    int 21h

    mov     si, offset string
top:    mov     ah, 1
    int     21h
    cmp     al, 13
    je  stop
    mov     [si], al
    inc     si

    jmp     top
stop:   mov     al, '$'
    mov [si], al


    mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    cmp     al, 'z'
    sub     al, 32

    mov dx, offset blank
    mov ah, 9
    int 21h
    mov dx, offset msg2
    mov ah, 9
    int 21h

    mov ax, 4c00h
    int 21h

main    endp
end main

Dear Young Sir,
Allow me to impart some valuable advice to you. This wisdom will no doubt be instilled within your malleable young mind in years to come, but you would be so much more blessed to receive sooner as opposed to later.
Permit me to make this humble suggestion for your betterment and coding enrichment:

COMMENT YOUR !@$% CODE

Or when you can, use self-documenting code which is not so easy in assembly, but some people manage.
Now, as to your dilemma, the answer was simple after I read your code and referenced external material.

    mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    cmp     al, 'z'
    sub     al, 32

This is where you should be making your adjustments. You need to go through each character and identify if it is an actual lower case letter. If so, you subtract 32 as you're doing. Then mov the value back to [si] then increment the offset si. But you have to loop.
The loop ends when you come to the '$' terminator. This will require a cmp and je combo. And since the labels "top" and "stop" have already been used, you'll have to pick different labels for your loop.

EDIT: And once you're done, you'll need to print out the new string after line 45 (the last print command), but before 47 (the program terminator).

Good luck on your homework.

Seeing as this is homework, I'm not giving you the tip outright or step-by-step. Follow above poster's advice, but here's some extra food for thought. The ASCII values for a lower case letter and its capital counterpart have some interesting properties. Look at them in hex or in binary form. You can switch from lowercase to capital with a specific bitwise operation and accompanying bitmask.

.stack  100h

.data
msg1    db  "Enter a string: $"
msg2    db  "Output: $"
msg3    db  "Number of characters: $"
blank   db  0dh, 0ah,'$'
string  db  99 dup(?)

.code
main    proc
    mov     ax, @data
    mov     ds, ax  
    mov dx, offset msg1
    mov ah, 9
    int 21h

    mov     si, offset string
top:    mov     ah, 1
    int     21h
    cmp     al, 13
    je  stop
    mov     [si], al
    inc     si

    jmp     top
stop:   mov     al, '$'
    mov [si], al


top2:   mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    cmp     al, 'z'
    sub     al, 32
    mov [si], al
    inc si

    jmp top2
stop2:  mov al, '$'
    mov [si], al

    mov dx, offset blank
    mov ah, 9
    int 21h
    mov dx, offset msg2
    mov ah, 9
    int 21h

    mov ax, 4c00h
    int 21h

main    endp
end main

Sorry, I was totally lost. Unlimited loop.

Let me pull this snippet from a previous post of yours:

    mov si, offset string
    mov     al, [si]
    cmp     al, 'a'
    jl  noconvert
    cmp     al, 'z'
    jg  noconvert
    sub     al, 32

This will actually work well in deciding which characters to convert.
You will still need to plug the converted value back in as you're doing in your above post.
But you also need to change where your second loop starts.
And you still need to check for the delimiter character to exit the loop and carry on.
Happy coding!
(Comment your code.)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.