The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: zhiling0229 on February 22, 2007, 10:07:45 AM

Title: Noob question on using MASM32
Post by: zhiling0229 on February 22, 2007, 10:07:45 AM
Hi,

I'm a noob and newbie in MASM32.  :(

I was writing a program:

.386
.MODEL flat,stdcall
.STACK 4096

ExitProcess PROTO, dwExitCode:DWORD
DumpRegs    PROTO

.code
main PROC
    mov eax,10000h
    add eax,40000h
    sub eax,20000h
    call DumpRegs
    INVOKE ExitProcess,0
   
main ENDP
END main

I run this in the MASM32 editor.
after that i went to Project>assemble ASM file. There was no error.
after that I went to Project>build all. Then a cmd prompt pop-up i just press enter. and this cmd sequence appear:

LINK : warning L4017: /SUBSYSTEM : unrecognized option name; option ignored
LINK : warning L4017: /OPT : unrecognized option name; option ignored
Run File [c:add.exe]:
List File [nul.map]:
Libraries [.lib]:
Definitions File [nul.def]:
C:\masm32\add.obj : fatal error L1101: invalid object module
Object file offset: 1 Record type: 4c
_
Link error
Press any key to continue . . .

What should i do? Thanks
Title: Re: Noob question on using MASM32
Post by: TNick on February 22, 2007, 11:04:08 AM
Hello!
By adding :

INCLUDELIB kernel32.lib


before .CODE the program is build without a problem, with this options (assuming that masm32 package is on drive D:)
d:\masm32\bin\ML.EXE /c /coff /Cp /nologo /I"d:\masm32\include" /I"D:\masm32\macros" TestFile.Asm
d:\masm32\bin\LINK.EXE /SUBSYSTEM:CONSOLE /RELEASE /VERSION:4.0 /LIBPATH:"d:\masm32\lib" /OUT:"TestFile.exe" TestFile.obj


BTW, do you have the latest version of masm32? the links for it are in the top right corner of this window!

Regards,
Nick
Title: Re: Noob question on using MASM32
Post by: ChrisLeslie on February 22, 2007, 11:19:45 AM
Welcome zhiling0229

There are several problems:
1) You should preferably add the assembler specific "option casemap :none" after the .model directive in order to be case sensitive.

2) Then your are missing a whole raft of mandatory include files to set up the various equates, structures and Win library functions:
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib
.. should be enough for you code that you have provided.

3) You do not need an ExitProcess PROTO because it will be in the include files above. And the proto does not require the argument name, ony the type.

4) DumpRegs procedure does not exit in your code. I assume that you have just not shown it here.

5) DumpRegs PROTO is not required because you are calling it directly, and there are no arguments.

6) The first three instructions are redundant. You may as well just have "mov eax,30000h".

Please study the examples provided in the masm32 package and try running then first.

Regards

Chris

Title: Re: Noob question on using MASM32
Post by: MaynardG_Krebs on February 22, 2007, 03:09:56 PM
I believe the DumpRegs procedure is defined in the Irvine32.lib and needs to be included in the path. Also in qeditor you probably want to go to Project > Console Assemble & Link
Title: Re: Noob question on using MASM32
Post by: MichaelW on February 23, 2007, 12:30:29 AM
If I place the posted code in a file named z.asm, in a directory that contains irvine32.lib, and assemble, link and run with this batch file:

\masm32\bin\ml /c /coff z.asm
pause
\masm32\bin\Link z.obj irvine32.lib \masm32\lib\kernel32.lib /SUBSYSTEM:CONSOLE
pause
z
pause

Then everything works as it should.

The only way I know of to do this from within QE would be to place the Irvine components in the current directory, create a makeit.bat (Create CONSOLE makeit.bat on the Script menu), customize it to something like the above, save it, and run it (Run Makeit.bat on the Project menu). If the assemble and link works without error, then you should be able to run the program (Run on the Project menu).