The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: paja on September 01, 2008, 11:25:16 AM

Title: multiple code segment
Post by: paja on September 01, 2008, 11:25:16 AM
Hi all :bg
I'm a student and I'm learning assembly x86 working with the masm environment.

I have the following question: manipulating the .model directive I can choose the memory model for my program, but why should I use multiple code (or data) segments?
For example, what are the benefits to have n different code segments?

Thanks a lot! :wink
Title: Re: multiple code segment
Post by: BogdanOntanu on September 01, 2008, 02:16:03 PM
In 32bit windows assembly you only use .model FLAT
This means that you have .code , .data and .data? "segments" And all segments are  sharing the same FLAT super group.

Do not confuse the segments that are used by MASM or assemblers or compilers to divide the program with the segments used by CPU when in real mode or the selectors used by the CPU in protected mode... they are NOT the same thing.

Using other models is for older environments like DOS/BIOS etc.

Multiple code segments can be used to group code in certain order in the same group. However those kind of things are either old and specific to DOS/BIOS programming or mixing 16 bits code with 32 bits code at system initialization... and are much to complicated to be understood or to be of real use to a beginner in assembly (OS programming)

For a start learn to write programs in win32 environment with FLAT model using MASM32.

Forget about old DOS and segmentation and 16 bits tutorials for a while. When you become experienced you can come back and turn the light onto those dark dusty places and clean them up.



Title: Re: multiple code segment
Post by: paja on September 01, 2008, 10:55:43 PM
Ok, thanks a lot for your suggestions! :bg