runtime_program_structure.ppt

Upload: mb4u

Post on 03-Apr-2018

220 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/28/2019 Runtime_Program_Structure.ppt

    1/6

    Runtime 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.

  • 7/28/2019 Runtime_Program_Structure.ppt

    2/6

    Procedure for Command Typed at

    Prompt

    1. Is command internal (DIR, REN, or ERASE)? if so,immediately execute by a memory-resident MS-DOSroutine.

    2. Is there a matching file with extension of COM? if fileis in current directory, it is executed.

    3. Is there a matching file with extension of EXE? If file isin current directory, it is executed.

    4. Is there a matching file with extension of BAT? -If file isin current directory, it is executed. BAT are batch filesa text file containing MS_DOS commands to beexecuted as if commands were typed at the console.

    5. If no COM, EXE, or BAT file in the current directory, firstdirectory in current path is searched. If not found,proceeds to next directory in path. Continues until file is

    found or search is exhausted.

  • 7/28/2019 Runtime_Program_Structure.ppt

    3/6

    Transient Programs

    (COM and EXE programs)

    Application programs with extensions ofCOM and EXE are called transientprograms.

    Generally, loaded into memory longenough to be executed; then the memorythey occupy is released.

    Can leave a portion of their code in menrywhen they exit; these are called memory-resident programs.

  • 7/28/2019 Runtime_Program_Structure.ppt

    4/6

    Program Segment Prefix (PSP)

    A special 256-byte block at the beginning of a a

    program as it is loaded into memory

    Offset Comments

    00-15 MS-DOS pointers and vector addresses

    16-2B Reserved by MS-DOS

    2C-2D Segment address of the current environment string

    2E-5B Reserved by MS-DOS

    5C-7FFile Control Blocks 1 and 2, used mainly by pre-MS-DOS 2.0

    programs

    80-FF Default disk transfer area and a copy of the current MS_DOScommand tail

  • 7/28/2019 Runtime_Program_Structure.ppt

    5/6

    COM 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 FFFE

    CODE

    CS,DS,ES,SS SP

    PSP DATA------------------------------------------STACK

  • 7/28/2019 Runtime_Program_Structure.ppt

    6/6

    EXE Programs

    Stored on Disk with an EXE header followed bya load module containing program.

    Header is not loaded into memory; insteadcontains 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 programs load address.

    CS and IP set to entry point of code, SS set tobeginning of stack segment, SP set to stacksize.