Search code examples
assemblymicroprocessorsemu8086

Assembly output (I did not get it)


I want to print a single string computer on the screen

But my output displays the string twice like this:

 computercomputer

My code:

data segment   
mesaj db "computer$"
ends
stack segment
dw   128  dup(0)
ends
code segment
start:
mov ax,@data
mov ds,ax
call ekransil
lea dx,mesaj    
call yaz
yaz proc
mov ah,09
int 21h
ret
yaz endp
ekransil proc ;create procedur
mov ax,0600h
mov bh,74h
mov cx,0000h
mov dx,184fh
int 10h
ret
ekransil endp
int 20h
end start ;finish program

Why does the value display in the data segment print twice? I don't understand. Anybody help me.


Solution

  • What is the next instruction to execute after this one call yaz ? The following instructions will be executed

    mov ah,09
    int 21h
    ret
    

    hence you got 2x 'computer' word. After this line call yaz you should jump at the end of program or ret call.

    Did you see it ?

     call ekransil
     lea dx,mesaj    
     call yaz         
     ; next instructions to execute are below
     yaz proc
       mov ah,09
       int 21h
       ret
     yaz endp