Runtime Program StructureProcedure for Command Typed at PromptTransient Programs (COM and EXE programs)Program Segment Prefix (PSP)COM ProgramsEXE ProgramsRuntime Program Structure•Command.com program supplied with MS-DOS and Windows (CMD.EXE for 2000 and XP)is called the command processor.•It interprets each command typed at a prompt.Procedure for Command Typed at Prompt1. Is command internal (DIR, REN, or ERASE)? – if so, immediately execute by a memory-resident MS-DOS routine.2. Is there a matching file with extension of COM? – if file is in current directory, it is executed.3. Is there a matching file with extension of EXE? If file is in current directory, it is executed.4. Is there a matching file with extension of BAT? -If file is in current directory, it is executed. BAT are batch files – a text file containing MS_DOS commands to be executed as if commands were typed at the console.5. If no COM, EXE, or BAT file in the current directory, first directory in current path is searched. If not found, proceeds to next directory in path. Continues until file is found or search is exhausted.Transient Programs (COM and EXE programs)•Application programs with extensions of COM and EXE are called transient programs.•Generally, loaded into memory long enough to be executed; then the memory they occupy is released.•Can leave a portion of their code in menry when they exit; these are called memory-resident programs.Program Segment Prefix (PSP)•A special 256-byte block at the beginning of a a program as it is loaded into memoryOffset Comments00-15 MS-DOS pointers and vector addresses16-2B Reserved by MS-DOS2C-2D Segment address of the current environment string2E-5B Reserved by MS-DOS5C-7FFile Control Blocks 1 and 2, used mainly by pre-MS-DOS 2.0 programs80-FFDefault disk transfer area and a copy of the current MS_DOS command tailCOM Programs•Unmodified binary image of a machine-language program.•Loaded into memory by MS_DOS at the lowest available segment address; a PSP is created at offset 0.•Code, data and stack are all stored in the same segment (physical and logical)Uses TINY memory model•Program can be as large as 64k (minus 256 for PSP and 2 bytes at end of stack). 0000 0100 FFFECODE CS,DS,ES,SS SP PSP DATA------------------------------------------STACKEXE Programs•Stored on Disk with an EXE header followed by a load module containing program.•Header is not loaded into memory; instead contains info used by MS_DOS to load and execute the program.•PS is created at first available address, program is placed in memory above it.•DS and ES ared set to program’s load address. CS and IP set to entry point of code, SS set to beginning of stack segment, SP set to stack
View Full Document