Additional ASCII characters

Viewed 59

I wrote an assembly language program to replace two adjacent characters.

    Code             SEGMENT

                ORG   100h
                ASSUME CS:Code, DS:Code, SS:Code

start:          jmp     here
text           DB      "Sample text","$"

here:
                mov     bx, OFFSET text
loop:
                mov     al, [bx]
                cmp     al, '$'
                je      display
                inc     bx
                mov     ah, [bx]
                cmp     ah, '$'
                je      display
                mov     [bx - 1], ah
                mov     [bx], al
                inc     bx
                jmp     loop
display:
                mov     ah, 09h
                mov     dx, OFFSET text
                int     21h
end:
                mov     ax, 4C00h
                int     21h
Code            ENDS

                END  start  

The problem is that although the program correctly replaces the characters in the sample string, it also adds some other non-matching ASCII characters to the end:

enter image description here

I will be grateful for any help and comments on my code.

0 Answers
Related