F
F
Firetheestle2016-04-21 08:53:52
assembler
Firetheestle, 2016-04-21 08:53:52

Why such a strange conclusion?

Given a task:
Enter 2 lines of characters and reserve space for the third line. Compare the first two and if they have different letters, then write these letters in the third line.
Here is the code:

include io.asm
Sseg segment stack 
  db 256 dup(?)
Sseg ends
Dseg segment
v1 db 0dh,0ah,'Vvedite stroku N1: $'
v2 db 0dh,0ah,'Vvedite stroku N2: $'
s1 db 5 dup(?)
s2 db 5 dup(?)
s3 dw 5 dup(?)
Dseg ends
Cseg segment 
    assume cs:Cseg,DS:Dseg,SS:Sseg,ES:Dseg
start:
    mov ax,Dseg
    mov ds,ax
    mov es,ax
    
    cld
    lea dx,v1
    outstr 
    mov cx,5
    mov si,0
vvod1:  
    inch s1[si]
    inc si
    loop vvod1
    
    newline
    
    lea dx,v2
    outstr
    mov cx,5
    mov si,0
vvod2:
    inch s2[si]
    inc si
    loop vvod2
    
    lea si,s2
    lea di,es:s1
  
    mov cx,5	
srav:
    repe cmps s1,s2
    mov bx,0
    dec di
    mov s3[bx],di
    inc di
    inc bx
    loop srav
    
    mov cx,5
    
   	mov ah, 09	 
   	lea dx, s3	 
   	int 21h
    finish
Cseg ends 
end start

and for some reason it outputs strangely ;C
be5dd2346faf47e39dd13d62437da7a1.png40506ac6ea234cefaa8538b159e7cc22.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2016-04-21
@Firetheestle

Can you explain what's going on here:

srav:
    repe cmps s1,s2
    mov bx,0
    dec di
    mov s3[bx],di
    inc di
    inc bx
    loop srav

In addition, for a string to be output by function 9 int21, it must end with a '$' character.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question