АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника

Indirect near (internal) jump.

Читайте также:
  1. B) Retell the text in indirect speech.
  2. Ex 14 Change the following sentences into Indirect Speech following the examples. Notice the changes in the pronouns.
  3. V. Retell Text В in indirect speech using new words and word combinations.

Unlike the instructions of direct jumps, the instructions of indirect jumps allow to use different modes of addressing and have got different variants. The common feature of this type of instructions consists in using addresses which are not pointed in a direct form (with help of label), but are contained or in a memory cell, or in one of the registers. It allows to modify an address of jump, and to execute the jump in accordance with the known absolute (physical) address. Let’s consider an example, when an address is in the data segment. If the jump is near, then the cell with the address consists from a word and contains only the offset (displacement) to the point of jump:

code segment


jmp DS:go_addr ; Code FF 26 dddd


go: ; The point of jump (label)


code ands

data segment


go_addr dw go ; The address of jump (word)


data ends

From this example it is not possible to see the advantages of the indirect type of jumps. The advantages of this jump will be more evident, if the cell go_addr is empty at first, but during the program execution, subject to some conditions, an address of one or the other point of jump will be put in it:

mov go_addr, offset go1

mov go_addr, offset go2


mov go_addr offset gon

In this situation there is a possibility to calculate or to determine exactly an address of jump beforehand in the given conditions.

The assembly permits descriptions of different forms of indirect jumps through the data segment:

jmp DS: go_addr

jmp word ptr go_addr

jmp go_addr

In the first variant it is pointed out through which of segments(which contains the address of jump) it is necessary to address to the cell go_addr. It is important to remember, that in this case it is possible to change the segment, if the cell is addressed through other segments (for example, through ES or CS).

In the second variant it is outlined, that the jump is executed through the cell of size of one word, and, consequently, it is near jump. The descriptor ptr points to the translator, that the jump is near, irrespective of the directive with help of which it has been declared.

And, at last the third, the most simple variant, which looks like the direct jump, but indeed it is indirect one, because the symbolic designation go_addr is a name of data field, but it is not the program'’ label. In this variant it is supposed, that the segment, in which the cell go_addr is located must be addressed through the register DS, though in such situations the substitution of segment is permissible. The type of jump (near or far) is determined by the size of the cell go_addr. But this variant is not always possible. For the correct translation, it is necessary before the moment of processing the sentence

jmp go_addr

to describe the name go_addr. It is possible to realize by means of locating the data segment before the code segment, or to fulfill two-pass translation. The number of passes may be set with help of using key


where # is a designation of passes number. For example, if it is necessary to fulfill two-passes translation, it is necessary to write:

tasm.exe /zi/z/v/m2 myprg.asm, , ,

In the considered examples an address of label was set directly in the instruction of the indirect jump, but it is possible to set an address in one of general purpose (ALU’s) registers: BX, SI or DI. In the previous example instead of indirect memory addressing it is possible to use indirect register addressing:

mov BX, offset go_addr

jmp [BX]

Especially large possibilities the base-index addressing gives, when the pairs of registers [BX][SI] or [BX][DI] are used. This method of addressing is convenient, when we deal with a series of alternative points of jump, the choosing of which depends on certain conditions. In this case in the data segment a special table of jump’s addresses is created (instead of one field with an address). The address of this table is loaded into the base register BX, and the index of this table (which is determined by certain rules) is loaded into DI or SI. Let’s consider an example:

code segment


mov BX, offset go_tbl

mov SI,8


jmp [BX][SI]






code ends

data segment

go_tbl label word

go1_addr dw go1


go8_addr dw go8


data ends

In this example it is not shown how has been calculated the index loaded into SI, but in any real program the meaning of index will depend on results of analysis of concrete operations or some conditions.

Among all types of jumps there exists such type, which, from one point of view may be classified as a direct (because in it the data segment is not used), but from the other point of view, it is indirect, because in the instruction the address of point of jump is used. For example:

mov BX, offset go1

jmp BX

In this case there is a possibility to calculate the address of jump, but there is no possibility to index it.


What do we mean under the “indirect far jump”? Where must be located the label for this type of jump ?

Дата добавления: 2015-09-14; просмотров: 10; Нарушение авторских прав

lektsii.com - Лекции.Ком - 2014-2022 год. (0.01 сек.) Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав
Главная страница Случайная страница Контакты