📄 strcmp.asm
字号:
; program compare two strings
; code by brvman 2008/06/08
.model small
.data
first db 80, 0, 80 dup(?)
second db 80, 0, 80 dup(?)
prompt1 db 'Enter the first string:$'
prompt2 db 0dh, 0ah, 'Enter the second string:$'
identical db 0dh, 0ah, 'The two strings are identical$'
diff db 0dh, 0ah, 'The two strings are not identical$'
.stack
compare macro src, dst
local next
local next2
lea si, src
lea di, dst
cld
inc si
inc di
mov cl, [si]
mov ch, [di]
inc si
inc di
cmp cl, ch
jnz next2
movzx cx, cl
repe cmpsb
jnz next2
next:
call iden_print
next2:
call diff_print
endm
.code
.386
start:
mov ax, @data
mov ds, ax
mov es, ax
; input two strings
lea dx, prompt1
mov ah, 09h
int 21h
lea dx, first
mov ah, 0ah
int 21h
mov dx, offset prompt2
mov ah, 09h
int 21h
mov dx, offset second
mov ah, 0ah
int 21h
compare first, second
iden_print proc
lea dx, identical
mov ah, 09h
int 21h
mov ah, 4ch
int 21h
iden_print endp
diff_print proc
lea dx, diff
mov ah, 09h
int 21h
mov ah, 4ch
int 21h
diff_print endp
end start
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -