我有一个汇编级语言程序,它比较 2 个字符串,但我需要比较 10 个字符串。我如何实现这一目标?我的字符串比较程序在一个过程中。
; segments
data segment
data1 db 64 ,? ,64 dup(?)
data2 db 64 ,? ,64 dup(?)
data3 db 64 ,? ,64 dup(?)
data4 db 64 ,? ,64 dup(?)
data5 db 64 ,? ,64 dup(?)
data6 db 64 ,? ,64 dup(?)
data7 db 64 ,? ,64 dup(?)
data8 db 64 ,? ,64 dup(?)
data9 db 64 ,? ,64 dup(?)
data10 db 64 ,? ,64 dup(?)
ends
stack segment
dw 128 dup(0)
ends
code segment
main proc far
; set segment registers:
mov ax, data
mov ds, ax
move es,ax
call input
check data1,data2
; gets input from user
input proc
lea dx, enter
mov ah,09h
int 21h
call newline
mov ah, 0ah
lea dx,data1
int 21h
call newline
mov ah, 0ah
lea dx,data2
int 21h
call newline
mov ah, 0ah
lea dx,data3
int 21h
call newline
mov ah, 0ah
lea dx,data4
int 21h
call newline
mov ah, 0ah
lea dx,data5
int 21h
call newline
mov ah, 0ah
lea dx,data6
int 21h
call newline
mov ah, 0ah
lea dx,data7
int 21h
call newline
mov ah, 0ah
lea dx,data8
int 21h
call newline
mov ah, 0ah
lea dx,data9
int 21h
call newline
mov ah, 0ah
lea dx,data10
int 21h
call newline
ret
input endp
newline proc
mov ah,02h
mov dl,0ah
int 21h
mov dl,0dh
int 21h
ret
newline endp
check macro a,b
local next,finish
mov cx, 64 ; buffer size to save string
mov si,a
mov di,b
repe cmpsw ;comparing two strings with each other
ja next
jmp finish
next :
;swapping strings
mov cx, 64
mov si,a
lea di,change
rep movsb
mov cx,64
mov si,b
mov di,a
rep movsb
mov cx,64
lea si,change
mov di,b
rep movsw
finish:
endm
ends
end main