COM file

COM
Filename extension
.COM
Internet media typeapplication/x-dosexec
Type of formatExecutable
Extended toDOS MZ executable
A number of COM files in IBM PC DOS 1.0

A COM file is a type of simple executable file. On the Digital Equipment Corporation (DEC) VAX operating systems of the 1970s, .COM was used as a filename extension for text files containing commands to be issued to the operating system (similar to a batch file).[1] With the introduction of Digital Research's CP/M (a microcomputer operating system), the type of files commonly associated with COM extension changed to that of executable files. This convention was later carried over to DOS. Even when complemented by the more general EXE file format for executables, the compact COM files remained viable and frequently used under DOS.

The .COM file name extension has no relation to the .com (for "commercial") top-level Internet domain name. However, this similarity in name has been exploited by malware writers.

DOS binary format

The COM format is the original binary executable format used in CP/M (including SCP and MSX-DOS) as well as DOS. It is very simple; it has no header (with the exception of CP/M 3 files),[2] and contains no standard metadata, only code and data. This simplicity exacts a price: the binary has a maximum size of 65,280 (FF00h) bytes (256 bytes short of 64 KB) and stores all its code and data in one segment.

Since it lacks relocation information, it is loaded by the operating system at a pre-set address, at offset 0100h immediately following the PSP, where it is executed (hence the limitation of the executable's size): the entry point is fixed at 0100h.[nb 1] This was not an issue on 8-bit machines since they can address 64k of memory max, but 16-bit machines have a much larger address space, which is why the format fell out of use.

In the Intel 8080 CPU architecture, only 65,536 bytes of memory could be addressed (address range 0000h to FFFFh). Under CP/M, the first 256 bytes of this memory, from 0000h to 00FFh were reserved for system use by the zero page, and any user program had to be loaded at exactly 0100h to be executed.[nb 1] COM files fit this model perfectly. Before the introduction of MP/M and Concurrent CP/M, there was no possibility of running more than one program or command at a time: the program loaded at 0100h was run, and no other.

Although the file format is the same in DOS and CP/M, .COM files for the two operating systems are not compatible; DOS COM files contain x86 instructions and possibly DOS system calls, while CP/M COM files contain 8080 instructions and CP/M system calls (programs restricted to certain machines could also contain additional instructions for 8085 or Z80).

.COM files in DOS set all x86 segment registers to the same value and the SP (stack pointer) register to the offset of the last word available in the first 64 KB segment (typically FFFEh) or the maximum size of memory available in the block the program is loaded into for both, the program plus at least 256 bytes stack, whatever is smaller, thus the stack begins at the very top of the corresponding memory segment and works down from there.[3][4]

In the original DOS 1.x API, which was a derivative of the CP/M API, program termination of a .COM file would be performed by calling the INT 20h (Terminate Program) function or else INT 21h Function 0, which served the same purpose, and the programmer also had to ensure that the code and data segment registers contained the same value at program termination to avoid a potential system crash. Although this could be used in any DOS version, Microsoft recommended the use of INT 21h Function 4Ch for program termination from DOS 2.x onward, which did not require the data and code segment to be set to the same value.

It is possible to make a .COM file to run under both operating systems in form of a fat binary. There is no true compatibility at the instruction level; the instructions at the entry point are chosen to be equal in functionality but different in both operating systems, and make program execution jump to the section for the operating system in use. It is basically two different programs with the same functionality in a single file, preceded by code selecting the one to use.

Under CP/M 3, if the first byte of a COM file is C9h, there is a 256-byte header;[2] since C9h corresponds to the 8080 instruction RET, this means that the COM file will immediately terminate if run on an earlier version of CP/M that does not support this extension. (Because the instruction sets of the 8085 and Z80 are supersets of the 8080 instruction set, this works on all three processors.) C9h is an invalid opcode on the 8088/8086, and it will cause a processor-generated interrupt 6 exception in v86 mode on the 386 and later x86 chips. Since C9h is the opcode for LEAVE since the 80188/80186 and therefore not used as the first instruction in a valid program, the executable loader in some versions of DOS rejects COM files that start with C9h, avoiding a crash.

Files may have names ending in .COM, but not be in the simple format described above; this is indicated by a magic number at the start of the file. For example, the COMMAND.COM file in DR DOS 6.0 is actually in DOS executable format, indicated by the first two bytes being MZ (4Dh 5Ah), the initials of Mark Zbikowski.

Large programs

Under DOS there is no memory management provided for COM files by the loader or execution environment. All memory is simply available to the COM file. After execution, the operating system command shell, COMMAND.COM, is reloaded. This leaves the possibilities that the COM file can either be very simple, using a single segment, or arbitrarily complex, providing its own memory management system. An example of a complex program is COMMAND.COM, the DOS shell, which provided a loader to load other COM or EXE programs. In the .COM system, larger programs (up to the available memory size) can be loaded and run, but the system loader assumes that all code and data is in the first segment, and it is up to the .COM program to provide any further organization. Programs larger than available memory, or large data segments, can be handled by dynamic linking, if the necessary code is included in the .COM program. The advantage of using the .COM rather than .EXE format is that the binary image is usually smaller and easier to program using an assembler.[5] Once compilers and linkers of sufficient power became available, it was no longer advantageous to use the .COM format for complex programs.

Platform support

The format is still executable on many modern Windows NT-based platforms, but it is run in an MS-DOS-emulating subsystem, NTVDM, which is not present in 64-bit variants. COM files can be executed also on DOS emulators such as DOSBox, on any platform supported by these emulators.

Use for compatibility reasons

Windows NT-based operating systems use the .com extension for a small number of commands carried over from MS-DOS days although they are in fact presently implemented as .exe files. The operating system will recognize the .exe file header and execute them correctly despite their technically incorrect .com extension. (In fact any .exe file can be renamed .com and still execute correctly.) The use of the original .com extensions for these commands ensures compatibility with older DOS batch files that may refer to them with their full original filenames. These commands are CHCP, DISKCOMP, DISKCOPY, FORMAT, MODE, MORE and TREE.[6]

Execution preference

In DOS, if a directory contains both a COM file and an EXE file with same name, when no extension is specified the COM file is preferentially selected for execution. For example, if a directory in the system path contains two files named foo.com and foo.exe, the following would execute foo.com:

C:\>foo

A user wishing to run foo.exe can explicitly use the complete filename:

C:\>foo.exe

Taking advantage of this default behaviour, virus writers and other malicious programmers have used names like notepad.com for their creations, hoping that if it is placed in the same directory as the corresponding EXE file, a command or batch file may accidentally trigger their program instead of the text editor notepad.exe. Again, these .com files may in fact contain a .exe format executable.

On Windows NT and derivatives (Windows 2000, Windows XP, Windows Vista, and Windows 7), the PATHEXT variable is used to override the order of preference (and acceptable extensions) for calling files without specifying the extension from the command line. The default value still places .com files before .exe files. This closely resembles a feature previously found in JP Software's line of extended command line processors 4DOS, 4OS2, and 4NT.

Malicious usage of the .com extension

Some computer virus writers have hoped to take advantage of modern computer users' likely lack of knowledge of the .com file extension and associated binary format, along with their more likely familiarity with the .com Internet domain name. E-mails have been sent with attachment names similar to "www.example.com". Unwary Microsoft Windows users clicking on such an attachment would expect to begin browsing a site named http://www.example.com/, but instead would run the attached binary command file named www.example, giving it full permission to do to their machine whatever its author had in mind.[citation needed]

There is nothing malicious about the COM file format itself; this is an exploitation of the coincidental name collision between .com command files and .com commercial web sites.

See also

Notes

  1. ^ a b In most versions of CP/M, the start of the TPA was at offset +100h, only preceded in memory by the zero page at offset +0h. Some versions differed for hardware reasons including CP/M for the Heath H89, where it started at offset +4300h (for compatibility, a Magnolia Microsystems hardware modification existed to map out the ROMs at +100h after startup), or CP/M for the TRS-80 Model I and TRS-80 Model III, where programs were loaded at offset +0h.

References

  1. ^ Christian, Brian; Markson, Tom; Skrenta, Rich (eds.). "Section 5.3". The PDP-11 How-To Book (Revision 1 ed.). Archived from the original on 2018-08-01. Retrieved 2018-08-01. (NB. Has a reference for the RT-11 operating system running on the PDP-11 minicomputer, which shows in section 5.3 that .COM is used to refer to a command file.)
  2. ^ a b Elliott, John C.; Lopushinsky, Jim (2002) [1998-04-11]. "CP/M 3 COM file header". Seasip.info. Archived from the original on 2018-08-01.
  3. ^ Paul, Matthias R. (2002-10-07) [2000]. "Re: Run a COM file". Newsgroupalt.msdos.programmer. Archived from the original on 2017-09-03. Retrieved 2017-09-03. [1] (NB. Has details on the DOS COM program calling conventions.)
  4. ^ Lunt, Benjamin "Ben" D. (2020). "DOS .COM startup registers". Forever Young Software. Archived from the original on 2020-11-12. Retrieved 2021-12-14.
  5. ^ Scanlon, Leo J. (1991). "Chapter 2". Assembly Language Subroutines for MS-DOS (2 ed.). Windcrest Books. p. 16. ISBN 0-8306-7649-X.
  6. ^ "Windows Commands". Microsoft. 2023-04-26.

Read other articles:

  لمعانٍ أخرى، طالع شجرة الدر (توضيح). شجرة الدرمعلومات عامةالصنف الفني تاريخيتاريخ الصدور 26 فبراير 1935مدة العرض 125 دقيقةاللغة الأصلية اللغة العربيةالعرض أبيض وأسود البلد  المملكة المصريةموقع التصوير القاهرةالطاقمالمخرج أحمد جلالالقصة أحمد جلالالبطولة آسيا داغرما

 

 

Mapo tahuSepiring mapo tahuTempat asalTiongkokDaerahSichuanBahan utamatahu, douban, (campuran fermentasi kacang polong dan pasta cabai), dan douchi (kacang hitam yang difermentasi), daging cincang Cookbook: Mapo tahu  Media: Mapo tahu Mapo tahu Mapo doufu dalam karakter Hanzhi Hanzi: 麻婆豆腐 Pinyin: mápó dòufu Makna harfiah: tahu buatan nenek bopeng Alih aksara Mandarin - Hanyu Pinyin: mápó dòufu - Tongyong Pinyin: mápó dòufů - Wade-Giles: ma2-pʻo2 tou4-fu - Romanisas...

 

 

Aeropuerto Internacional de Baréin IATA: BAH OACI: OBBI FAA: LocalizaciónUbicación Al Muharraq, Gobernación de Muharraq, Baréin, BaréinElevación 2Sirve a Manama, Gobernación Capital, BaréinDetalles del aeropuertoTipo CivilOperador Aviación CivilPistas DirecciónLargoSuperficie12L/30R3.956Asfalto12R/30L2.530AsfaltoSitio web BahrainAirport.com[editar datos en Wikidata] El Aeropuerto Internacional de Baréin (IATA: BAH, OACI: OBBI) (en árabe مطار البحرين الد

United States historic placeJenks Park & Cogswell TowerU.S. National Register of Historic PlacesU.S. Historic district Cogswell TowerShow map of Rhode IslandShow map of the United StatesLocationCentral Falls, Rhode IslandCoordinates41°53′15″N 71°23′21″W / 41.88750°N 71.38917°W / 41.88750; -71.38917Area5 acres (2.0 ha)Built1890ArchitectHumes, Albert H.MPSCentral Falls MRA (AD)NRHP reference No.79000057[1]Added to NRHPApril 6, 1979 ...

 

 

Esta página cita fontes, mas que não cobrem todo o conteúdo. Ajude a inserir referências. Conteúdo não verificável pode ser removido.—Encontre fontes: ABW  • CAPES  • Google (N • L • A) (Outubro de 2023) Campeonato Rondoniense de Futebol de 2021 Rondoniense 2021 Dados Participantes 8[1] Organização FFER Anfitrião Rondônia Período 24 de abril – 14 de julho Gol(o)s 54 Partidas 24 Média 2,25 gol(o)s por partida Campe...

 

 

بوغدانوفيتش    علم شعار الإحداثيات 56°47′00″N 62°03′00″E / 56.783333333333°N 62.05°E / 56.783333333333; 62.05  تاريخ التأسيس 1885  تقسيم إداري  البلد روسيا الإمبراطورية الروسية الاتحاد السوفيتي[1]  التقسيم الأعلى أوبلاست سفردلوفسك (–31 ديسمبر 2005)  خصائص جغرافية  ا

Hélène Boucher als Pilotin (1933) Hélène Boucher (* 23. Mai 1908 in Versailles; † 30. November 1934 in Guyancourt bei Versailles) war eine frühe französische Pilotin, die zu Lebzeiten oft die „schnellste Frau der Welt“ genannt wurde.[1] Inhaltsverzeichnis 1 Rekorde 2 Leben 3 Adaptionen 4 Literatur 5 Weblinks 6 Einzelnachweise Rekorde 1933 stellte sie in einem 95-PS-Eindecker mit 6.100 m einen neuen Höhenweltrekord für Frauen auf.[2] Im August 1934 stellte si...

 

 

Stasiun Furusan古山駅Gedung Stasiun pada April 2005LokasiYuni, HokkaidoJapanPengelola JR HokkaidoJalur■ Muroran Main LineLetak dari pangkal182.2 km from OshamambeJumlah peron2 side platformsJumlah jalur2Informasi lainStatusUnstaffedSejarahDibuka25 September 1943 (1943-09-25)Lokasi pada petaStasiun FurusanLokasi di JepangSunting kotak info • L • BBantuan penggunaan templat ini Stasiun Furusan (古 山 駅, Furusan-eki) adalah stasiun kereta api di Jalur Utama Muroran di...

 

 

German record label Not to be confused with the French black metal label Drakkar Productions. This article does not cite any sources. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: Drakkar Entertainment – news · newspapers · books · scholar · JSTOR (May 2015) (Learn how and when to remove this template message) Drakkar EntertainmentFounded1986FounderBogdan KopecDi...

Spanish general (1791–1831) This article needs additional citations for verification. Please help improve this article by adding citations to reliable sources. Unsourced material may be challenged and removed.Find sources: José María de Torrijos y Uriarte – news · newspapers · books · scholar · JSTOR (February 2017) (Learn how and when to remove this template message) José María de Torrijos y UriarteJosé María Torrijos in a portrait by Ángel S...

 

 

Wabaseemoong Independent Nations or more fully as the Wabaseemoong Independent Nations of One Man Lake, Swan Lake and Whitedog, is an Ojibway First Nation band government who reside 120 km northwest of Kenora, Ontario and 13 kilometres (8.1 mi) east of the Ontario-Manitoba border of northwestern Ontario, Canada. As of December 2018, the First Nation had a population of 2,000 registered people, of which their on-Reserve population was 1200 registered members and approximately 100 non...

 

 

American science fiction and fantasy writer (1918–2009) Philip José FarmerPhilip José FarmerBorn(1918-01-26)January 26, 1918North Terre Haute, Indiana, U.S.DiedFebruary 25, 2009(2009-02-25) (aged 91)Peoria, Illinois, U.S.Pen namemore than a dozen[1] (below)OccupationNovelist, short story writerAlma materPeoria High SchoolBradley UniversityPeriodc. 1952–2009GenreFantasy, science fictionSpouse Bette V. Andre ​(m. 1941)​Children2Websitew...

American bassist This biography of a living person needs additional citations for verification. Please help by adding reliable sources. Contentious material about living persons that is unsourced or poorly sourced must be removed immediately from the article and its talk page, especially if potentially libelous.Find sources: Mark Andes – news · newspapers · books · scholar · JSTOR (March 2016) (Learn how and when to remove this template message) Mark A...

 

 

Ця стаття не містить посилань на джерела. Ви можете допомогти поліпшити цю статтю, додавши посилання на надійні (авторитетні) джерела. Матеріал без джерел може бути піддано сумніву та вилучено. (липень 2018) Виробни́чий план — це система адресних завдань по випуску про...

 

 

Hadiah Pulitzer Joseph Pulitzer    •    Pulitzer menurut tahunPemenang Pulitzer Jurnalisme: Pelayanan Umum Liputan Wartasemerta Liputan Investigasi Liputan Penjelas Liputan Lokal Liputan Nasional Liputan Internasional Tulisan Khusus Komentar Kritik Tulisan Editorial Kartun Editorial Fotografi (1942–1967) Fotografi Berita Langsung (1968–1999) Fotografi Wartasemerta (2000–sekarang) Fotografi Khusus (1968–sekarang) Sastra dan drama: Biografi atau Autobiografi Fi...

Chung-in MoonGambar Chung-in Moon di konferensi CogitAsia pada 29 Juni 2015LahirTanggal tidak terbaca. Angka tahun harus memiliki 4 digit (gunakan awalan nol untuk tahun < 1000).Cheju, Korea SelatanWarga negaraKoreaAlmamaterUniversitas YonseiUniversitas MarylandKarier ilmiahBidangIlmu politikHubungan internasionalPolitik dan ekonomi politik KoreaPolitik internasional Asia TimurInstitusiUniversitas YonseiUniversity of California, San DiegoDuke University Chung-in Moon (lahir 25 Maret 1951) ...

 

 

1957 stage musical by Meredith Willson This article is about the stage musical. For the 1962 film adaptation, see The Music Man (1962 film). For the 2003 made-for-television adaptation, see The Music Man (2003 film). For other uses, see Music Man. The Music ManOriginal Broadway posterMusicMeredith WillsonLyricsMeredith WillsonBookMeredith Willson Franklin LaceyProductions1957 Broadway 1961 West End 2000 Broadway revival 2022 Broadway revivalAwardsTony Award for Best Musical The Music Man is a...

 

 

Candi BrahuCandi Brahu, tersusun dari batu bata merah.Galat Lua: .Informasi umumGaya arsitekturCandi Jawa TimurKotadekat Mojokerto, Jawa TimurNegara IndonesiaRampungabad ke-15KlienMajapahitData teknisUkuran22,5m x 18 m Candi Brahu (Hanacaraka: ꦕꦤ꧀ꦢꦶꦧꦿꦲꦸ) merupakan salah satu candi yang terletak di dalam kawasan situs arkeologi Trowulan, bekas ibu kota Majapahit. Tepatnya, candi ini berada di Dukuh Jambu Mente, Desa Bejijong, Kecamatan Trowulan, Kabupaten Mojokerto, Jawa...

Several comic book series by Marvel Comics For other uses, see Venom (disambiguation). This article needs to be updated. The reason given is: The article does not include info about the 2016, 2018 and 2021 comic books and the Venomverse and Venomized events. Please help update this article to reflect recent events or newly available information. (April 2018) VenomThe cover of Venom: Lethal Protector #1, February 1993. The first Venom solo comic. Art by Mark Bagley.Publication informationPubli...

 

 

Pour la fête du cinéma au Liban, voir Fête du cinéma (Liban). Les acteurs Géraldine Nakache, Fred Testot, Ana Girardot, Jérémie Elkaïm et Baptiste Lecaplain à Paris lors de l'ouverture de la fête du cinéma 2013. La Fête du cinéma est une opération de promotion du cinéma ayant lieu chaque année en France, généralement au mois de juin, depuis 1985. Jusqu'en 1992, l'opération a une durée d'un jour. Elle se tient de 1993 à 2008 sur trois jours, du dimanche au mardi. De 2009 ...

 

 

Strategi Solo vs Squad di Free Fire: Cara Menang Mudah!