I want to program in Masm with multiple ASM-Files as I
did it in Tasm before.

All works fine only if i don't use something like that in a Sub-asm-file

invoke ReadFile, hFile, addr input, 4, addr bytesread, 0

-->compiler gives errors

undefined symbol
Invoke argument type mismatch

for: hFile,input and bytesread

This compiles strangly without errors

mov eax, hFile
mov ecx, offset input
mov edx, offset bytesread
invoke ReadFile, eax, ecx, 4, edx, 0

plz help

I have attached sample code
Posted on 2002-04-15 11:08:53 by CRYO
The problem is the sequencial nature of MASM. The hFile is defined *AFTER* the include. So all the contents of the include file is processed *BEFORE* you even define hFile in the .data segment..

However, im surpriesed manually calling as you showed will still work :o

Here is the Fix..
Posted on 2002-04-15 11:15:39 by NaN
many thanks Nan:alright:

This forum is really great!

Posted on 2002-04-15 12:01:04 by CRYO
NaN, here's a theory as to why the manual approach works and
invoke "directly" doesn't...

mov eax, hFile
mov ecx, offset input
mov edx, offset bytesread

It's quite clear for the assembler which opcodes to generate from
this. Addresses of course can't be computed in the first pass when
declared below the code, which means a 2nd pass will have to be
done... and also means the assembler can do size checking there
(ie, see if hFile is a word or byte or whatever-not-dword sized type).

With invoke, masm cannot know what opcode size to output. The opcode
to push a variable is FF35xxxxxxxx where the x's is the address of
the variable for native (on win32, dword size) data. Word data requires
a 66h prefix byte. Handling this ambiguity would require an annoying
amount of code and reassembling, and the masm developers decided it was
not worth it. You can probably set up a forward proto or whatever anyway.
Posted on 2002-04-17 07:55:28 by f0dder

You will have to get used to the idea that MASM and TASM hang together differently. With "invoke" you need prototypes that are declared before the invoke call, thats how MASM is designed. You can do it in TASM with PROCDESC statements as prototypes if you wanted to kep the two code types similar but there will always be differences here and there.


Posted on 2002-04-17 08:37:42 by hutch--