News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Duplicate Arguments names

Started by theunknownguy, March 22, 2010, 11:49:21 PM

Previous topic - Next topic

theunknownguy

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...

clive

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
It could be a random act of randomness. Those happen a lot as well.

theunknownguy

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

clive

Are you closing the procedure with ENDP, the parameters only have local context between PROC/ENDP
-Clive
It could be a random act of randomness. Those happen a lot as well.

theunknownguy

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...

jj2007

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...

theunknownguy

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 >.<.

clive

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
It could be a random act of randomness. Those happen a lot as well.

qWord

maybe an name conflict with global vars
FPU in a trice: SmplMath
It's that simple!

hutch--

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

Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

theunknownguy

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



;#########################################################################

clive

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
It could be a random act of randomness. Those happen a lot as well.

qWord

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.
FPU in a trice: SmplMath
It's that simple!

clive

Generating a listing file for an example that works / does not work, might also be instructive.
-Clive
It could be a random act of randomness. Those happen a lot as well.

theunknownguy

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