АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника
Structure of Programs in Assembly.
An access to the main memory is executed only through segments (logical formations overlaid any area of physical address space). The initial address of the segment without junior hexadecimal digit is inputted into the one of the segment registers. After it we get an access to the memory area, which begins from the given segment.
How is the notion of memory segments reflected on the programs structure? If an access to the memory is possible only through the segments, it is obvious, that these segments must be described in the program. Each description concerns certain segment. So, a program contains as many descriptions as many segments are to be used during it execution. So, a program has got a segment structure.
It should be added, that a program structure is also determined by specificity of the operational system and regulations of the selected translator.
Let’s consider an example of a program with a segment structure. In order the program will be efficient (have got a capacity for work) it must contain some additional elements, which will be explained later (such elements here, for example, are: calls of DOS functions, using stack and some other).
Text of any program includes key words, which may be divided into: instructions(commands) of processor and directives(pseudo-instructions) of translator.
Instructions(commands) are such expressions, which determine concrete operations to be executed by the computer (each instruction determines only one operation) and their (its) operands.
Directives(pseudo-instructions) are intended for the transfer of service information to the translator, which is necessary during the process of the program assembling. Let’s consider the text of the program-example on the whole:
A simple program with three segments
At first point out correspondence of segment registers to segments
Now describe the code segment
Code segment ;Open the code segment
Begin: mov AX,data ;Tune DS
Mov DS,AX ;on the data segment
Input on the screen a string of the text
Mov AH,09h ;The DOS function of input on the screen
Mov DX,offset msg ;Address of the input string
Int 21h ;Call of DOS
Complete the program
Mov AX,4C00h ;DOS function of the program completion
Int 21h ;Call of DOS
Code ends ;Close the code segment
Describe data segment
Data segment ;Open data segment
Msg db "The program is working !$";The sting to be output
Data ends ;Close the data segment
Describe the stack segment
Stk segment stack ;Open segment stack
Дата добавления: 2015-09-14; просмотров: 4; Нарушение авторских прав