The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: theunknownguy on March 22, 2010, 11:49:21 PM

Title: Duplicate Arguments names
Post by: theunknownguy on March 22, 2010, 11:49:21 PM
I have a question, i have searched arround the forum and only found a solution by bongdan (sorry if i put bad the nickname).

I got many procedures that in their respective "contexts" use the same arguments:


Test1 Proc Hey:Dword, Lol:Dword
Test2 Proc Hey:Dword, Lol:Dword


Now i use more than 2 procs, and i ereally need to put the same names (the ones i put are examples only), bongdan solution (again sorry if i put bad the nickname) is:

Test1 Proc @@Hey:Dword, @@Lol:Dword

But this seems not to work after place it for more than 3 procedures...

Somebody have a solution, i am not used to use the same arguments names, but its public source code project and in order people understand i must really name them the same...

JWASM compiler by the way...
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:03:13 AM
Are you sure MASM even cares? I've never had a problem with it doing this.
-Clive

Microsoft (R) Macro Assembler Version 6.11d     03/22/10 19:01:00
foo.asm      Page 1 - 1


.386

.MODEL FLAT,C

00000000 .CODE

00000000 start:

00000000 test1 proc Param1:DWORD, Param2:PTR BYTE

00000000 test1 endp

00000000 test2 proc Param1:DWORD, Param2:PTR BYTE

00000000 test2 endp

00000000 test3 proc Param1:DWORD, Param2:PTR BYTE

00000000 test3 endp

00000000 test4 proc Param1:DWORD, Param2:PTR BYTE

00000000 test4 endp

end start

Microsoft (R) Macro Assembler Version 6.11d     03/22/10 19:01:00
foo.asm      Symbols 2 - 1




Segments and Groups:

                N a m e                 Size     Length   Align   Combine Class

FLAT . . . . . . . . . . . . . . GROUP
_DATA  . . . . . . . . . . . . . 32 Bit 00000000 DWord   Public  'DATA'
_TEXT  . . . . . . . . . . . . . 32 Bit 00000000 DWord   Public  'CODE'


Procedures,  parameters and locals:

                N a m e                 Type     Value    Attr

test1  . . . . . . . . . . . . . P Near 00000000 _TEXT Length= 00000000 Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test2  . . . . . . . . . . . . . P Near 00000000 _TEXT Length= 00000000 Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test3  . . . . . . . . . . . . . P Near 00000000 _TEXT Length= 00000000 Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test4  . . . . . . . . . . . . . P Near 00000000 _TEXT Length= 00000000 Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C


Symbols:

                N a m e                 Type     Value    Attr

@CodeSize  . . . . . . . . . . . Number 00000000h
@DataSize  . . . . . . . . . . . Number 00000000h
@Interface . . . . . . . . . . . Number 00000001h
@Model . . . . . . . . . . . . . Number 00000007h
@code  . . . . . . . . . . . . . Text    _TEXT
@data  . . . . . . . . . . . . . Text    FLAT
@fardata?  . . . . . . . . . . . Text    FLAT
@fardata . . . . . . . . . . . . Text    FLAT
@stack . . . . . . . . . . . . . Text    FLAT
start  . . . . . . . . . . . . . L Near 00000000 _TEXT

   0 Warnings
   0 Errors
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:04:37 AM
JWASM using...

And cant do this... what i am missing??...

My procedures are in multiple files by the way (i dont think this matters...)



V_CItem_SetBonusForPendants Proc Uses Edx Ecx ItemType:DWord, ItemIndex:DWord

V_CItem_SetOption2 Proc Uses Edx Ecx ItemType:DWord, ItemIndex:DWord, Option2:DWord
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:07:45 AM
Are you closing the procedure with ENDP, the parameters only have local context between PROC/ENDP
-Clive
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:08:36 AM
Quote from: clive on March 23, 2010, 12:07:45 AM
Are you closing the procedure with ENDP, the parameters only have local context between PROC/ENDP
-Clive

It was an example Clive they have Endp...

V_CItem_SetOption2 Proc Uses Edx Ecx ItemType:DWord, ItemIndex:DWord, Option2:DWord
Local pThisItem:DWord
Local MyStruct:DWord
;----------------------------------------------------
;Save structs into locals and assume.
;----------------------------------------------------
Assume Edx: Ptr ItemStruct
Assume Ecx:Ptr ITEM_ATTRIBUTE_STRUCT ;From Item.txt
   Mov [Edx].Item_Option2, 1
   Movsx Eax, [Edx].Item_SpecialNum
   Mov [[Edx].Item_Special + Eax], 84 ;Special[SpecialNum] (array)  (SKILL = Unknown)
ret
V_CItem_SetOption2 EndP


The example is uncomplete i didnt wanted to paste a long procedure... but i do use the arguments...
Title: Re: Duplicate Arguments names
Post by: jj2007 on March 23, 2010, 12:12:04 AM
As Clive wrote already, names are local to procedures, and you can reuse them as often as you want. That applies to JWasm, too. Maybe you should post a complete example where it doesn't work...
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:13:36 AM
Quote from: jj2007 on March 23, 2010, 12:12:04 AM
As Clive wrote already, names are local to procedures, and you can reuse them as often as you want. That applies to JWasm, too. Maybe you should post a complete example where it doesn't work...

It works in all the places, if i just change the Arguments names, i can compile with no problems...

I dont find any error on my procedures >.<.
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:14:39 AM
Across multiple files? Assembled separately? Hard to believe you'd be able to push scope/namespace that far.

If you are referring to procedures in different files (objects) PROTO might be a better choice if you want to define parameters to external subroutines.

-Clive
Title: Re: Duplicate Arguments names
Post by: qWord on March 23, 2010, 12:17:19 AM
maybe an name conflict with global vars
Title: Re: Duplicate Arguments names
Post by: hutch-- on March 23, 2010, 12:17:45 AM
There is a mistake in the last example by not closing the ASSUME directive.


Assume Edx: Ptr ItemStruct


You need to close this with,


ASSUME edx:nothing

Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:18:58 AM
Quote from: hutch-- on March 23, 2010, 12:17:45 AM
There is a mistake in the last example by not closing the ASSUME directive.


Assume Edx: Ptr ItemStruct


You need to close this with,


ASSUME edx:nothing



My mistake hutch now i will test, lol how i forget this...

By the way my project have this includes:

And yeah i define most of them by PROTO when its needed...

;########################### Inserted modules ############################

;///////////////////////////////////////
;Main Core Includes
;///////////////////////////////////////
include .\Valk-Core\V-UniUsage.asm ;all universal procedures, macros and others
include .\Valk-Core\V-Graphics.asm ;Graphics procedures
include .\Valk-Core\V-WndCore.asm ;Main window proc
include .\Valk-Core\V-IntConnectionsCFG.asm ;Interal Connections Config


;/////////////////////////////////////////////////////////////////////////////////
;
;                      Game Play Global Includes
;
;/////////////////////////////////////////////////////////////////////////////////


;----------------------------------------
;Class Includes
;----------------------------------------
include .\Valk-GamePlay\Valk-GameClass\Valk-CItem\V-ItemClass.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMap\V-MapClass.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMonster\V-Monsters\V-MonsterClass.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMagic\V-MagicClass.asm

;----------------------------------------
;Load Includes
;----------------------------------------
include .\Valk-GamePlay\Valk-GameClass\Valk-CItem\V-ItemLoad.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMap\V-MapLoad.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMonster\V-Monsters\V-MonsterLoad.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMonster\V-MobItemMng\V-MobItemMngLoad.asm
include .\Valk-GamePlay\Valk-ObjectFuctions\V-ObjInit.asm

;----------------------------------------
;Complements Includes
;----------------------------------------
include .\Valk-GamePlay\Valk-GameClass\Valk-CItem\V-ItemSetValues.asm

;----------------------------------------
;Actions Includes
;----------------------------------------
include .\Valk-GamePlay\Valk-GameClass\Valk-CItem\V-ItemActions.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMap\V-MapActions.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMonster\V-Monsters\V-MonsterActions.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CMagic\V-MagicActions.asm
include .\Valk-GamePlay\Valk-GameClass\Valk-CGates\V-GatesActions.asm



;/////////////////////////////////////////////////////////////////////////////////
;
;                      Connections Global Includes
;
;/////////////////////////////////////////////////////////////////////////////////



;---------------------------------------
;Internal Clients Includes
;---------------------------------------
include .\Valk-InternConnections\Valk-RankingServer\V-RankingServer.asm
include .\Valk-InternConnections\Valk-ConnectServer\V-ConnectServer.asm
include .\Valk-InternConnections\Valk-JoinServer\V-Joinserver.asm
include .\Valk-InternConnections\Valk-DataServer\V-DataServer.asm
include .\Valk-InternConnections\Valk-EventChip\V-EventChip.asm
include .\Valk-InternConnections\Valk-ExDB\V-ExDB.asm

;---------------------------------------
;Internal Connections Includes
;---------------------------------------
include .\Valk-InternConnections\Valk-InternalSockBase\V-InternalStructs.asm
include .\Valk-InternConnections\Valk-InternalSockBase\V-IntSockBase.asm
include .\Valk-InternConnections\Valk-InternalSockBase\V-IntConnect.asm



;#########################################################################
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:23:29 AM
Again with MASM, as that's what I use. So what exactly is the error message you get?

-Clive

Microsoft (R) Macro Assembler Version 6.11d     03/22/10 19:20:17
foo.asm      Page 1 - 1


.386

.MODEL FLAT,C

00000000 .CODE

test5 proto Param1:DWORD, Param2:PTR BYTE


00000000 start:

00000000  68 000004D2 push 1234
00000005  68 0000162E push 5678
0000000A  E8 00000000 E call test5
0000000F  83 C4 08 add esp,8
00000012  C3 ret

00000013 test1 proc Param1:DWORD, Param2:PTR BYTE

00000016  8B 45 08 mov eax,Param1
00000019  8B 4D 0C mov ecx,Param2
ret

0000001E test1 endp


0000001E test2 proc Param1:DWORD, Param2:PTR BYTE

00000021  8B 45 08 mov eax,Param1
00000024  8B 4D 0C mov ecx,Param2
ret

00000029 test2 endp


00000029 test3 proc Param1:DWORD, Param2:PTR BYTE

0000002C  8B 45 08 mov eax,Param1
0000002F  8B 4D 0C mov ecx,Param2
ret

00000034 test3 endp


00000034 test4 proc Param1:DWORD, Param2:PTR BYTE
local Local1:DWORD, Local2:PTR TBYTE

0000003A  8B 45 08 mov eax,Param1
0000003D  8B 4D 0C mov ecx,Param2
ret

00000042 test4 endp

end start

Microsoft (R) Macro Assembler Version 6.11d     03/22/10 19:20:17
foo.asm      Symbols 2 - 1




Segments and Groups:

                N a m e                 Size     Length   Align   Combine Class

FLAT . . . . . . . . . . . . . . GROUP
_DATA  . . . . . . . . . . . . . 32 Bit 00000000 DWord   Public  'DATA'
_TEXT  . . . . . . . . . . . . . 32 Bit 00000042 DWord   Public  'CODE'


Procedures,  parameters and locals:

                N a m e                 Type     Value    Attr

test1  . . . . . . . . . . . . . P Near 00000013 _TEXT Length= 0000000B Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test2  . . . . . . . . . . . . . P Near 0000001E _TEXT Length= 0000000B Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test3  . . . . . . . . . . . . . P Near 00000029 _TEXT Length= 0000000B Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
test4  . . . . . . . . . . . . . P Near 00000034 _TEXT Length= 0000000E Public C
  Param1 . . . . . . . . . . . . DWord bp + 00000008
  Param2 . . . . . . . . . . . . DWord bp + 0000000C
  Local1 . . . . . . . . . . . . DWord bp - 00000004
  Local2 . . . . . . . . . . . . DWord bp - 00000008
test5  . . . . . . . . . . . . . P Near 00000000 FLAT Length= 00000000 External C


Symbols:

                N a m e                 Type     Value    Attr

@CodeSize  . . . . . . . . . . . Number 00000000h
@DataSize  . . . . . . . . . . . Number 00000000h
@Interface . . . . . . . . . . . Number 00000001h
@Model . . . . . . . . . . . . . Number 00000007h
@code  . . . . . . . . . . . . . Text    _TEXT
@data  . . . . . . . . . . . . . Text    FLAT
@fardata?  . . . . . . . . . . . Text    FLAT
@fardata . . . . . . . . . . . . Text    FLAT
@stack . . . . . . . . . . . . . Text    FLAT
start  . . . . . . . . . . . . . L Near 00000000 _TEXT

   0 Warnings
   0 Errors
Title: Re: Duplicate Arguments names
Post by: qWord on March 23, 2010, 12:24:49 AM
make an text search in all included files for the procedure parameters causing conflict - maybe you will find a global variable, constant or macro with this name.
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:26:54 AM
Generating a listing file for an example that works / does not work, might also be instructive.
-Clive
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:27:41 AM
Quote from: qWord on March 23, 2010, 12:24:49 AM
make an text search in all included files for the procedure parameters causing conflict - maybe you will find a global variable, constant or macro with this name.

I do define alot of ItemType into structs, but i have compiled before with that names under structs and no problem.


Clive here is one of the bugs, i gotta say that they reduce alot when closing the "ASSUME".

V-ItemActions.asm(82) : Error A2062: Symbol already defined: NewOption
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:36:21 AM
Ok after closing all "ASSUMES" that i forget still the bugs here the list:

V-ItemSetValues.asm(326) : Error A2160: Conflicting parameter definition:
V-ItemSetValues.asm(326): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(417) : Error A2160: Conflicting parameter definition:
V-ItemSetValues.asm(417): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(569) : Error A2062: Symbol already defined: ItemType
V-ItemSetValues.asm(569): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(569) : Error A2062: Symbol already defined: ItemIndex
V-ItemSetValues.asm(569): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(675) : Error A2062: Symbol already defined: ItemType
V-ItemSetValues.asm(675): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(675) : Error A2062: Symbol already defined: ItemIndex
V-ItemSetValues.asm(675): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(755) : Error A2160: Conflicting parameter definition:
V-ItemSetValues.asm(755): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(781) : Error A2062: Symbol already defined: ItemType
V-ItemSetValues.asm(781): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(781) : Error A2062: Symbol already defined: ItemIndex
V-ItemSetValues.asm(781): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(812) : Error A2062: Symbol already defined: ItemType
V-ItemSetValues.asm(812): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemSetValues.asm(812) : Error A2062: Symbol already defined: ItemIndex
V-ItemSetValues.asm(812): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code
V-ItemActions.asm(82) : Error A2062: Symbol already defined: ItemType


Ill do what qWord say and search in other files if meaby i declare a global variable called ItemType...
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:40:27 AM
With MASM the -Fl option (F L) generates a listing file, at the end you get the procedures parameters/locals, and global symbols. This might provide some hints to the namespace and scope of certain variables.

If the simple example I posted assembles on MASM/JWASM, it could be you have closure issue like Hutch's examples where the scope of some variable exceeds the procedure limits , of Qword's variables with global scope.

-Clive
Title: Re: Duplicate Arguments names
Post by: clive on March 23, 2010, 12:43:25 AM
V-ItemSetValues.asm(326) : Error A2160: Conflicting parameter definition:
V-ItemSetValues.asm(326): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code

What is going on at these lines, do you have some kind of circular inclusion going on? Look at what's going on in procedures immediately before the erroring ones.

-Clive
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 12:45:44 AM
Quote from: clive on March 23, 2010, 12:43:25 AM
V-ItemSetValues.asm(326) : Error A2160: Conflicting parameter definition:
V-ItemSetValues.asm(326): Included by
  V-RestInc.inc(62): Included by
   V-GameServer.asm(31): Main line code

What is going on at these lines, do you have some kind of circular inclusion going on? Look at what's going on in procedures immediately before the erroring ones.

-Clive

I remove the PROTO from the file i used this procedure, since they dont need PROTO (the file that calls them is below) and the Conflict parameter error is gone...

I make the list file with -FL options and searching i found only a structure defined before with the names:

00000000                   ITEM_ATTRIBUTE_STRUCT struct
00000000                    ItemType Byte ?
00000001                    ItemIndex Byte ?


Does this affect?...

Also come to my mind that ITEMTYPE (caps) its used by some windows include i think...

But its ITEMTYPE and not ItemType has i use... can be this a problem?
   
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 01:47:48 AM
Fixed, the problem was in a procedure the last 2 lines i used example:

mov ItemIndex, eax
mov ItemType, edx


Without declaring ItemIndex and ItemType in the procedure arguments.

Its hard to detect bugs when your coding lines are more than 8.000 and keep growing >.<.

Thanks to all for the fast response, especially to u clive, you really good help ^^
Title: Re: Duplicate Arguments names
Post by: qWord on March 23, 2010, 02:27:09 AM
Quote from: theunknownguy on March 23, 2010, 01:47:48 AMIts hard to detect bugs when your coding lines are more than 8.000 and keep growing
splitting your program in modules may helps to keep track of it.
Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 02:30:30 AM
Quote from: qWord on March 23, 2010, 02:27:09 AM
Quote from: theunknownguy on March 23, 2010, 01:47:48 AMIts hard to detect bugs when your coding lines are more than 8.000 and keep growing
splitting your program in modules may helps to keep track of it.

What you mean with modules, i mean i have alot of files, but most of my errors compiler never show me the "good line".

Its something odd that happens in allmost all big projects i do, sometimes compiler (MASM & JWASM) show me wrong lines number... >.<
Title: Re: Duplicate Arguments names
Post by: qWord on March 23, 2010, 03:17:30 AM
a module means here to compile asm-files separately to object files (*.obj). This modules then combined to  one program by the linker. An short example:
module1.asm
include masm32rt.inc
externdef mySharedDword:DWORD ; this variable is initialized in an other module
ExternFunction PROTO

.code
start:
invoke ExternFunction

print "mySharedDword = "
mov eax,mySharedDword
print str$(eax),10,13
inkey
exit
end start

module2.asm
include masm32rt.inc

externdef mySharedDword:DWORD ; this variable is declared as extern, but initialized in this module
ExternFunction PROTO

.data
mySharedDword dd 1234
.code
ExternFunction proc
print "extern function called",10,13
ret
ExternFunction endp
end


assemble: each module separately
link: link.exe /SUBSYSTEM:CONSOLE /OUT:"Main.exe" "module1.obj" "module2.obj"

One advantage is that variables are only visible in current module (as long as you don't make them visible to other modules through the use of extern/externdef).
The normal way is to create one include file with definition of struct's, (global) variables and function prototypes. This file is then used in all modules.

Title: Re: Duplicate Arguments names
Post by: theunknownguy on March 23, 2010, 03:28:12 AM
Thanks qWord ill give it a try  :cheekygreen:
Title: Re: Duplicate Arguments names
Post by: jj2007 on March 23, 2010, 07:54:36 AM
Quote from: qWord on March 23, 2010, 02:27:09 AM
Quote from: theunknownguy on March 23, 2010, 01:47:48 AMIts hard to detect bugs when your coding lines are more than 8.000 and keep growing
splitting your program in modules may helps to keep track of it.

You would need an IDE that searches redefined or undefined symbols across all your files. IMHO it is easier to chase a bug if you keep it all in one fat file. Above 100,000 lines that might change, of course...