Q44746: .MODEL and FAR_STACK, LOCAL_STACK in Quick Assembler

Article: Q44746
Product(s): See article
Version(s): 2.01
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_masm
Last Modified: 26-JUN-1989

Prior to Quick Assembler Version 2.01, the .MODEL directive expanded
into instructions that assumed that SS=DS=DGROUP. This situation is
not upheld at the start of a stand-alone assembly program (initially,
SS is set to the stack segment, and SP is set to the size of the
stack). The startup code of all Microsoft high-level languages sets
SS=DGROUP and adjusts SP accordingly.

Two new attributes have been added to the .MODEL directive:

1. FAR_STACK

2. LOCAL_STACK  (the default, if neither is specified)

These new options are designed to simplify setting up segments for
DS=SS and DS!=SS.

LOCAL_STACK is the default, and will direct .MODEL and .STACK to
behave as they have previously, i.e., set up segments assuming DS=SS.

FAR_STACK will direct the .MODEL and .STACK to do the correct setup
for a DS!=SS environment.

The following lists the expansion of a sample .MODEL and .STACK
directive:

.MODEL small = _data  SEGMENT WORD PUBLIC 'data'
               dgroup GROUP  _data
               _data  ENDS
               _text  SEGMENT WORD PUBLIC 'text'
               _text  ENDS
                      ASSUME cs:_text, ds:_data, ss:dgroup

.STACK 100h  = stack  SEGMENT PARA STACK 'stack'
               dgroup GROUP  stack
                      org 100h
               stack  ENDS

This setup assumes that DS==SS, which is the default. Specifying
".MODEL small, LOCAL_STACK" expands to the same instructions.

If you specify FAR_STACK in the above example, the expansion is as
follows:

.MODEL small, FAR_STACK
               _data  SEGMENT WORD PUBLIC 'data'
               dgroup GROUP  _data
               _data  ENDS
               _text  SEGMENT WORD PUBLIC 'text'
               _text  ENDS
                      ASSUME cs:_text, ds:_data, ss:NOTHING

.STACK 100h
               stack  SEGMENT PARA STACK 'stack'
                      ASSUME  SS:stack
                      org 100h
               stack  ENDS

Please note that the stack segment is not placed in DGROUP when
FAR_STACK is specified. Additionally, the "assume" generated by the
.MODEL assumes NOTHING for SS, and the .STACK performs an "assume" to
the stack segment.

An error is generated if FAR_STACK is specified along with the TINY
memory model.