冲突的参数定义

时间:2016-11-26 06:54:36

标签: assembly masm masm32 irvine32

在这个程序中,我试图将源字符串附加到目标字符串的末尾。但是当我试图运行该程序时,它在这一行中给了我错误。

strLength PROTO,
    stringLength:PTR BYTE

这就是它所说的: 错误A2111冲突的参数定义

我一直在尝试修复代码,但仍然不知道出了什么问题。这就是整个代码:

INCLUDE Irvine32.inc

strCat PROTO,
    sourceFrom:PTR BYTE,
    targetTo:PTR BYTE

strLength PROTO,
    stringLength:PTR BYTE

.data
Source1 BYTE "Testtttttt", 0h
NoSpace1 BYTE "This string should cause an error. for the user if you try to concatenate Source1 to it. ", 0h

.code
main PROC
INVOKE strCat, ADDR Source1, ADDR NoSpace1
exit
main ENDP

strCat PROC USES ESI EDI ECX EAX,
    sourceFrom:PTR BYTE,
    targetTo:PTR BYTE
;--------------------------------------------------------------------------
;appends a source string to the end of a destination string
;receives: pointer to source, pointer to target
;return: nothing
;--------------------------------------------------------------------------
INVOKE strLength, targetTo          ;EBX = length
mov ECX, EBX                            ;mov the stringLength to ECX

end:                                    ;look for end of line
mov EAX, BYTE PTR[sourceFrom]           ;sourcefrom to EAX
cmp EAX, ' '                            ;compare with space
inc EAX
jne end
next:
inc EAX
cmp EAX, ' '                            ;compare with space
jne end                                 ;if not space go to the next character

INVOKE strLength, sourceFrom        ;EBX = length
mov ECX, EBX                            ;mov the stringLength to ECX
mov ESI, sourceFrom                     ;ESI points to source
mov EDI, targetTo                       ;EDI points to target
cld                                     ;direction forward
rep movsb

ret
strCat ENDP

strLength PROC USES EDI,
    stringTo:PTR BYTE
;--------------------------------------------------------------------------
;find the length of the string
;receives: pointer to string
;return: length of string in EAX
;--------------------------------------------------------------------------
mov EDI, stringTo
mov EBX, 0                              ;set EAX to 0

loop1:
cmp BYTE PTR [EDI], 0                   ;check if it is the end of string
je loop2                                ;if it is the end go to loop2
inc edi                                 ;if not, next characters
inc EBX
jmp loop1

loop2:
ret
strLength ENDP

END main

0 个答案:

没有答案