The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: chiwing on June 03, 2005, 06:41:37 PM

Title: fatal problem...ask for help !
Post by: chiwing on June 03, 2005, 06:41:37 PM
I come from HONG KONG. I am a beginner for win32 asm.
When I have installed masm32, I tried the software, I according a book which teach me the first program:
          .386
             .model flat, stdcall
             option casemap:none;
include    windows.inc
include    user32.inc
includelib   user.lib
include      kernel32.inc
includelib    kernel32.lib;     
          .data
          szcaption    db   'A MessageBox !',O
          szText       db   'Hello, World !',O;
          .code
          start:
          invoke messagebox, NULL, offset szTect, offset szcaption,MB_OK
          invoke exitProces. NULL
          end start
after typing this program in the masm editor, I click the standard button--"PROJECT"->"Assemble ASM File", but it told me that :"Assembling: E:\masm32\Program\message.asm
E:\masm32\Program\message.asm(4) : fatal error A1000: cannot open file : windows.inc"

I asked my friend, which have learnd assembly language before. He told me that I should do sth when I finish instaling masm32, but he forgot what the thing was.  :(

Could anybody tell me what should  I do , and teach me how to use masm32.
Furthermore, how can I create a .exe file>>>
Title: Re: fatal problem...ask for help !
Post by: MichaelW on June 03, 2005, 06:59:39 PM
Hi chiwing,

Welcome to the forum.

Try changing your includes to something like this:

include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib


To create an EXE for this code select Project -> Console Assemble & Link.

I see a few syntax errors in you code. MASM will report them as errors, and specify the line number, just as it specified line (4) for the A1000 error.
Title: Re: fatal problem...ask for help !
Post by: Mark Jones on June 03, 2005, 08:08:54 PM
Hello and welcome Chiwing. (^_^)

Quote from: chiwing on June 03, 2005, 06:41:37 PM
          invoke messagebox, NULL, offset szTect, offset szcaption,MB_OK
          invoke exitProces. NULL

There are six syntax errors here. This should be:

      invoke MessageBox, NULL, offset szText, offset szcaption,MB_OK
      invoke ExitProcess, NULL

Title: Re: fatal problem...ask for help !
Post by: MichaelW on June 03, 2005, 11:22:18 PM
chiwing,

Mark showed you six of the syntax errors, but there are at least two more.

And although it does not matter for this code, szText is the name of a MASM32 macro. If you had included these macros in the source your use of the name would have caused a conflict.

And you should be aware that under some conditions using OFFSET with INVOKE will not work. ADDR is usually a better choice.
Title: Re: fatal problem...ask for help !
Post by: GregL on June 03, 2005, 11:36:38 PM
chiwing,

    Hint: semicolons.

Title: Re: fatal problem...ask for help !
Post by: hutch-- on June 04, 2005, 02:13:07 AM
chiwing,

If you have installed MASM32 successfully, look through the example code as what you are doing in the example is very simple code. MASM32 required hard coded paths for reliability purposes and while you can build files in many different ways, if you are trying out other techniques, you should look for the documentation that supports it.
Title: Re: fatal problem...ask for help !
Post by: chiwing on June 05, 2005, 07:37:25 AM
Thanks for above replyer's help , I will follow your instruction.
Title: Re: fatal problem...ask for help !
Post by: BytePtr on June 05, 2005, 05:43:45 PM
Did u get this example from book? You must type program exactly like in book. Or if u used RadASM then it displays hints for you. If u type MessageBox then it will be correct if u type messageBox then this will be wrong.
There is also errors on code:
szcaption    db   'A MessageBox !',O
          szText       db   'Hello, World !',O;

Not O but zero: 0 U must type code correctly. Windows programming is not like in Pascal, type operators like u want but it's like C, where u must look every single char, otherwise your code never will be compiled.
Title: Re: fatal problem...ask for help !
Post by: chiwing on June 08, 2005, 07:00:44 AM
I am so sorry for my careless mistake, but I have follow all the instruction and I have correct all the mistakes that have mention . This time, I am sure my program is the same with my book, but it say the same thing :
" Assembling: E:\masm32\Program\message.asm
E:\masm32\Program\message.asm(4) : fatal error A1000: cannot open file : windows.inc"
Could anybody tell me what's wrong with line 4:"include  \masm32\include\windows.inc"
below is the entire program :
          .386
             .model flat, stdcall
             option casemap:none
include  \masm32\include\windows.inc
include    \masm32\include\user32.inc
includelib   \masm32\include\user.lib
include      \masm32\lib\kernel32.inc
includelib    \masm32\lib\kernel32.lib;   
          .data
          szcaption    db   'A MessageBox !',0
          szText       db   'Hello, World !',0;
          .code
          start:
          invoke MessageBox, NULL, offset szText, offset szcaption,MB_OK
          invoke ExitProcess, NULL
          end start
Title: Re: fatal problem...ask for help !
Post by: chiwing on June 08, 2005, 07:11:37 AM
I have see a website that told me that :
WE SHOULD add : "SET INCLUDE=X:\masm32\INCLUDE;%INCLUDE%
SET LIB=X:\masm32\LIB;%LIB%
SET PATH=X:\masm32\BIN;%PATH%
SET ML=/coff /link /SUBSYSTEM:WINDOWS" in the auotexec.bat.

and add :"/KC:\AUTOEXEC.BAT" in the cmd.exe's shortcut.

do i need to do these?
Title: Re: fatal problem...ask for help !
Post by: hutch-- on June 08, 2005, 08:02:12 AM
No.

It risks messing up any other environment settings if you have any other programming language set up as well.

The best idea if you have some reason to avoid hard coded paths is to learn the DOS SET command and set the required paths as environment variable and put it in a batch file.
Title: Re: fatal problem...ask for help !
Post by: GregL on June 08, 2005, 05:42:53 PM
chiwing,

Your program still has errors.

The .lib files are in the '\masm32\lib' directory and the .inc files are in the '\masm32\include' directory. You have a couple of those mixed up. Also, it's 'user32.lib' not 'user.lib'.

Check that there is actually a 'windows.inc' file in '\masm32\include'?

The semicolons at the end of the lines don't produce errors, but don't use them unless they are in front of a comment.

You really have to pay attention to details when programming in MASM32.

Keep at it. :)

Title: Re: fatal problem...ask for help !
Post by: Mark Jones on June 08, 2005, 07:39:15 PM
Quote from: chiwing on June 08, 2005, 07:00:44 AM
.386
.model flat, stdcall
option casemap:none
include     \masm32\include\windows.inc
include     \masm32\include\user32.inc
includelib  \masm32\include\user.lib
include     \masm32\lib\kernel32.inc
includelib  \masm32\lib\kernel32.lib;   

An equivalent to all this, if you have installed the MASM v8.2 SP2a, is:


include masm32rt.inc


Get the MASM32 service pack 2a from here (http://www.masmforum.com/simple/index.php?topic=1802.0).

The only system variable I have set for MASM32 is "path = %path%;c:\masm32\bin". Win XP. You should not need to set anything special.

If it still is not working properly, try reinstalling MASM32 to C:\MASM32 and making sure C:\MASM32\bin is in the path. Reboot. :)

よろしく、    Yoroshiku,     Regards,
 マルク      Maruku         Mark
Title: Re: fatal problem...ask for help !
Post by: chiwing on June 13, 2005, 11:10:22 AM
I am so sorry to reply so late. because of my busy work, I will follow your instruction later.
Besides, I am so sorry for my careless again :'(.
Really thanks for above people help..