I have a procedure in assembly which supposed to take a string and 2 numbers that will represent the number of milliseconds to wait after printing each letter, also it first count the length of the string and then starts to print it letter by letter with a delay of %cx:%dx this is the code:
IDEAL
MODEL small
STACK 100h   
DATASEG
    x db 02
    string db "hello, my name is ____",0Ah, 0Dh,"and this is my game:",0Ah,0Dh ,'$'
    string2 db "this is a test ",0Ah ,'$'
    
CODESEG
    
proc PrintString
    xor dx, dx
    push bp
    mov bp, sp
    mov bp, [bp+8h] ;string offset
    xor cx, cx
    WhileLoop:
        mov dl, [byte ptr ds:bp] ;string offset in the ds
        inc bp
        inc cx
        cmp dl, 24h
        jne WhileLoop
    mov bp, sp
    mov bx, bp
    mov bp, [bp+8h] ; string offset
    sub cx, 1
    PrintLoop:
        mov dl, [byte ptr ds:bp]
        mov ah, 02h
        inc bp
        int 21h
        mov ah, 86h
        push cx
        ;watiting cx:dx milliseconds
        mov cx, [ss:bx+6]     ;push 03h
        mov dx, [ss:bx+4]     ;push 01615h
        int 15h
        pop cx
        loop PrintLoop
    pop bp
    ret
endp
    
    
start:
    mov ax, @data
    mov ds, ax
    push offset string
    push 03h
    push 01615h
    call PrintString
    pop ax
    pop ax
    pop ax
    xor ax, ax
    push offset string2
    push 05h
    push 01615h
    call PrintString
    
exit:
    mov ax, 4c00h
    int 21h
END start
everything works fine when the code looks like this. buf if I delete the x variable which I don't use even once in my code - the code suddenly doesn't work and the output looks like this:

it gets stuck at the h, sometimes it manages to print also the second letter ('e') also if I keep the variable x but I try to change the text to something else it also doesn't work:
but if I make the string really short it works with or without the variable x:

