Re: Localized Parameter Directive?



"Betov" <betov@xxxxxxx> posted:
> Why don't you use a real Assembler, like FASM or RosAsm,
> instead?

<g> Trying to learn the MASM way of things. I didn't run into
any problems in VB or C or Pascal or javascript in the past
with such things. In fact there are 10 or 20 API declarations
in one particular program where hWnd is used quite a lot in
each of the declarations. Those other compilers tend to keep
the localized variables seperated from the global variables, if
there's a duplicate definition, ie they'll use one or the other,
without complaining during the compile process.

I'm seeing where in another project, there is no PROTO for
WndProc. So I can only guess that the compiler never requires
a PROTO "declaration". Is there a directive to turn on requiring
PROTO declarations?

I don't see a compiler directive in the 1991 and 1992 books.
Nothing in the CP/M Assembly Language from 1986 either.
I'll wait to see if anyone here can offer a suggestion or
comment.

Couple questions for Betov, how would you declare the
hWnd as being a parameter for the procedure, rather than
it referencing the global variable? And what do all those @
"at" symbols mean before the variable names? And what
about the ampersand symbols "&" in front, as in &NULL?
And what about all those, "D$variablename"? It looks alot
like... DS:variablename. But you'll have to explain what it
really means. I didn't think the segment stuff was used used
anymore with Win32.

--
Jim Carlock
Please post replies to newsgroup.

"Jim Carlock" <anonymous@xxxxxxxxxxxxx> écrivait:
> Using RadASM which in turn is using MASM to compile.
> C:\Masm32\Bin\ML.EXE /c /coff /Cp /nologo /I"C:\Masm32\Include"
> "TEST.asm"
>
> : error A2005: symbol redefinition : hWnd
>
> <the_code>
> .586
> .model flat,stdcall
> option casemap:NONE
> include Test.Inc
>
> WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
> WndProc proto :DWORD,:DWORD,:DWORD,:DWORD
>
> .data
> ClassName db "cTest",0
> AppName db "Test",0
>
> .data?
> hInstance HINSTANCE ?
> CommandLine LPSTR ?
> hWnd dd ?
>
> .code
>
> start:
> invoke GetModuleHandle, NULL
> mov hInstance,eax
> invoke GetCommandLine
> mov CommandLine,eax
> invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
> invoke ExitProcess,eax
>
> WinMain proc
> hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
> ret
> WinMain endp
>
> WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
>
> ret
> WndProc endp
>
> end start
> </the_code>
>
> casemap:NONE means it's all case sensitive, right?
>
> I'm must be misinterpreting what's going on.

Here is the translation of your
Source, in RosAsm syntax:

-----------------------------------------------

[ClassName: 'cTest', 0 AppName: 'Test', 0]

[hInstance: ? CommandLine: ? hWnd: ?]

Main:
call 'KERNEL32.GetModuleHandleA', &NULL
mov D$hInstance eax
call 'KERNEL32.GetCommandLineA'
mov D$CommandLine eax
call WinMain, D$hInstance, &NULL, D$CommandLine, &SW_SHOWDEFAULT
call 'KERNEL32.ExitProcess' eax

Proc WinMain:
Arguments @hInst, @hPrevInst, @CmdLine, @CmdShow

; ...
EndP

Proc WndProc:
Arguments @hWnd, @uMsg, @wParam, @lParam

; ...

mov eax D§hwnd ; Global Data 'hwnd'
mov ebx D@hwnd ; '@hwnd' Stack Local
EndP

----------------------------------------
Betov.

< http://rosasm.org >


.



Relevant Pages

  • Re: How to pass information, classes between forms in Windows Application mode [ FINALLY!]
    ... In a WinForms app generated by Visual Studio, ... A constructor in my "book" is the stuff that appears in public ... wouldn't compile as the appropriate constructor signature hasn't been ... declarations, it will compile. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: managing header files
    ... hundred by commenting out some external declarations, ... complaints) but the complaints about redundant declarations and the complaints ... to simplify the problem I decided to just try to compile ... approach of, in effect, finding one header file that all the .c files ...
    (comp.lang.c.moderated)
  • Re: Print error alerts
    ... I tried to compile the code, ... I Ran you command: vbc ... 'Imports' statements must precede any declarations. ...
    (microsoft.public.backoffice.smallbiz2000)
  • Re: Runtime macros
    ... as a macro rather than a function, and at runtime, the macro could examine ... declarations again (except for those cases where it wouldn't be possible ... ISTM, if there are cases where you as a programmer can know that the first type seen indicates it is always that type that that can only be an artifact of some implementation detail about your whole system, eg harware, or third party code etc. ... called, if this is the first time, check the types of its arguments, put the declarations into the body of its code, compile it and them setf the symbol-function so that next time it just proceeds. ...
    (comp.lang.lisp)
  • Re: Keeping STL Containers in scope in Win32 C++
    ... Okay -- as it stands, this shouldn't compile. ... have you checked that the initilization code in WinMain ...
    (microsoft.public.vc.stl)