用汇编语言编写程序:有三个字符串,要求找出其中最大者
;如果知道串的长度的话,可以这么做,比如都等长的16个字符
;串比较宏定义
strcmp macro str1,str2
lea si,str1
lea di,str2
mov cx,16
cld
repz cmpsb
endm
;串传送宏定义
strmov macro str1,str2
lea si,str1
lea di,str2
mov cx,16
cld
rep movsb
endm
;------------------------------------------
data segment
str1 db '$';第一个串
str2 db '$';第二个串
str3 db '$';第三个串
max db 16 dup(?),'$'
data ends
;-----------------------------------------
code segment
assume cs:code,ds:data,es:data
main proc
start:
mov ax,data
mov ds,ax
mov es,ax
strmov str1,max ;str1->max
strcmp str2,max
jle lop
strmov str2,max
lop: strcmp str3,max
jle con
strmov str3,max
con: mov ah,09h
lea dx,max
int 21h
exit: mov ah,4ch
int 21h
main endp
code ends
end main
这样打真的好累哦。
。。。。其实还有很多好方法,在这儿打很不方便,这台机子我也没法调试,所以先打了一个比较容易理解的。
答:详情>>