The role and workflow of the online command interpreter

Source: Internet
Author: User

The main function of the command interpreter is to interpret the commands entered by the user and then go to the handler of the corresponding command to execute them. Operating systems typically place command interpreters at the top of the OS to enable direct interaction with the user.

1. Role of the Order interpretation procedure

The keyboard terminal handler receives commands that the user enters from the keyboard and saves them in the keyboard buffer. Then the command interpreter reads the command, identifies it, goes to the entry address of the corresponding command handler, gives control to the handler to execute, and then sends the processing results to the screen. If a user enters a command, the command interpreter fails to recognize it, or if there is a problem in the middle of the execution, an error message should be displayed.

2. Composition of the Order interpretation procedure

In the early 1980s, Microsoft developed the operating system of MS-dos for configuration in microcomputer. With the development of microcomputers, the MS-DOS version is also upgraded from the beginning version 1.0 to the 6.x version. In the meantime, it has become the de facto standard for 16-bit microcomputer operating systems. The following is an example of the Command.com handler in the MS-DOS operating system to illustrate the composition of the command interpreter. It consists of the following 3 parts.

(1) Resident part. This part of the program is resident in memory, usually some interrupt service subroutine. For example, the normal exit interrupt INT20, which is used to return the operating system after the user program has finished executing, resides in the exit interrupt INT27, in which case the return program resides in memory, and INT24 for handling and displaying standard error messages. The resident part also includes a program that, when the user program terminates, checks whether the staging part has been 蒗 by the user program, and if it is overwritten, the staging part is redeployed into memory.

(2) Initialization section. It follows the resident memory portion, gaining control at startup. This section also includes a handler for the Autoexec.bat and determines the starting address of the application mount. The Autoexec.bat file is found and executed by the handler every time the system restarts. Because the file is no longer needed after it is used, it will be overwritten by the first file loaded by Command.com.

(3) Temporary part. This section is primarily a command interpreter, and includes all internal command handlers, batch file handlers, and procedures for loading and executing external commands. They all reside in memory, but the user program can use and overwrite this part of memory, and at the end of the user program, the resident program 乂 them back into memory from the disk and restores the staging section.

3. Workflow of an Order interpreter

After the system is plugged in or reset, the initialization part obtains the control right, completes the initialization work to the whole system, and automatically executes the Autoexec.bat file, then puts the control power to the temporary part. The staging section first reads the commands in the keyboard buffer to determine if the file name, extension, and drive name are correct. If it is found to be wrong, return it after giving an error message, and then recognize the command if there is nothing wrong with it. A simple way to identify commands is based on a table in which each table is made up of the command name and the entry address of its handler.

If the staging section finds the input command in the table and is an internal command, you can obtain the entry address of the command handler directly from the corresponding table entry, and then give control to the handler to execute the command. If you find that the entered command is not an internal command but an external command, the staging section must also establish a command line for it, and then execute the system call exec to load the command handler and get its base address, and then give control to the program to execute the appropriate command. The following illustration shows the workflow for MS-DOS Command.com.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.