I'm try to assemble the Icz TUT03 to an obj file., made by Privalov.

First thing I've learned is do not use any kernel32.lib other than the one that comes with MASM32. FASM has a problem with the new stuff added.

I don't know FASM very well at all. I looked in the early docs for enter.(top of page32)

Here is my error:


flat assembler version 1.40
tut03.asm [33] enter [2]:
enter
error: invalid macro arguments.

Here is the code area:


format MS COFF

include 'h:\fasm\include\macro\stdcall.inc'
include 'h:\fasm\include\macro\import.inc'
include 'h:\fasm\include\kernel.inc'
include 'h:\fasm\include\user.inc'
include 'h:\fasm\include\macro\macros.inc'

section '.data' data readable writeable

ClassName db "SimpleWinClass",0
AppName db "Our First Window",0

hInstance dd ?
CommandLine dd ?

section '.text' code readable executable

public _start
_start:
invoke GetModuleHandle, NULL
mov [hInstance],eax
invoke GetCommandLine
mov [CommandLine],eax
stdcall WinMain, [hInstance],NULL,[CommandLine],SW_SHOWDEFAULT
invoke ExitProcess, eax

proc WinMain, hInst,hPrevInst,CmdLine,CmdShow
wc WNDCLASSEX
msg MSG
hwnd dd ?
enter <---------line 33
mov [wc.cbSize],wc.size
mov [wc.style],CS_HREDRAW or CS_VREDRAW
mov [wc.lpfnWndProc],WndProc
mov [wc.cbClsExtra],NULL
mov [wc.cbWndExtra],NULL
push [hInstance]
pop [wc.hInstance]
.
.

If I remove that enter it also fails on the enter in wndproc.
I tried putting in the stack frame myself:


proc WinMain, hInst,hPrevInst,CmdLine,CmdShow
wc WNDCLASSEX
msg MSG
hwnd dd ?
[COLOR=red]push ebp
mov ebp,esp
sub ebp, 12
[/COLOR]

but then I get a diffrent error:

flat assembler version 1.40
tut03.asm [64]:
jz @f
error: invalid value.


Thanks.
Posted on 2002-09-23 08:54:54 by ThoughtCriminal
IIRC, the enter-instruction is overridden by a macro in stdcall.inc; (confirmed when looking in the file, at line 23 the macro starts).

BTW, enter and leave are slow instructions, the long way is faster... :)

shouldn't you be "sub esp, 12" instead of "sub ebp,12" ?
And aren't WNDCLASSEX and MSG structures, I'm no expert on the stack (I'm cutting my self on the smashed plates, ouch ;) ) but that migth be one problem since WNDCLASSEX is larger than a dword.
Posted on 2002-09-23 10:04:12 by scientica