Comprising a plurality of program segments

In the previous chapter we mentioned 0: 200 ~ 0: 2FF address space is relatively safe, but this capacity is only 256 bytes of space.
In the operating system space as long as the operating system through the application of it are safe, secure operating system is responsible for allocating space for the program. In the case of the operating system allows, the program can get any number of space.
Time required to obtain space according to the procedure, access to space can be divided into two types:

  1. When the loader is assigned to the program
  2. Apply to the system during program execution

No matter described in the second book
for assembler, if he needs to obtain the required space when loaded, it is necessary to make a statement in the source program for the assembler source is doing in terms of assembler source program a statement of the corresponding segment.

Using data stored in the code segment

This idea is declared data in the code segment. Then the operating system when it is loaded into the memory of the inevitable need to allocate space for these data declared in the code segment. Although this child does not look very elegant.
And for this, we also need to calculate its own location data store.
At the same time, if not the beginning of compilation instructions of the program, then you need to end a statement to explain the beginning of the assembler. To the operating system prompt, tells the operating system, entrance procedures, at a certain label.
In single-tasking operating systems, program execution process executable file is as follows:

  1. By other programs in the program executable file is loaded into memory
  2. Set CS: IP, i.e. inlet is provided in the program (the first instruction to be executed)
  3. End of the run, return

Directive inlet end is described in a program, such end startthat after compiling connector, an inlet end for the program specified by the instruction start (a reference address), is called a converted address entry, storing description information in the executable file. Operating system based on secondary information, set CS: IP.

The data, code, stack into different segments

Why do so. In fact, no matter how, in real memory and there is not much difference, then why the need for the various segments of it.
This is actually in order to meet our human thinking, so that the source code look more elegant and easy to read.
We declare the different segments in the compilation of the source program, are used to store data and code. In fact, after all this in a segment which is loaded into memory and there is not much difference.
We do not need to calculate the address data of the program, the time period can be directly name instead.
Say it again, the segment registers are not able to directly use the amount of direct, segment name does not work, it is necessary to use general-purpose registers to do the transfer.

Write, debug program has multiple segments

cx is the program for the entire length of the assembler source file called machine instruction length of translation, including the data segment
a segment will occupy at least 16 bytes,
the data segment is defined before or after the block does not matter





Guess you like

Origin www.cnblogs.com/freesfu/p/11031129.html