Pergunta

I'm trying to display 3 messages,one of them using a function.But that function never stops displaying the message. This is the code:

.model small
.data
message db "Hello from function!$"  
message1 db "Hello from the court!$" 
message2 db "Hello from the second court!$" 
.code
function proc
  mov dx,offset message;
  mov ah,9; 
int 21h;
endp


mov ax,@data;
mov ds,ax;

call function

lea dx,message1;
mov ah,9;
int 21;

call function

lea dx,message2;
mov ah,9;
int 21;

call function

mov ax,4c00h;
int 21h;
Foi útil?

Solução

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).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top