News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Conflicting Parameter Definition (Array Value Swap Program)

Started by Syre Lancaster, September 30, 2013, 04:25:23 AM

Previous topic - Next topic

Syre Lancaster

Hey guys,
I've been working on this practice problem for my class that asks you to create an array of random ints then swap the values in each pair. I've followed the professor's instructions precisely, but I still error when it comes to the DumpMemory Procedure.

Error   1   error A2111: conflicting parameter definition   C:\Irvine\Examples\Project_sample\Problem 18.asm   61   1   ASM_Project
Error   2   error A2008: syntax error : dword   C:\Irvine\Examples\Project_sample\Problem 18.asm   63   1   ASM_Project
Error   3   error A2006: undefined symbol : units   C:\Irvine\Examples\Project_sample\Problem 18.asm   68   1   ASM_Project
Error   4   error A2006: undefined symbol : unitType   C:\Irvine\Examples\Project_sample\Problem 18.asm   69   1   ASM_Project
Error   5   error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\Problem 18.obj" /I "c:\Irvine" /W3 /errorReport:prompt  /Ta"Problem 18.asm"" exited with code 1.   C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\masm.targets   49   5   ASM_Project


I've been over the code several times comparing it directly with the instructional video and I can't seem to find what is causing the trouble. If anyone has any insight into this, it would be greatly appreciated.


INCLUDE Irvine32.inc

Swap PROTO, ;Prototypes
pValX:PTR DWORD,
pValY:PTR DWORD

DumpMemory PROTO,
address:DWORD,
units:DWORD,
unitType:DWORD

.data
array DWORD 16 DUP(?)
msgBefore BYTE "Array before the swap:",0
msgAfter BYTE "Array after the swap:",0

.code
main PROC
mov esi,OFFSET array
mov ecx,LENGTHOF array

L1: call Random32
mov [esi],eax
add esi,TYPE array
loop L1

INVOKE DumpMemory,OFFSET array,LENGTHOF array,TYPE array
call Crlf

mov esi,OFFSET array
mov ecx,LENGTHOF array ;Number of elements in the array
shr ecx,1 ;Divide counter by 2(pair of elements)

L2: INVOKE Swap,esi,ADDR[esi+4] ;Swap the pair
add esi,TYPE array * 2 ;Next Pair
loop L2

exit
main ENDP

;------------------------------
Swap PROC USES eax esi edi,
pValX:PTR DWORD, ;First Pointer
pValY:PTR DWORD ;Second Pointer
;Exchange values of two 32 bit ints
;Receives:nothing
;Returns:nothing
;------------------------------

mov esi,pValX ;get pointers
mov edi,pValY
mov eax,[esi] ;get first int
xchg eax,[edi] ;exchange with second
mov [esi],eax ;replace with first int
ret
Swap ENDP



;------------------------------
DumpMemory PROC USES esi ebx ecx,
;------------------------------
address:DWORD, ;starting address
units:DWORD, ;number of units
unitType:DWORD ;unit size

mov esi, address
mov ecx, units
mov ebx, unitType
call DumpMem
ret
DumpMemory ENDP
END main








GoneFishing

Try to prototype your function in this way:

DumpMemory PROTO :DWORD, :DWORD, :DWORD

Let me know if it helped or not

Another thought is to rename parameter "address" .

dedndave

i think you are ok except for a couple commas
both of your PROC's have the same error
;------------------------------
DumpMemory PROC USES esi ebx ecx,    ;<------- remove this comma
;------------------------------
address:DWORD, ;starting address
units:DWORD, ;number of units
unitType:DWORD ;unit size


normally, it might look like this...
DumpMemory PROC USES esi ebx ecx address:DWORD,units:DWORD,unitType:DWORD

however, vertograd has a point:
try to use names for PROC's, arguments, variables, and other labels that are more unique   :P

address
array
units
Swap
and so on....
these are "everyday" names that should be avoided

you almost had a problem with "DumpMemory" - lol
Irvine32 has one named "DumpMem"

otherwise, nice job for a beginner   :t

jj2007

As Dave wrote, the comma is illegal.

MySwap PROTO :PTR DWORD, :PTR DWORD
DumpMemory PROTO address:DWORD, units:DWORD, unitType:DWORD

Replace Swap with MySwap or similar, it seems the assembler doesn't like "Swap".

Syre Lancaster

Aye I replaced some of the names of the labels as you guys said and moved the defintions into the PROC line for the procedures and the code assembled sucessfully:


Now all I have to figure out is to display the before/after *head scratch*

Updated code:

INCLUDE Irvine32.inc

Swap PROTO, ;Prototypes
pValX:PTR DWORD,
pValY:PTR DWORD

DumpMemory PROTO,
sAddress:DWORD,
nUnits:DWORD,
unitType:DWORD

.data
array DWORD 16 DUP(?)
msgBefore BYTE "Array before the swap:",0
msgAfter BYTE "Array after the swap:",0

.code
main PROC
mov esi,OFFSET array
mov ecx,LENGTHOF array

L1: call Random32
mov [esi],eax
add esi,TYPE array
loop L1

INVOKE DumpMemory,OFFSET array,LENGTHOF array,TYPE array
call Crlf

mov esi,OFFSET array
mov ecx,LENGTHOF array ;Number of elements in the array
shr ecx,1 ;Divide counter by 2(pair of elements)

L2: INVOKE Swap,esi,ADDR[esi+4] ;Swap the pair
add esi,TYPE array * 2 ;Next Pair
loop L2
call WaitMsg
exit
main ENDP

;------------------------------
Swap PROC USES eax esi edi pValX:PTR DWORD,pValY:PTR DWORD
;Exchange values of two 32 bit ints
;Receives:nothing
;Returns:nothing
;------------------------------

mov esi,pValX ;get pointers
mov edi,pValY
mov eax,[esi] ;get first int
xchg eax,[edi] ;exchange with second
mov [esi],eax ;replace with first int
ret
Swap ENDP



;------------------------------
DumpMemory PROC USES esi ebx ecx sAddress:DWORD,nUnits:DWORD,unitType:DWORD
;------------------------------

mov esi, sAddress
mov ecx, nUnits
mov ebx, unitType
call DumpMem
ret
DumpMemory ENDP
END main


Thanks for the advice, it really helped alot.  :biggrin:

Syre Lancaster

Figured it out.... added a jmp to the end of L2 and DumpMem'd my way to victory!


L2: INVOKE Swap,esi,ADDR[esi+4] ;Swap the pair
add esi,TYPE array * 2 ;Next Pair
loop L2
jmp L3
L3:
mov esi,OFFSET array
mov ecx,LENGTHOF array
mov ebx,TYPE array
call DumpMem


Thank you all, I shall be sure to mention you all after I use this program to TAKE OVER THE WORLD  :badgrin: