print macro msg
lea dx,msg
mov ah,09h
int 21h
endm
read macro msg1
mov dx,offset msg1
mov bx,00h
mov ah,3fh
int 21h
endm
.model small
.stack 100h
.data
s1 db 10,13,'Enter a string $'
s2 db 10,13,'Strings are equal $'
s4 db 10,13,'String1 is less than String2 $'
s5 db 10,13,'String2 is less than String1 $'
s3 db 50 dup('$')
s6 db 50 dup('$')
len1 dw 0
len2 dw 0
fl db 0
.code
mov ax,@data
mov ds,ax
print s1
;reading 1st string
read s3
;finding the length of 1st string
sub ax,02
mov len1,ax
print s1
;reading 2nd string
read s6
;finding the length of 1st string
sub ax,02
mov len2,ax
;Assign cx(count) as smallest length
mov cx,ax
cmp ax,len1
jc jump1
mov cx,len1
;comparing each characters
jump1:mov si,00h
loop1:mov al,s3[si]
cmp al,s6[si]
jc fir
jnz notp
inc si
loop loop1
mov ax,len1
cmp ax,len2
jc fir
jnz notp
print s2
jmp stop
fir:print s4
jmp stop
notp:print s5
stop:mov ah,4ch
int 21h
end
No comments:
Post a Comment