The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: WayneSallee on May 22, 2005, 05:51:01 PM

Title: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 05:51:01 PM
Ok I've got an asm file to assemble, and run, but Masm 32 will not assemble it. It gives me erros that there is no obj file. How do I creat an obj file, and do I need other files to get this this thing to run. In the past I used masm 61.

This Masm 32 is so not userfreindly.

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 22, 2005, 05:53:37 PM
To turn .asm into .obj, ml /c /coff MyAsm.asm
To turn .obj into .exe, link /subsystem:windows MyAsm.obj
Title: Re: Getting Started with Masm 32
Post by: Vortex on May 22, 2005, 05:58:40 PM
Hi Wayne,

Should you give a little more information about the error messages you are receiving?
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 06:00:49 PM
Quote from: AeroASM on May 22, 2005, 05:53:37 PM
To turn .asm into .obj, ml /c /coff MyAsm.asm
To turn .obj into .exe, link /subsystem:windows MyAsm.obj

Ok where do I put those commands?, in the asm file?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 06:03:55 PM
Quote from: Vortex on May 22, 2005, 05:58:40 PM
Hi Wayne,

Should you give a little more information about the error messages you are receiving?

error cannot open input file. c:/obj      something like that

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: Phil on May 22, 2005, 06:10:45 PM
Nope, the commands don't belong in the asm file. First, you must make sure that the c:\masm32\bin directory is in your path at the command level. You can accomplish this by starting a command processor and then doing a path command like:

 C:\MyDir> path=C:\masm32\bin;%path%

This will set your search path to look first in the directory where you installed the masm32 binaries. The ML and LINK programs will be found there and they will be treated as commands if they are in the command processors search list. The %path% after the semi-colon will make sure that all previously defined directories remain in your path. Then:

 C:\MyDir> ml /c /coff MyAsm.asm
 C:\MyDir> link /subsystem:windows MyAsm.obj
 C:\MyDir> dir MyAsm.exe
 C:\MyDir> MyAsm

Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 06:15:29 PM
Clear as mud.

Wayne Sallee
Wayne@WayneSallee.com

Quote from: Phil on May 22, 2005, 06:10:45 PM
Nope, the commands don't belong in the asm file. First, you must make sure that the c:\masm32\bin directory is in your path at the command level. You can accomplish this by starting a command processor and then doing a path command like:

 C:\MyDir> path=C:\masm32\bin;%path%

This will set your search path to look first in the directory where you installed the masm32 binaries. The ML and LINK programs will be found there and they will be treated as commands if they are in the command processors search list. The %path% after the semi-colon will make sure that all previously defined directories remain in your path. Then:

 C:\MyDir> ml /c /coff MyAsm.asm
 C:\MyDir> link /subsystem:windows MyAsm.obj
 C:\MyDir> dir MyAsm.exe
 C:\MyDir> MyAsm


Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 22, 2005, 07:23:27 PM
ml.exe and link.exe are programs run from the command line. They normally reside in c:\masm32\bin.
Therefore to run them you could type into the commandline c:\masm32\bin\ml.exe and c:\masm32\bin\link.exe
But if you put c:\masm32\bin in your path environment variable then you only have to type ml and link into the commandline.
On Win98 you can do this by putting SET PATH=%PATH%;C:\masm32\bin at the end of c:\autoexec.bat. On WinXP you can do this by going to Control Panel...System...Advanced...Environment Variables. Find path in the System Variables section and put a ;c:\masm32\bin at the end of it.

There is a two step process for converting MyAsm.asm into MyAsm.exe:
type into console ml /c /coff MyAsm.asm.
Then type into consol link /subsystem:windows MyAsm.obj
This is assuming that your console is in the directory containing MyAsm.asm.
Title: Re: Getting Started with Masm 32
Post by: MichaelW on May 22, 2005, 09:29:23 PM
Hi Wayne,

Your problem might have a simple solution. Could you show us what you are you trying to assemble and tell us how are you trying to assemble it?

Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 11:28:15 PM
The problem was not in the software finding the masum files, it was a problem with the software not finding my files because I did not have my files in the masm32 directory. I created a temporary directory in the masm32 directroy, and it no longer gives me those errors.

But eventualy I will move back out of the masm 32 directory. To do that I guess I will have to edit an autoexe file.

Next question:

Does the asembler not check for errors??? What's up?  I can put junk in the code, and it won't give any errors.

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 11:34:44 PM
Ok, the problem with check for errors was salved. Have to do a file save, or els it uses the file before editing. Masm 61 will ask to save changes before assembling.

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 22, 2005, 11:44:05 PM
Ok since I put the junk in there to see if it would find errors, I know exactly whre that junk is, but is there not a way to have it singlestep and show you exactly where in the code, that the errors are, like masm61 does?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: mnemonic on May 22, 2005, 11:58:15 PM
Hi WayneSallee,

Quote from: WayneSallee on May 22, 2005, 11:28:15 PM
Does the asembler not check for errors??? What's up?  I can put junk in the code, and it won't give any errors.
This is assembler not Java. Masm just checks for invalid mnemonic usage and the like. In general you are yourself responsible for what you code.

Quote from: WayneSallee on May 22, 2005, 11:34:44 PM
Ok, the problem with check for errors was salved. Have to do a file save, or els it uses the file before editing. Masm 61 will ask to save changes before assembling.
Huh? Sorry, but I don´t get what you´re saying half the time...
Masm won´t ask you for anything. Did you mean QEdit?

Quote from: WayneSallee on May 22, 2005, 11:44:05 PM
Ok since I put the junk in there to see if it would find errors, I know exactly whre that junk is, but is there not a way to have it singlestep and show you exactly where in the code, that the errors are, like masm61 does?
Singlestep? Do you speak of some debugger?
If masm finds syntax errors or errors in general it will tell you in which line they are.

Please try to be a bit more precise. Thanks.

Regards
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 23, 2005, 01:04:16 AM
Quote from: mnemonic on May 22, 2005, 11:58:15 PM
If masm finds syntax errors or errors in general it will tell you in which line they are.


Ok it does. I did not notice that. Though single stepping like masm61 would be better, but at least it does have line numbers. I had not noticed that.

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: hutch-- on May 23, 2005, 01:10:22 AM
Wayne,

The problems appear to be from the amount of theory you bring in with your code. Bottom line is you must find the appropriate binaries and this can be done as per MASM32 with hard coded paths or alternatively by setting the paths in the environment. Either way you must find all of the files required to build the application or you will keep getting errors related to missing files.
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 23, 2005, 01:30:08 AM
I'm working on converting a 16 bit program to a 32 bit program. Fun fun :-) What role can the segment registers play. Can I use them freely as 16 registers, or is the use of them prohibited. Or what role do they play if any in 32 bit programing?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: hutch-- on May 23, 2005, 01:46:28 AM
Wayne,

You don't use segment registers in 32 bit code as they are set to the same starting address for FLAT memory model. Count it as a blessing.  :toothy
Title: Re: Getting Started with Masm 32
Post by: Mark Jones on May 23, 2005, 01:47:22 AM
Hello Wayne, welcome to the forum. :)

Please see this thread about the 16-bit registers: http://www.masmforum.com/simple/index.php?topic=1362.0

I found that information by using the little search box above.

That said, I would not recommend starting your 32-bit journey with such a complex task. Look at the Iczelion tutorials included with MASM32, that's probably your best way to get accustomed to this new style of coding.

Good luck and have fun.
Title: Re: Getting Started with Masm 32
Post by: GregL on May 23, 2005, 01:58:40 AM
Wayne,

Are you talking about the DOS-based IDE that came with MASM 6.1?. Wasn't it called 'Programmer's Workbench'? It's been more than a decade since I used it. There are IDEs for MASM that run on 32-bit Windows. The one that comes with MASM32 is QEdit, some others are WinAsm and RadAsm. Otherwise it's done from the command-line.
Title: Re: Getting Started with Masm 32
Post by: pbrennick on May 23, 2005, 12:42:18 PM
[Shameless Plug]Don't forget EasyCode.[/Shameless Plug]

Paul
Title: Re: Getting Started with Masm 32
Post by: Mark Jones on May 23, 2005, 09:50:50 PM
I was thinking the same thing Paul, but you beat me to it. :)
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 26, 2005, 01:55:34 AM
.DATA

.CODE

.DATA

.CODE

.DATA

This is getting old. did not have to do it when programing in 16 bit. Is there a way around having to tell it every time that it's now data, or now code?

Also what's a good book to buy that would be best for me with my move from 16 bit to 32 bit, preferably one without a lot of higher code, but a rather pure assebly language code?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: hutch-- on May 26, 2005, 04:21:00 AM
 :bg

Wayne,

Yes there is a way around it, write all of you data to the data section in one ".data" notation. The capacity to use,


.data
  somedata dd 0
.code


is there if you need to split up code and data.
Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 26, 2005, 06:09:55 AM
Iczelions Win32 tutorials are very good:

http://win32assembly.online.fr/tutorials.html
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 26, 2005, 10:32:48 PM
Quote from: hutch-- on May 26, 2005, 04:21:00 AM
:bg


is there if you need to split up code and data.


I like putting the data with the subrotines that use it. That's my prefered way to organize it, and it was simple with masm16, but with masm32 I find that I have to insert .code, and .data.  So I thought I would check to see if there was a way to still do it without having to inset .code, and .data.

Is there some reasoning behind this that I don't understand? It seems so much simpler to mix the code with the data instead of having it segmented. Is there some reasoning behind this that I don't understand?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: QvasiModo on May 26, 2005, 11:12:05 PM
Hi all :)

Quote from: WayneSallee on May 26, 2005, 10:32:48 PM
Is there some reasoning behind this that I don't understand? It seems so much simpler to mix the code with the data instead of having it segmented. Is there some reasoning behind this that I don't understand?

The main reason is the fact that under modern OSs the code section is read-only.

Speed is another reason. For old processors it used to be all the same, but now mixing code and data is bad: it makes the processor waste bandwidth fetching data into the code cache, and invalid opcodes are slower to decode.
Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 27, 2005, 06:17:49 AM
INside procedures you can use stack space for local variables like this:


MyProc proc arg1:DWORD,arg2:DWORD

LOCAL Var1:DWORD
LOCAL Var2:DWORD

...

ret

MyProc endp
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 28, 2005, 05:32:55 PM
Still working on changing my code over to 32 bit.

I can't even get a PUSH   EBX to work. I don't get any errors on assembly, but when I run it, microsoft gives an error that it has to be shut down. I can put ret's before push statements, but if a push is read, it errors.

Is there some kind of stack preperation that I have to do that I didn't have to mess with on 16 bit?

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 28, 2005, 05:53:45 PM
The only way that push ebx could fail at the OS level is if you mess up the stack pointer esp.

Please could you post the offending code?
Title: Re: Getting Started with Masm 32
Post by: WayneSallee on May 29, 2005, 01:58:29 AM
No microsoft does not have to shut down. Microsoft shuts down my program.

Now I found the problem. It's erroring on that fact that I ret without poping the stack to ballance it out. So it's the ret that is creating the error, not the push

I was using the ret to debug, and was actualy creating a bug.

Ok back to de work :-)

Wayne Sallee
Wayne@WayneSallee.com
Title: Re: Getting Started with Masm 32
Post by: AeroASM on May 29, 2005, 07:58:19 AM
Quote from: WayneSallee on May 29, 2005, 01:58:29 AM
No microsoft does not have to shut down. Microsoft shuts down my program.

I knew that. I meant that the program fails at the OS level rather than the CPU level or other.

I also suspected that the ret might have been causing the problem with an imbalanced stack but I did not say it bcause I misread your post and thought that you had said that it was the pushh ebx that caused the problem.