You missed RET
at the end of function
:
function proc
mov dx,offset message
mov ah,9
int 21h
RET
endp
If you don't put the RET
here you'll find that the recursion occures as function
called multiple times (while the stack don't exceeded).