News:

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

problem assembling very simple program

Started by eeoam, August 04, 2007, 10:20:24 AM

Previous topic - Next topic

eeoam

I've written the following program:

.486
.model flat, stdcall


.code
start:
  int 21h
end start


When I try to assemble it I get the following message:

E:\asm>ml hello.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: hello.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/z2
"hello.obj"
"hello.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
hello.obj : warning LNK4033: converting object format from OMF to COFF
LINK : fatal error LNK1181: cannot open input file "hello.exe"

What's going wrong? (I'm running on Windows XP Home edition if that's important).

E.

BogdanOntanu

Apparently you are trying to assemble an old DOS program in an new Windows like environment.

The directive:



.model flat, stdcall



suggest that you want a Windows environment as a target.

While this code below:



int 21h



does suggest that you want an DOS environment.

MASM32 is more appropriate for programming in Win32 than in DOS.

What do you want? DOS or Windows?
Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

Vortex

Hi eeoam,

If you wish to develop applications for DOS, you should get the 16-bit MS inker :

http://website.masm32.com/microsoft/Lnk563.exe

Quotehello.obj : warning LNK4033: converting object format from OMF to COFF

It's the 32-bit version of link.exe producing this warning message.

eeoam

Quote from: BogdanOntanu on August 04, 2007, 10:44:42 AM
Apparently you are trying to assemble an old DOS program in an new Windows like environment.

The directive:



.model flat, stdcall



suggest that you want a Windows environment as a target.

While this code below:



int 21h



does suggest that you want an DOS environment.

MASM32 is more appropriate for programming in Win32 than in DOS.

What do you want? DOS or Windows?

Well I'd like to do Windows, ultimately but I've got a book on DOS and I'd like to be able to run the programs in it.

hutch--

hi eeoam,

welcome on board. Unless you have reason to write 16 bit DOS code, don't waste your time learning an old architecture that is no longer used in modern code. If you have downloaded the masm32 project have a look at the tutorial\console examples to get you up and going. There is progressively more advanced example code and from the dfault editor there is a help file on the Help menu called "Asm Intro help" that has a lot of useful basic stuff for you.

masm32 can produce very simple console templates which are ideal to experiment with and the editor will create new ones for you. Go to the "Code" menu and select "Bare Console Template" to get a very simple working template to test code with.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

eeoam

Quote from: hutch-- on August 04, 2007, 12:30:32 PM
hi eeoam,

welcome on board. Unless you have reason to write 16 bit DOS code, don't waste your time learning an old architecture that is no longer used in modern code. If you have downloaded the masm32 project have a look at the tutorial\console examples to get you up and going. There is progressively more advanced example code and from the dfault editor there is a help file on the Help menu called "Asm Intro help" that has a lot of useful basic stuff for you.

masm32 can produce very simple console templates which are ideal to experiment with and the editor will create new ones for you. Go to the "Code" menu and select "Bare Console Template" to get a very simple working template to test code with.

Thanks for the welcome! I started the editor and created a bare console template but when i I clicked Project|Console Assemble and Link nothing happened. So I went to the command line and got this message:

E:\asm>ml asm0.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: asm0.asm
asm0.asm(2) : fatal error A1000: cannot open file : \masm32\include\masm32rt.inc

but the c:\masm32\include directory is present and the masm32rt.inc file is there. So why can't the assembler find it?

E.

mnemonic

You should keep your sourcecode files on the same partition as the \masm32\ folder is located.
That should fix your problem.

HTH
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

Vortex

E:\asm>ml asm0.asm

Are you sure that you installed the masm32 package to the root of the partition?

It should look like C:\masm32 or D:\masm32 etc.

eeoam

Quote from: Vortex on August 04, 2007, 01:43:11 PM
E:\asm>ml asm0.asm

Are you sure that you installed the masm32 package to the root of the partition?

It should look like C:\masm32 or D:\masm32 etc.

Alright, I've moved my asm folder to the c: drive. Now I can build from the masm editor no problem. But when I try to run ml from the command line I get the error

C:\asm>ml asm0.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: asm0.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/z2
"asm0.obj"
"asm0.exe"
NUL
LINK : warning LNK4044: unrecognized option "z2"; ignored
asm0.obj : warning LNK4033: converting object format from OMF to COFF
LINK : fatal error LNK1181: cannot open input file "asm0.exe"

which is odd since the file being compiled is:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

comment * -----------------------------------------------------
                        Build this  template with
                       "CONSOLE ASSEMBLE AND LINK"
        ----------------------------------------------------- *

    .data?
      value dd ?

    .data
      item dd 0

    .code

start:
   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    call main
    inkey
    exit

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

main proc

    cls
    print "Hello",13,10

    ret

main endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start


so there shouldn't be any linker problems...

E.


mnemonic

Quote from: eeoam on August 04, 2007, 02:53:28 PMLINK : fatal error LNK1181: cannot open input file "asm0.exe"
I know that "problem", but it is rather simple to solve:
Make sure, that the executable (asm0.exe) is not running (being executed by Windows) at the time the linker is trying to access it.
You can not overwrite an executable that is currently running.

You can ignore the other warnings as they are more of an informational nature.
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

MichaelW

What is /z2, and what is your linker command line?
eschew obfuscation

Vortex

E:\asm>ml asm0.asm

This should be :

E:\asm>ml /c /coff asm0.asm

eeoam

Quote from: MichaelW on August 05, 2007, 04:59:39 AM
What is /z2, and what is your linker command line?

I don't know what /z2 came from. I've just been typing

ml asm0.asm

eeoam

Quote from: Vortex on August 05, 2007, 07:09:24 AM
E:\asm>ml asm0.asm

This should be :

E:\asm>ml /c /coff asm0.asm

Aha! I assemble with "ml /c /coff asm0.asm" and link with "link /SUBSYSTEM:CONSOLE /OPT:NOREF asm0.obj" and it all works!

Thanks for all your help!


Vortex