Write a program to compare two strings?

1 answer

Answer

1239176

2026-07-08 07:11

+ Follow

Registers used: ax,ds,si,di,cl

flags affected: zf,cf

program:

assume cs:code,ds:data

code segment

mov ax,data

mov ds,ax

mov si,offset str1

mov di,offset str2

mov cl,count

cld

rep cmpsb

hlt

code ends

data segment

str1 db 04h,05h,07h,08h

count equ 04h

org 0010h

str2 db 04h,06h,07h,09h

data ends

end

result:

input: str1 (ds:0000h) = 04h,05h,07h,08h

str2 (ds:0010h) = 04h,06h,07h,09h

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.