Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cwjcc!gatech!hubcap!ncrcae!ncr-sd!hp-sdd!megatek!spot!hollen From: hollen@spot.megatek.uucp (Dion Hollenbeck) Newsgroups: comp.sys.ibm.pc Subject: Re: EXE And COM files Message-ID: <437@megatek.UUCP> Date: 20 Dec 88 15:40:53 GMT References: <7386@watcgl.waterloo.edu> Sender: news@megatek.UUCP Lines: 37 From article <7386@watcgl.waterloo.edu>, by smvorkoetter@watmum.waterloo.edu (Stefan M. Vorkoetter): > In article <6078@hoptoad.uucp> pozar@hoptoad.UUCP (Tim Pozar) writes: > >In article <250@shockeye.UUCP> hermit@shockeye.UUCP (Mark Buda) writes: > >>I'm not sure if I know what I'm talking about, but a COM file doesn't have > >>a format. It is just an image of the program, whose entry point must be at > >>an offset of zero. > > > > Not quite. .COM programmes start at an offset of 100h. > > Tim > > Well, they are loaded at an offset of 100h in the code segment, but they > start at an offset of zero in the FILE. And the entry point is right at > the beginning. > > Stefan Vorkoetter > (smvorkoetter@watmum) Everybody above is mostly right. To clear things up, the assembly source which generates a .COM program must ORG the first instruction at 100H. This means that an absolute JMP instruction to the second instruction of the code (assuming the first is 3 bytes long) would be JMP 103H. Yes, the beginning of the file (offset 0) is the beginning of the code. Also, a .COM program can have only one segment in which the CODE, DATA and STACK are all kept. If the program knows about unused memory, it can change around the segments once it starts running (like moving the stack). Com programs load faster because the loader does not have to resolve addresses when it is laying down the memory image of the program since everything is in one segment and all references are single segment relative. Also, at the beginning of the program, the loader initializes all the segment registers to one value. Dion Hollenbeck (619) 455-5590 x2814 Megatek Corporation, 9645 Scranton Road, San Diego, CA 92121 seismo!s3sun!megatek!hollen ames!scubed/