MLHA - PC - Programmering - Assembler - MASM - Directives
| .CODE | .DATA | .MODEL | .STACK |
| ASSUME | DB | DOSSEG | END | ENDS | EQU | ORG | SEGMENT | TITLE |

.CODE [name]
Used with .MODEL - defines start of code segment.
name may be used with medium, large and huge models.
Default segment name for small and compact models: _TEXT
.DATA
Used with .MODEL - defines start of NEAR data segment.
Segment name: _DATA
.MODEL model
Defines the memory model: SMALL, COMPACT, MEDIUM, LARGE, HUGE
.MODEL can only be used with the EXE format (not COM).
.MODEL SMALL
>.CODE, .DATA, .STACK
>DOSSEG
.STACK [size]
Used with .MODEL - defines start of stack segment.
Segment name: STACK
Default stack size: 256 (1024?) bytes - may be set with size.
.STACK 100h  ;256 bytes
ASSUME
Associates a segment-register (CS,DS,ES,SS) with a named segment.
      ASSUME CS:code, DS:code, ES:code, SS:code
code  SEGMENT
>SEGMENT
DB
Define Byte : Allocates [and initializes] one ore more bytes of data
Char bytes (strings) may be delimited by either " or '.
msg   DB   "Message$"
      DB   "Hello World",13,10
      DB   'Hello World',0Dh,0Ah
      DB   ;uninitialized byte
  
      mov  dx,offset msg
DOSSEG
Orders segments according to the Microsoft DOS segment conventions - overriding the ordering in the source text.
>.STACK, .DATA, .CODE
END [address]
Marks the end of a module [and sets entry point to address].
start: ;code starts here
       ;...
       END start
ENDS
>SEGMENT
EQU : name EQU expression
Equate : Assigns expression to name.
msg    db "Hello",13,10
len    EQU $ - msg      ;len = location - OFFSET msg = 7

       mov dx,OFFSET msg 
       mov cx,len       ;mov cx,7
ORG
Sets the Location Counter.
In COM programs, ORG 100h leaves room for the DOS PSP.
code   SEGMENT
       ORG 100h
start: ;code at 100h
SEGMENT
Defines a named program segment
code  SEGMENT
      ;code here
code  ENDS
>ASSUME
TITLE
Defines the program title - usually in first program line
TITLE hello