News:

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

fatal problem...ask for help !

Started by chiwing, June 03, 2005, 06:41:37 PM

Previous topic - Next topic

chiwing

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>>>

MichaelW

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.
eschew obfuscation

Mark Jones

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

"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

MichaelW

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.
eschew obfuscation

GregL


hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

chiwing

Thanks for above replyer's help , I will follow your instruction.

BytePtr

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.

chiwing

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

chiwing

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?

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

GregL

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. :)


Mark Jones

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.

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
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

chiwing

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..