What is meaning of .model small in 8086 programs?

Sakil Mallick picture Sakil Mallick · Nov 12, 2017 · Viewed 17k times · Source

I am a beginner in 8086 assembly language. I can understand the logic used in the program and write small programs myself. But I just want to know what this does:

.model small
.stack 300h

What is explanation for .model small?

I am using masm.

Answer

Sep Roland picture Sep Roland · Nov 12, 2017

With .model tiny you get a program where CS, DS, and SS are all pointing to the same 64KB of memory. The stack is placed in the highest region of this 64KB segment.

With .model small you get a program where CS points to a segment of its own, followed by the segment where DS and SS are pointing to. The stack is placed in the highest region of the SS segment.

The directive .stack 300h is telling MASM the size of the stack, so MASM can warn you when the rest of the program (data,bss,heap) would clash with the stack.

In both these models all access to data items is done using near pointers.