The MASM Forum Archive 2004 to 2012

Miscellaneous Forums => 16 bit DOS Programming => Topic started by: ofiras on March 23, 2007, 12:32:08 PM

Title: MASM - compilation
Post by: ofiras on March 23, 2007, 12:32:08 PM
Hello everyone,
Im new here, and I have jest started learning ASM...
I didn't get it - how do I compile my ASM file? (Make it an EXE file)
I heard I need to use 'ml' and 'link' in the cmd of windows, but it says he doesn't know the command "ml"...
What do I do?
All I need is to make an ASM file to EXE, I don't care how...
Please help...
Thanks,
Ofir.
Title: Re: MASM - compilation
Post by: ragdog on March 23, 2007, 12:38:49 PM
hi

download m32v9r.zip and install !

save as compile.cmd in your project folder

and try this @echo off
set path=\masm32\
set resname=rsrc
set name=source

if exist %name%.exe del %name%.exe
if exist %resname%.res del %resname%.res

%path%bin\rc /v %resname%.rc
%path%bin\cvtres.exe /machine:ix86 %resname%.res
%path%bin\ml.exe /c /coff /nologo /I"%path%include" %name%.asm
%path%bin\link.exe /SUBSYSTEM:WINDOWS /OUT:%name%.exe /LIBPATH:"%path%Lib" %name%.obj %resname%.obj

if exist *.obj del *.obj

pause


ragdog
Title: Re: MASM - compilation
Post by: ofiras on March 23, 2007, 12:53:06 PM
Thenks, but i didn't really get it...
What do I save as compile.cmd? Where do I try this :

"@echo off
set path=\masm32\
set resname=rsrc
set name=source

if exist %name%.exe del %name%.exe
if exist %resname%.res del %resname%.res

%path%bin\rc /v %resname%.rc
%path%bin\cvtres.exe /machine:ix86 %resname%.res
%path%bin\ml.exe /c /coff /nologo /I"%path%include" %name%.asm
%path%bin\link.exe /SUBSYSTEM:WINDOWS /OUT:%name%.exe /LIBPATH:"%path%Lib" %name%.obj %resname%.obj

if exist *.obj del *.obj

pause
"?

Thenks,
Ofir.
Title: Re: MASM - compilation
Post by: ragdog on March 23, 2007, 01:08:47 PM
in your project folder

here is a example

[attachment deleted by admin]
Title: Re: MASM - compilation
Post by: ofiras on March 23, 2007, 03:19:45 PM
Tnx very very much...
one (I think) last thing...
It says "filename.obj : fatal error LNK1190: invalid fixup found, type 0x0001".
Why?
Thenks,
Ofir
Title: Re: MASM - compilation
Post by: hutch-- on March 23, 2007, 03:32:04 PM
Without seeing your source code, it is probably invalid startup code. Try this, BEFORE any of the runtime code place the label "start:", at the end of the runtime code put "end start" and see if you get the same error.

Its logic is something like this.

.486 etc ....
.data
  ; any data here
.data?
  ; any uninitialised data here
.code

start:

  ; all of the runtime code here

end start






Title: Re: MASM - compilation
Post by: ofiras on March 23, 2007, 04:10:44 PM
Still not working...
I just want to print something on the screen...
I'll be glad if you can chack my code to see what's wrong with it:
.586
.model flat, stdcall  ;32 bit memory model
option casemap :none  ;case sensitive

include windows.inc
include user32.inc
include kernel32.inc

includelib user32.lib
includelib kernel32.lib
.data

Message db "Hello!!! I'm Ofir$"

.code

start:

mov dx,OFFSET Message
mov ax,SEG Message
mov ds,ax

mov ah,9
int 21h
mov ax,4c00h
int 21h

end start


It says:
"
Assembling: myf.asm
myf.asm<19> : error A2022: instruction operands must be the same size
myf.asm<20> : error A2004: symbol type conflict
Microsoft <R> bla bla bla...
Copyright <C> bla bla bla...

LINK : fatal error LNK1181: cannot open input file "myf.obj"
"

I have never compiled even 1 program in ASM... I'll be very happy to do it, so thenks very very much for your help.


Thenks a lot,
Ofir
Title: Re: MASM - compilation
Post by: PBrennick on March 23, 2007, 10:19:39 PM
ofiras,
There are several things wrong here. Primarily you are putting 16bit code into a win32 source. This will never work as interrupts are not allowed in win32 (basically).

The first thing we need to know is are you trying to write a windows program or a DOS program. Once we know that, we can better help you. Based on your answer, this topic will be moved to either the Campus or to the 16bit programming area.

Let us know what you want.
Paul
Title: Re: MASM - compilation
Post by: Sameer on March 24, 2007, 05:15:24 AM
also there are so many examples around just have a look

also look at The GeneSys Project
Title: Re: MASM - compilation
Post by: ofiras on March 24, 2007, 09:43:32 AM
First of all, thenks a lot for all of you for trying to help me.
For start, I want to know how to use DOS.
How do I do it?

My original code was diffrent, but i changed it... it was:

; This is a simple program which displays "Hello World!"
; on the screen.

.model small
.stack
.data

Message db "Hello World!$" ; message to be display

.code

mov dx,OFFSET Message ; offset of Message is in DX
mov ax,SEG Message ; segment of Message is in AX
mov ds,ax ; DS:DX points to string

mov ah,9 ; function 9 - display string
int 21h ; call dos service
mov ax,4c00h ; return to dos DOS
int 21h

END start               ;end here


Thenks,
Ofir

Title: Re: MASM - compilation
Post by: ofiras on March 24, 2007, 07:02:47 PM
Seems to be dead here...
Title: Re: MASM - compilation
Post by: MichaelW on March 24, 2007, 07:24:04 PM
With the addition of a start: label at the start of the code segment, your code will assemble, link, and run OK. What version of MASM are you using, and do you have a 16-bit linker?