?? cmpstr.asm
字號:
;演示程序
;此程序比較數據段和附加段的兩串字符串string1和string2是否相等
;若相等,顯示“string1 match string2”,否則顯示“the two strings are nomatch”
; -----------定義數據段
DSEG SEGMENT 'DATA'
string1 db "I am a student." ;字符串一
match db " string1 match string2",13,10,'$'
nomatch db "the two strings are nomatch",13,10,'$'
quit db "press any key to exit......",13,10,'$'
DSEG ENDS
; -----------附加段
eseg segment
string2 db "I am a student." ;字符串二
eseg ends
;-----------定義代碼段
CSEG SEGMENT 'CODE'
;*******************************************
START PROC FAR
assume cs:cseg,ds:dseg,es:eseg
;--------------保存返回DOS的地址
PUSH DS
MOV AX, 0
PUSH AX
;------------設置段寄存器
MOV AX, DSEG
MOV DS, AX
mov ax,eseg
MOV ES, AX
lea si,string1
lea di,string2
mov cx,15
cld
repe cmpsb
cmp cx,0
jz mat
;-----------兩字符串不等
mov ah,9
lea dx,nomatch
int 21h
jmp waitforexit
;-----------兩字符串相等
mat:
mov ah,9
lea dx,match
int 21h
;-----------按任意鍵退出
waitforexit:
mov ah,9
lea dx,quit
int 21h
mov ah,1
int 21h
;----------- 返回DOS
exit: RET
START ENDP
;*******************************************
CSEG ENDS
END START ; set entry point.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -