offset length description 0 2 an int 20h instruction is stored here 2 2 program ending address 4 1...

4
.COM programs The .com file can have a maximum size of 64KB. .com program does not contain relocation information, they are more compact and are loaded for execution faster than .EXE programs. The .com programs use only one segment, all jump and call instruction in the .COM will be of NEAR type.

Upload: bertina-carr

Post on 14-Jan-2016

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Offset Length Description 0 2 An INT 20h instruction is stored here 2 2 Program ending address 4 1 Unused, reserved by DOS 5 5 Call to DOS function

.COM programs The .com file can have a maximum size of 64KB. .com program does not contain relocation information, they are more

compact and are loaded for execution faster than .EXE programs. The .com programs use only one segment, all jump and call

instruction in the .COM will be of NEAR type.

Page 2: Offset Length Description 0 2 An INT 20h instruction is stored here 2 2 Program ending address 4 1 Unused, reserved by DOS 5 5 Call to DOS function

.COM Programs

Single 64K-byte Segment Execution Always Begins At Offset 100h IP set to 0100h for initial dispatch .COM-style programs must have their initial instructions

at this location Stack Pointer Initialized to FFFEh stack is constructed backwards (towards the program

code and data) starting from the last even address within the (single) program segment. If the program and data are quite large (within the 64K-byte segment), problems may occur is the stack fills up overtop of instructions or data

.COM programs must be loaded to run within the first Megabyte of memory.

.COM program addresses are not "memory range" checked and .COM programs can access and modify any (RAM) portion of the first Megabyte of memory (including the Operating System and its tables.

Page 3: Offset Length Description 0 2 An INT 20h instruction is stored here 2 2 Program ending address 4 1 Unused, reserved by DOS 5 5 Call to DOS function

.EXE Programs Multiple Segments

DS and ES registers initially point to the PSP.CS initially points to the first segment containing instructions within the program code.

SS initially points to the first "stack" segment within the program code. At least one segment should be identified (with the STACK option) as being a data area for the stack.

Initial Execution Offset

Execution normally starts with the IP set to 0000, at the first instruction of the (first) code segment. However, the actual offset is determined by a label reference on the END statement which marks the end of the source program.

Initial Stack Pointer

The SP register is set to the length of the supplied "stack" segment.

Page 4: Offset Length Description 0 2 An INT 20h instruction is stored here 2 2 Program ending address 4 1 Unused, reserved by DOS 5 5 Call to DOS function

PSP (Program Segment Prefix) The PSP structure, which is 256 bytes long (100h

bytes, in hexadecimal ,contains the command-line parametersOffset Length Description

0 2 An INT 20h instruction is stored here2 2 Program ending address4 1 Unused, reserved by DOS5 5 Call to DOS function dispatcher0Ah 4 Address of program termination code0Eh 4 Address of break handler routine12h 4 Address of critical error handler routine16h 22 Reserved for use by DOS2Ch 2 Segment address of environment area2Eh 34 Reserved by DOS50h 3 INT 21h, RETF instructions53h 9 Reserved by DOS5Ch 16 Default FCB #16Ch 20 Default FCB #280h 1 Length of command line string81h 127 Command line string