News:

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

Need help with a make.bat file

Started by pianodervish, June 15, 2010, 07:13:05 AM

Previous topic - Next topic

pianodervish

Hello!
Im having problems making a custom .bat file that will compile (assemble+link) a given file. Currently the file I have is TemplateAdvanced.asm that has the following code:
        .586
   .MODEL FLAT,STDCALL
   .STACK 4096
   option casemap :none  ; case sensitive
.data
.code
END

My make.bat file is the following:

@echo off
PATH C:\masm32\bin
ml /c /Cx /Zd /Zf /Zi /Fl /coff TemplateAdvanced.asm
@echo on
link /subsystem:windows TemplateAdvanced.obj /out:TemplateAdvanced.exe /debug

No matter what I do I get the following error message : Fatal Error LNK1120 unresolved external symbol _mainCRTStartup. I have no idea what is wrong. Any ideas? Thanx :)!

jj2007

This will work, but beware, there are better ways to do it. Just check the examples in the Masm32 package.

.586
   .MODEL FLAT,STDCALL
   .STACK 4096
   option casemap :none  ; case sensitive
.data
.code
start:
ret
end start

hutch--

dervish,

JJ is right, with MASM you must tell the assembler where the code starts and where the code finishes. Its a "label:" with whatever unique name you like with a matching "end label". Inbetween the "start" and the "end start" is where you write your code.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Rockoon

To be quite specific, code doesnt have to be between the entry point label and the 'end' directive, but it must be before that 'end' directive.

The end directive is terminal, telling the assembler "here is the end of the source file!"

The end directives parameter describes the entry point of the program. Defining an entry point is only important in .EXE files (.COM files always enter at the beginning of the code segment) .. the entry point is telling the linker to encode the starting point into the executable, so the operating system knows where in your executable to jump to in order to kick off youir program after its loaded.

Other assemblers do it differently, and most compilers use a default label (such as 'main' or 'winmain') instead of having a directive define the entry point.
When C++ compilers can be coerced to emit rcl and rcr, I *might* consider using one.

jj2007

Quote from: Rockoon on June 15, 2010, 11:32:57 AM
To be quite specific, code doesnt have to be between the entry point label and the 'end' directive, but it must be before that 'end' directive.

Here is a perfectly valid example with code before the entry point, mixed with two read-only strings:

include \masm32\include\masm32rt.inc

.code

MyTest proc arg1:DWORD, arg2:DWORD
  MsgBox 0, arg1, arg2, MB_OK
  ret
MyTest endp

AppName db "Masm32 is great!", 0
Hello db "A message:", 0

pianodervish_proggiestart:
invoke MyTest, offset AppName, addr Hello
invoke ExitProcess, 0

end pianodervish_proggiestart

pianodervish