Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Carter P.A.PC assembly language.2005.pdf
Скачиваний:
15
Добавлен:
23.08.2013
Размер:
1.07 Mб
Скачать

2.2. CONTROL STRUCTURES

 

41

 

 

 

 

 

Signed

 

Unsigned

JE

branches if vleft = vright

JE

branches if vleft = vright

JNE

branches if vleft 6= vright

JNE

branches if vleft 6= vright

JL, JNGE

branches if vleft < vright

JB, JNAE

branches if vleft < vright

JLE, JNG

branches if vleft ≤ vright

JBE, JNA

branches if vleft ≤ vright

JG, JNLE

branches if vleft > vright

JA, JNBE

branches if vleft > vright

JGE, JNL

branches if vleft ≥ vright

JAE, JNB

branches if vleft ≥ vright

Table 2.4: Signed and Unsigned Comparison Instructions

to JZ and JNZ, respectively.) Each of the other branch instructions have two synonyms. For example, look at JL (jump less than) and JNGE (jump not greater than or equal to). These are the same instruction because:

x < y = not(x ≥ y)

The unsigned branches use A for above and B for below instead of L and G. Using these new branch instructions, the pseudo-code above can be

translated to assembly much easier.

1

cmp

eax, 5

2

jge

thenblock

3

mov

ebx, 2

4

jmp

next

5thenblock:

6

mov

ebx, 1

7next:

2.2.3The loop instructions

The 80x86 provides several instructions designed to implement for-like loops. Each of these instructions takes a code label as its single operand.

LOOP Decrements ECX, if ECX 6= 0, branches to label

LOOPE, LOOPZ Decrements ECX (FLAGS register is not modified), if ECX 6= 0 and ZF = 1, branches

LOOPNE, LOOPNZ Decrements ECX (FLAGS unchanged), if ECX 6= 0 and ZF = 0, branches

The last two loop instructions are useful for sequential search loops. The following pseudo-code:

Соседние файлы в предмете Электротехника