.COM FILE TEMPLATE
;**********************************************
;
; .COM File Program Template (COM.ASM)
;
; Compile with:
;
; TASM COM.ASM
; TLINK /t COM.OBJ
;
; +gthorne'97
;
;**********************************************
.model small
.code
.386
org 100h
start: jmp MAIN_PROGRAM
;----------------------
; Your Data Here
;----------------------
;----------------------
MAIN_PROGRAM:
;---------------
; Your Code Here
;---------------
;---------------
mov al, 0h ; return code (0 = no error)
exit_program:
mov ah,4ch ; quit to DOS
int 21h
end start
.COM FILE TEMPLATE #2 (ALTERNATE)
;**********************************************
;
; .COM File Program Template #2 (COM_B.ASM)
;
; This is here for the purpose of comparison
; with the .EXE model shown below
;
; Compile with:
;
; TASM COM_B.ASM
; TLINK /t COM_B.OBJ
;
; +gthorne'97
;
;**********************************************
COM_PROG segment byte public
assume cs:COM_PROG
org 100h
start: jmp MAIN_PROGRAM
;----------------------
; Your Data Here
;----------------------
;----------------------
MAIN_PROGRAM:
;---------------
; Your Code Here
;---------------
;---------------
mov al, 0h ; return code (0 = no error)
exit_program:
mov ah,4ch ; quit to DOS
int 21h
COM_PROG ends
end start
.EXE FILE TEMPLATE
;**********************************************
;
; .EXE File Program Template (EXE.ASM)
;
; Compile with:
;
; TASM EXE.ASM
; TLINK EXE.OBJ
;
; +gthorne'97
;
;**********************************************
.model small ; normally small medium or large here
.stack 200h
.code
EXE_PROG segment byte public
assume cs:EXE_PROG,ds:EXE_PROG,es:EXE_PROG,ss:EXE_PROG
start: jmp MAIN_PROGRAM
;----------------------
; Your Data Here
;----------------------
;----------------------
MAIN_PROGRAM:
;---------------
; Your Code Here
;---------------
;---------------
mov al, 0h ; return code (0 = no error)
exit_program:
mov ah,4ch ; quit to DOS
int 21h
EXE_PROG ends
end start
.EXE FILE TEMPLATE #2 (ALTERNATE)
;**********************************************
;
; .EXE File Program Template 2 (EXE2.ASM)
; (Compares to first .COM file model)
; Tested under TASM 4.1
; Donated by Eyes22, Modified to match the others
;
; Compile with:
;
; TASM EXE2.ASM
; TLINK EXE2.OBJ
;
; +gthorne'97
;
;**********************************************
;dosseg ; directive is ignored in tasm 4, so
; uncomment it if you have any errors
.model small
.stack 200h
.data
.code
start: jmp MAIN_PROGRAM
;----------------------
; Your Data Here
;----------------------
;----------------------
MAIN_PROGRAM:
;---------------
; Your Code Here
;---------------
;---------------
mov al, 0h ; return code (0 = no error)
exit_program:
mov ah,4ch ; quit to DOS
int 21h
end start
Taken verbatim from the book Assembly Language for the IBM-PC
Graciously Appended By C.E.
COM Programs:There are two types of transient programs, depending on the extension used:
COM and EXE. You may recall that we used DEBUG to create and save short COM
programs. A COM program is an unmodified binary image of a machine-language
program. It is loaded into memory by DOS at the lowest available segment address,
and a PSP is created at offset 0.The code, data and stack are all stored in the
same physical (and logical)segment.The program may be as large as 64k, minus the
size of the PSP and two reserved bytes at the end of the stack. ALl segment registers
are set to the base address of the program. The code area begins at offset 100h,and
the data area immediately follows the code. The stack area is at the end of the
segment because DOS initializes SP to FFFEh.
e.g., Hello.asm
title Hello World Program written in COM format. Note that the DOSSEG, .DATA and
.STACK directives are unnecessary, and the directive ORG is added --(which sets
the location counter to offset 100h before generating any instructions. This
leaves room for the PSP, which occupies locations 0 through 0FFh. COM programs
are always smaller than their EXE counterparts.
.model tiny
.code
org 100h
maine proc
mov ah,9
mov dx, offset helo_msg
int 21h
mov ax, 4c00h
int 21h
maine endp
helo_msg db 'Hello, world!' '$'
end maine
|