Comparison of COM files and EXE files in DOS

Source: Internet
Author: User

[Source] http://www.cnsharenet.com/DOS/f/dft/dexecom.htm

    A com file is a memory image file of an executable program. It is similar to the executable program structure in the CP/M operating system of an 8-bit machine with only 16-bit address lines. During the execution of the COM program, besides the DOS and rom bios functions, and the user's specific arrangement, the segment register is generally not changed. The four segment registers share the same content and all point to PSP. Therefore, the program size is limited to 64 KB. The COM file entry must be 100 H, while the EXE file can have multiple segments. CS, SS, IP, and SP are initialized by DOS according to the information in the file header when the program is loaded, and ES and DS point to PSP. In addition to the program itself, the EXE file also includes the file header (an integer multiple of 512 bytes), which occupies a larger disk space and slows down loading, but the program size is not limited. After the EXE file is modified using debug, it cannot be directly written back to the disk.

Comparison between COM files and EXE files
Comparison item COM Program EXE program
Maximum Size 65536 bytes minus 256 bytes of PSP and 2 bytes of stack No restrictions
Portal PSP: 100 H The END statement parameter indicates
Code segment containing the entry
Portal CS PSP Offset of the entry in the segment
Entry IP Address 100 H PSP
DS at entry time PSP PSP
ES at entry time PSP Segment with STACK attribute
SS at entry time PSP Length with STACK attribute segments
Enter the SP 0FFFEH or off-high memory high-end-2 Initialized or not initialized
Stack upon entry Press a word with a value of 0 Defined by segments with STACK attributes
Stack size 65535 bytes minus PSP length (256 bytes) minus executable code length NEAR or FAR
Subroutine call NEAR 4 ch of INT 21 H is recommended
Exit Method We recommend that you use a 4CH of INT 21 H or near RET or INT20H. If the user has initialized
Far RET is also available
File Length Program length Program length and File Header
(Integer multiple of 512 bytes)

I. Similarities
Both are executable files under DOS .. The COM file is an executable binary code file, and the. EXE file is an executable floating code file.
Ii. Differences
(1) The. COM file is generally relatively small and cannot exceed 64 KB, while the. EXE file is generally large and can exceed 64 KB.
(2) The. COM file is quickly loaded into the memory, while the. EXE file is slow.
(3). COM files are generally relatively simple, and. EXE files are relatively complicated, making it difficult to compile.
(4 ). COM files contain the same values in the execution period registers, that is, code, data, and so on. the EXE file contains different values in the execution period register, that is, the code and data reside in different segments.
(5). the COM file does not have a file header or any other internal identification information, but resides on the disk. the EXE file has a file header (also called a control information block), a relocation map, and other information used by DOS.
(6) For the. COM file, the DOS loader cannot relocate its execution segments, but for the. EXE file, its execution segments can be relocated.
(7) The. COM file can have only one segment, while the. EXE file can have more than one segment.
(8) The. COM file cannot have a stack segment, but the. EXE file can.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.