The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: mohit on July 06, 2009, 06:40:16 AM

Title: ml.exe question
Post by: mohit on July 06, 2009, 06:40:16 AM
To assembly guru's,

I have just started on assembly (my first program) and I am getting compilation errors with below line of code

_DATA   SEGMENT public 'DATA'
;Declaring global variables
MyVar   dword      1      ;32 bits or 4 byte variable
_DATA   ENDS

mov   eax, seg _DATA      ;I am getting error at this point

Please help!!! I am compiling this file using inshipped masm version in VC++ 2008
Title: Re: ml.exe question
Post by: hutch-- on July 06, 2009, 06:57:04 AM
Have a look at the code in the masm32 project as it shows you how to put a basic assembler skeleton together.

The minimum things you need are include files for any API calls you choose to use which contain the prototypes for the API functions and you need to set up the memory model for 32 bit FLAT and usually the default calling convention to be used which is STDCALL.

It looks basically like this.

      .386                   ; minimum processor needed for 32 bit
      .model flat, stdcall   ; FLAT memory model & STDCALL calling
      option casemap :none   ; set code to case sensitive


The actual error you are getting is because your code is not in a code section but you are much better off checking out the existing masm32 models than trying to manually code segment directives with no practice.