Партнерка на США и Канаду по недвижимости, выплаты в крипто
- 30% recurring commission
- Выплаты в USDT
- Вывод каждую неделю
- Комиссия до 5 лет за каждого referral
- the second letter designates a flag, or symbol of negation “n”, after which follows the name of flag.
If there is no symbol “n” after “j”, then the state of flag is checked, and if it is equal to 1, then the jump on the pointed label is executed. If the symbol “n” is present, then it is checked the flag’s equality to 0, and if the meaning of the flag is 0, then the jump is executed.
Table.
Name of Flag | Instruction | Meaning of Flag |
Carry Flag(cf) | jc | cf = 1 |
Parity Flag(pf) | jp | pf = 1 |
Zero Flag(zf) | jz | zf =1 |
Sign Flag(sf) | js | sf = 1 |
Overflow Flag(of) | jo | of = 1 |
cf | jnc | cf = 0 |
pf | jnp | pf = 0 |
zf | jnz | zf = 0 |
sf | jns | sf = 0 |
of | jno | of = 0 |
Instructions of Conditional Jumps and Register CX.
The register CX has got a special functional predestination: it executes a role of counter in instructions of loops control and in a work with chains of symbols.
The syntax of instruction of conditional jump with using the register CX is the following:
jcxz label_of_jump (Jump if CX is Zero)
It may be used only for short type of jumps.
Organization of Loops.
The instruction of loop has the following syntax:
loop label_of_jump
the work of this program consists in the performance of the next actions:
§ decrement of the CX register;
§ comparison the of CX’s meaning with 0:
° if CX > 0, then the control is handed over to the label of jump;
° if CX = 0, then the control is handed over to the next (after the loop) instruction.
This instruction can realize only short jumps.
Procedures. Syntax of procedures description in a program.
Procedures. Syntax of procedures description in a program.
Procedure (subroutine) is the general functional unity of decomposition (division on several parts) of some problem. It may be considered as a group of instructions, which is intended for the solution of certain subproblem and has an ability to get a control starting from the point of this subroutine call, which is located in the main (high level) program, and an ability to return the control in this (the same) point. This procedure may be called, if it is necessary, from any point of the main program.
There are two directives for the description procedures in assembly: PROC and ENDP.
|
Name_of_Procedure PROC [modifier] [distance]
[ARG list_of_arguments]
[RETURNS list_of_arguments]
[LOCAL list_of_arguments]
[USES list_of_registers]
![]() |
Instructions,
Directives
………………………….
|
[Name_of_Procedure] ENDP
The main attention must be paid to the operand distance of the directive PROC. This attribute may have meanings near and far (on default it has a meaning near).
Allocation Procedures in Program.
A procedure may be allocated in any place in a program, but with an account, that a control can not be handed over to it by chance. The following variants of procedure allocation inside a program are possible:
° at the beginning of program (before the first executed instruction);
Example:
model small
.stack 100h
.data
……..
.code
primer1 PROC near
………
ret
primer1 ENDP
start:
…….
end start
° at the end of program (after the instruction, which returns control to the operational system).
Direct near and direct far calls of procedures.
There is an important property, which it is possible to use thanks to a special mechanism of procedures calls. The essence of this mechanism consists in a possibility to save information, which concerns with the context of the program at the point of the procedure call. (Under the context it is meant an information on the program state at the point of the procedure call; there are two instructions in the microprocessor’s system of instructions, which realize the work with a context, namely call and ret.
These instructions have the following syntax:
call [modifier] name_of_procedure. This instruction hands over control on address with a symbolic name “name_of_procedure”, but in the stack is stored an address of return to the instruction, which is placed after the instruction call.
ret [number] .This instruction reads an address of return from the stack and loads it into the registers CS and IP. [number] is not a compulsory parameter, which designates a quantity(number) of elements, which should be taken off from the stack after the return from the procedure.
For the instruction call a problem of organizing near and far operations is actual. It is clear from the format of the instruction, where [modifier] is present.
A call of a procedure may be:
· near (internal), if the procedure is in the current code segment, and in this case the address of return is a contents of the IP register only;
· far (intersegment), if the procedure is in the other code segment, and for the return it is necessary to use the contents of registers IP and CS. The order of their location in the stack is the following: at first the contents of CS is placed, and after it follows the contents of IP.
Indirect near and direct far calls of procedures.
There are two types of indirect calls of procedures:
· indirect near (within the limits of current segment through the cell, which contains an address of the called subroutine starting point);
· indirect far (in the other segment of given program through the cell, which contains an address of the called subroutine starting point).
Notion of macro-means in the assembly and their predestination.
In general, the assembly translator consists from two parts: the first is a translator itself, and the second is a macro-assembler. The processing of a program in assembly includes two phases. At the first phase the macro-assembly works, which executes so called before-processor’s processing; the main idea of the “before-processor’s processing” consists in using stuffing (подстановка), which substitute by a special manner one symbolic sequence by the other one (this sequence may be a sequence of instructions or sequence of data as well). What is more important here: the input text as a rule is written in a language which differs considerably from assembly (this language is often called the macro-language), but the output text is in the assembly compulsory. At the second phase works the translator itself, which forms an object code (the object code contains the text of the initial program in a machinery type).
Objects, which are carried out with help of the macro-language are usually called macroses. Using of macroses simplifies (automates) the input of program’s text, visualizes program’s text. Sometimes, for example, when directives of conditional translations are used, macroses complicate the initial text. We will consider only the main means of macro-assembly language.
Blocks of Repetition and its description.
Blocks of repetition compel the translator to repeat the given fragment of initial text the pointed number of times. This fragment may contain directives of data description (in this case it is included in a data segment), or it may contain instructions (in this case it must be placed in a code segment).
Macroinstructions.
Macroinstructions may be considered as a further development of mechanism of text substitution (stuffing). The repeated parts of text may be represented in a form of macroinstructions.
Macroinstruction is a string, which contains some symbolic name (name of macroinstruction), and which is to be substituted by one or by several other strings. This name may be accompanied by parameters.
If a programmer hasn’t got already prepared variant of necessary macroinstructions, then it is necessary to set its picture-description, which is also called a macrodefinition. The syntax of macrodefinition is the next:
Name_of_macroinstruction macro List_of_formal_arguments
Body of macrodefinition
endm
There are three variants of placing macrodefinitions inside a program:
· at the beginning of the initial text of the program; this variant it is recommendable to use, when it is actual only within the limits of the given program;
· in a separate file; this variant is recommendable, when it is actual within the limits of several programs, and in order to make this macrodefinition accessible in the given program, it is necessary at the beginning of the initial text of the program to write a directive
include Name_of_file,
for example:
masm
model small
include Primer. inc
;Here will be placed the text of file Primer. inc
……………………….
· in a macrolibrary; if the used macroinstruction has got a universal character, then it is reasonable to include it in so called macrolibrary. To make macroinstructions accessible from the current program it is possible by using the same directive include. A disadvantage of this method consists in including all macrodefinitions in the initial text, but it is possible to exclude some macrodefinitions by using a directive purge (очистить), with operands, which should be excluded from the text.
Functionally macroinstructions look like procedures, but there are essential differences between them:
° text of procedures can not be changed (text of macroinstructions may be changed in correspondence with the parameters, which have been pointed out);
° text of macroinstructions is always inputted inside the program in a form of macroextension and may be considered as program’s one (the control in this case is not handed over).
Macrodefinitions are processed by the compiler. In order to use the described macrodefinition in a concrete place of the program, it must be activated with help of macroinstructions by using the following syntax construction:
Name_of_macroinstructions List_of_actual_arguments
The result of this syntax construction will be substitution of this string by strings from the body of macroinstructions, in which formal arguments will be substituted by actual ones. The process of such substitution is called macrogeneration, and the result of this process is called macroextension. Let’s consider a simple example:
If it is necessary to save in the program contents of three different registers many times, then it is possible to describe these actions with help of macrodefinition:
psh macro a, b,c
push a
push b
push c
endm
When in the program will appear, for example, a string
psh AX, BX, CX
the following fragment of text will be generated:
push AX
push BX
push CX
|
Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6 |



