The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Ani_Skywalker on November 03, 2011, 06:44:30 PM

Title: Random questions
Post by: Ani_Skywalker on November 03, 2011, 06:44:30 PM
I have a lot of questions that in my opinion wont need any thread of their own, they are more random stuff that I start to wonder about while reading about assembly or writing it. Thought I post those questions here instead of swarming this forum with threads.

Things I wonder right now:

1. What is the difference of MASM and MASM32? I refer to this: http://www.microsoft.com/download/en/details.aspx?id=12654

2. In the book "Assembly Language Step by Step with DOS and Linux" the author talks about defining a stack segment. Here is a quote:

QuoteThe segment containing the stack has some special considerations attached to it, especially regarding the linking of several files together into one executable program. One of these considerations is that the stack have the type "stack" attached to it. This tells the linker (as I explain later) that this particular segment is special-it's a stack segment and not just a data segment. Hence the line: SEGMENT stack stack

I don't really get this part, could you actually define what your stack will look like on program start? Never come by this part in my previous assembly readings before.

3. Can you mix up sections when you write assembly. For example, can you write like this:

.data
.data?

.code
start
main proc
...
endp main
end start

.data
...

.code
...


The reason I ask this is because I believe I read somewhere it is not possible, yet the author of the book I mentioned above claims you can do it. One difference is that he uses NASM. Maybe you can do it in NASM but not in MASM?

Also, is there any good NASM IDEs for Windows?
Title: Re: Random questions
Post by: NoCforMe on November 03, 2011, 06:50:54 PM
Regarding #2, yes, of course you can define what your program stack looks like with MASM (or MASM32 for that matter).

But you know what? One of the nice things about Win32 programming is that you don't have to define the stack at all! It's basically handed to you on a silver platter by Windoze; all you have to do is use it (properly). Which takes a lot of  headaches out of the programming equation from the get-go.

Otherwise, you would need to define a stack segment (since every program requires a stack, no matter how small or primitive). You have control over

So if you're writing Windows programs, don't worry about the stack. (Just don't get it out of balance!)
Title: Re: Random questions
Post by: dedndave on November 03, 2011, 07:09:54 PM
1) masm is an assembler program distributed by microsoft
masm32 is a library and tools package developed by Hutch - intended for use with masm

2) win32 - we use "flat" memory model
code, data, stack - all addressable in a 4 Gb flat space
no need to mess with it - or CS, DS, ES, SS for that matter

3) yes - no problem
when you open a segment, the assembler suspends the one that was previously opened
this applies to the source text file
however, all the .DATA stuff winds up in one segment,
.CODE - all in one segment
which really aren't segments as we knew them in 16-bit days
they are merely sections of the PE executable file
Title: Re: Random questions
Post by: NoCforMe on November 03, 2011, 07:17:09 PM
I have to say that one of the things I don't miss at all from the good old 16-bit days is having to mess with segments and segment registers. Very refreshing to have everything on one big flat playing field.
Title: Re: Random questions
Post by: qWord on November 03, 2011, 07:23:18 PM
3) Annotation: You can still use MASM's SEGMENT-directive for switching segments. This directive also allows to create new segments (=sections) with user defined attributes (read,write,execute,alignment, ...).
Title: Re: Random questions
Post by: MichaelW on November 04, 2011, 02:31:33 AM
Quotewhen you open a segment, the assembler suspends the one that was previously opened

Opening a stack segment does not close the current segment.
Title: Re: Random questions
Post by: Ani_Skywalker on November 04, 2011, 12:09:02 PM
Quote from: MichaelW on November 04, 2011, 02:31:33 AM
Opening a stack segment does not close the current segment.

Ah, so opening a stack segment is an exception to that rule?
Title: Re: Random questions
Post by: MichaelW on November 04, 2011, 12:35:08 PM
Quote from: Ani_Skywalker on November 04, 2011, 12:09:02 PM
Ah, so opening a stack segment is an exception to that rule?

Yes, or at least it used to be.