News:

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

asm Beginner compiler issues

Started by kaiplak, June 02, 2007, 08:28:07 AM

Previous topic - Next topic

kaiplak

I dled the masm32 profect created a hello world example. does masm 32 project include a compiler, because I can't figure out how to compile my hello world program. I also tried comiling somother program with ml dos command that was a different program it didn't work. How do you compile ASM? I feel like an idiot, since I have a bit of experience in Java and C, and now I can't even compiler masm...  :'(

donkey

Hi kaiplak,

To compile a program using MASM, you must first assemble it using ML.EXE, the command line generally looks like this...

ML.EXE /c /coff /Zi /Cp /nologo /I"\MASM32\Include" "myapp.asm"

Once assembled the program needs to be linked using a linker, LINK.EXE does this, though for 16 bit applications you will need an older version. The command line varies depending on what type of program you are building (GUI, Console, DLL etc...) but for a simple application it is...

LINK.EXE /SUBSYSTEM:WINDOWS /VERSION:4.0 /LIBPATH:"\MASM32\LIB" myapp.obj

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

hutch--

kaiplak,

It may help if you posted at least some of your code so we know what you are trying to do. Also don't be afraid to build some of the example code, its there to help you understand the format.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

kaiplak

Hey Guys Thanks, but I still don't understand. I tried the ML dos command on

this code:

.286
.model tiny

.code
   org 100h
entry:
   jmp start

   ; your data and subroutine here

start:
   mov ax, 4c00h
   int 21h
end entry

and it ended up with a bunch of fatal errors. I believe you would need to change .286 to .386?

At any rate I would love to make an asm program that displays the hello world message so I messed with this code abit in MASM32. I have tried all kinds of program like WinAsm, Masm32 and some others wich I forget at the minute. many did not have a compiler.

; This program displays "Hello, World!"

dosseg
.model small
.stack 100h

.data
hello_message db 'Hello, World!',0dh,0ah,'$'

.code
main  proc
      mov    ax,@data
      mov    ds,ax

      mov    ah,9
      mov    dx,offset hello_message
      int    21h

      mov    ax,4C00h
      int    21h
main  endp
end   main

ML.EXE /c /coff /Zi /Cp /nologo /I"\MASM32\Include" "myapp.asm"
could you explain the various options you put in this command, such as /c and /coff. Is it a necessity in masm to add the include files as part of the compile command rather than putting it in the code itself like how you do with C #include<header.h> or Java's import.whatever. what is a definite way to compile asm and what compiler options are there?

kaiplak

Hello Again I'd just like to make a further report about masm, I chose the assemble and link on this code

.386
.model tiny

.code
   org 100h
entry:
   jmp start

   ; your data and subroutine here

start:
   mov ax, 4c00h
   int 21h
end entry

and get this error:

Assembling: C:\Documents.asm
MASM : fatal error A1000: cannot open file : C:\Documents.asm
Volume in drive C has no label.
Volume Serial Number is 5077-408C

Directory of C:\

what does this mean? Still look at my above reply as well I used the assemble asm command on the masm32 editor and I also tried the assemble and link and got the same error what does this mean?

hutch--

kaiplak,

It because you are trying to build 16 bit DOS code with a 32 bit linker. If you are after 16 bit code, we have a 16 bit forum, if not try out some of the example code in the masm32 project, its all 32 bit and builds correctly.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Vortex


zooba

And the second error is because the batch files which come with MASM32 don't allow you to have spaces in the path to your file.

Install MASM32 in the root directory (ie. C:\MASM32) and put a PROJECTS directory in that or somewhere else where there are no spaces.

Alternatively, it is possible to modify the batch files to put quotes around all the filenames, but this is a bit more complicated. I think there was a post a while ago with ready-made batch files...

Cheers,

Zooba :U

kaiplak

Well I did a sear last night on the error I was getting and found your patch about the spaces in the path name for error a1000. I want to do 32 bit code, I don't understand assembly much, how do I set my code to 32 bit?
I found a hello example as well in the masm32 files:

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

;                 Build this with the "Project" menu using
;                       "Console Assemble and Link"

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

    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros

  ; -----------------------------------------------------------------
  ; include files that have MASM format prototypes for function calls
  ; -----------------------------------------------------------------
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc

  ; ------------------------------------------------
  ; Library files that have definitions for function
  ; exports and tested reliable prebuilt code.
  ; ------------------------------------------------
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

    .code                       ; Tell MASM where the code starts

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

start:                          ; The CODE entry point to the program

    print chr$("Hey, this actually works.",13,10)
    exit

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

end start                       ; Tell MASM where the program ends


It did compile but when I press on the exe file it doesn't do anything, how can I see the message. perhaps it is doing something but executes so fast that I don't see it. what is wrong with this? further more what are the options used in this command line: ML.EXE /c /coff /Zi /Cp /nologo /I"\MASM32\Include" "myapp.asm" don't forget to also tell me why my code was 16 bit?

MichaelW

To see the program output you can run it from a command prompt, or add a statement to the code that will cause it to delay before closing or wait for a keystroke. If you are working in QE, press Ctrl+D to get a command prompt. You can cause the program to delay for 2 seconds before closing by placing this statement immediately above the exit statement (the function name Sleep is case sensitive):

invoke Sleep, 2000

If you are working in QE you can see a list of the ML command line options at Help \ MASM32 Help \ Command Line Tools. If not, another method would be to open a command prompt and enter something like this, substituting the correct drive spec:

c:\masm32\bin\ml /?

For the details, see Chapter 1: Tools, here

16-bit DOS code uses a model other than flat. Other common characteristics are the presence of interrupt calls, and code that writes to the segment registers.
eschew obfuscation