Memory Management
Dr. Tim McGuire
CS 272
Sam Houston State University
Overview .COM Programs .COM Program Format %TITLE "COM File Template"
    IDEAL
    MODEL tiny
    DATASEG
excode     DB     0
    CODESEG
    ORG    100h            ; Standard .COM start address
Start:
;----- Insert program here
Exit:
    mov    ah,04Ch         ; DOS function: Exit program
    mov    al, [exCode]    ; Return exit code value
    int    21h             ; Terminate program
    END    Start           ; End of program/entry point
The ORG Directive A .COM Program in Memory
 
 
 
 
 
 
 
 
 
 
 

.COM Program Stack

An Example of a .COM Program %TITLE ".COM Demo"
    IDEAL
    MODEL   tiny
    DATASEG
MSG DB "Hello$"
    CODESEG
    ORG     100h     ;Standard .COM start address
Start:
    lea     dx,[msg] ;get message
    mov     ah,9     ;display string function
    int     21h      ;display 'Hello'
Exit:
    mov     ah,04Ch  ;DOS function: Exit program
    mov     al,0     ;Return exit code value
    int     21h      ;Terminate program
    END     Start    ;End of program/entry point
Differences between .COM and .EXE mov ax,@data
mov ds,ax
are not needed in a .COM program
Program Modules Assembly and Object Modules NEAR and FAR Procedures PROC name   type
; body of procedure
     ret
ENDP name
The Execution of a FAR Procedure EXTRN EXTRN Example PUBLIC where name_list is a list of procedure and variable names that are referenced in a different module Linking Object Modules An Example of EXTRN and PUBLIC