News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

help with masm

Started by Pokerice, May 10, 2014, 06:34:49 PM

Previous topic - Next topic

Pokerice

Hello, I am trying to learn assembly with masm32 but I am confused about a few things.

1) I tried opening the demo 1 and 2 but it seemed to do nothing or it exited before I can take a look at it.

2) I cannot find the ml.exe or linker.exe in the folder(I was trying to use the ml command in cmd but it is unrecognized).

3) I read that one of the advantages of assembly is its small size, but looking at demo 1 (hello world), the asm file is 2KB while exe is 3KB. Is this considered to be small?

4) I am currently trying to follow the "Iczelion's tutorial" on assembly, are there any other good tutorials/readings? (Not sure if Iczelion's tutorial is outdated or not)

jj2007

First things first: Welcome to the Forum :icon14:

Please try to be a bit more precise. There is no file or folder "demo" in \Masm32\examples
Below a simple example:

include \masm32\include\masm32rt.inc

.code
AppName   db "Masm32:", 0

start:   MsgBox 0, "Hello World", addr AppName, MB_OK
   exit

end start


You can use print "hello world" instead of the MsgBox. If the console window closes too fast, use inkey "hit a key" before exit.

Iczelion's tutorials are still the best way to learn Windows programming. See also Tips, Tricks & Traps for a concise introduction and some helpful material.

Pokerice

Thanks!

The demo is in \Masm32\tutorial\console\...
I just tried adding the inkey just before exit in demo1. When I opened the exe or go Project>Run program, nothing happens.

dedndave

Iczelion's tutorial is a bit out of date
however, it is still a great tutorial, with a little rework

one example is that the masm32 libraries and include files have been vastly updated since it was written
Iczelion might show you how to PROTOtype windows API functions that are now already done for you
it might also tell you to define some windows constants and structures that are already defined in windows.inc

dedndave

ML and LINK are in \masm32\bin
it's not a requirement, but i like to add that folder to my PATH

3 Kb is fairly small, in terms of PE executables
it's not as small as some old DOS .COM programs
but, compared to a compiler EXE, it can be very small
some compilers might make a 60 Kb EXE for Hello World - lol

dedndave

as for the examples, try the ones in \masm32\examples, rather than the ones in \masm32\tutorial
however, that should produce an output

both demo1 and demo2 produce output for me
you may have to open a console window in the folder, then type the EXE name to execute

Pokerice

Thank you dedndave, indeed the ML and LINK is in the bin folder.

Regarding to the size, its just that I heard people can get below 20bytes for a simple hello world program with assembly. The demos still doesn't work though even with console but I guess I will just skip them and go to examples, thanks again :biggrin:

dedndave

20 bytes is an old DOS 16-bit .COM program
and, yah, they can be really Tiny   :P

but, nowdays, everyone has terabyte drives and gigabytes of RAM
small isn't as big a deal as it used to be
i still try to keep an eye on size - out of habit, mostly

Vortex

Hi Pokerice,

Welcome to the forum.

Dave is right. Those very short applications are 16-bit DOS COM. Here is an example :

.model tiny

.data

string db 'Hello!$'

.code

org 100h

start:

    mov     dx,OFFSET string

    mov     ah,9
    int     21h

    mov     ax,4C00h
    int     21h

END start

Pokerice

Thanks Vortex 8)

I can't seem to open the exe (incompatible version) and I get symbol not defined :DGROUP if I try to assemble and link in the editor.

hutch--

If you are going to build 16 bit COM files you need to use the old OMF linker and write your own batch file to build it, the normal linker in MASM32 is only for 32 bit PE files.

Pokerice

No wonder it wouldn't work, thanks hutch--. Guess I will concentrate on 32bit for the time being.

Vortex

Hi Pokerice,

You can check Build.bat in the attachment. link16.exe is the 16-bit linker :

\masm32\bin\ml /c /AT Hello.asm
\masm32\bin\link16 /TINY Hello.obj,Hello.com;

Pokerice

I ran your Build.bat, it created the obj and com files. But when I open the .COM, it is still incompatible.

Vortex

Hi Pokerice,

What's your operating system? The 64-bit versions of Vista,Win 7 and Win8 will not allow 16-bit DOS applications :

http://msdn.microsoft.com/en-us/library/bb756962.aspx