سيطره 8
سيطره 8
سيطره 8
Lecture 8
8086 Microprocessor
Instruction Set
4. branch Instructions
Mnemonics: Unconditional jump & conditional jump
There are two types of branches or jumps namely conditional and
unconditional branches.
تعليمات القفز
و هناك نوعان من.الغاية من تعليمة القفز هي تعديل طريق تنفيذ التعليمات في البرنامج
في القفز غير المشروط ال يوجد. القفز المشروط و القفز غير المشروط: وهي،تعليمات القفز
أي شروط من أجل حدوث القفز أما في القفز المشروط فإن الحاالت الشرطية الموجودة في
ففي حال تحقق الحاالت،لحظة تنفيذ تعليمة القفز تتخذ القرار فيما إذا سيحدث القفز أم ال
. و إال ُيتابع التنفيذ بالتعليمة التي تلي تعليمة القفز في البرنامج،الشرطية فإنه يتم القفز
Unconditional jump
This is performed by the JMP instruction. Unconditional execution often
involves a transfer of control to the address of an instruction that does not
1
follow the currently executing instruction. Transfer of control may be forward
to execute a new set of instructions, or backward to re-execute the same
steps.
Conditional jump
This is performed by a set of jump instructions j<condition> depending upon
2
the condition. The conditional instructions transfer the control by breaking the
2
sequential flow and they do it by changing the offset value in IP.
8086 Microprocessor
Instruction Set
4. branch Instructions
Mnemonics: Unconditional jump & conditional jump
Unconditional jump
The JMP instruction provides a label name where the flow of control is transferred
immediately. The basic syntax of JMP instruction:
JMP label
To declare a label in your program, just type its name and add ":" to the
end, label can be any character combination but it cannot start with a
number, for example here are 3 legal label definitions:
label1:
label2:
a:
Label can be declared on a separate line or before any other instruction, for
example:
x1:MOV AX, 1
3
x2: MOV AX, 2
8086 Microprocessor
Instruction Set
4. branch Instructions
Mnemonics: Unconditional jump & conditional jump
Unconditional jump
The JMP instruction provides a label name where the flow of control is transferred
immediately.
EXAMPLE
MOV AX, 00 ; Initializing AX to 0
MOV BX, 00 ; Initializing BX to 0
MOV CX, 01 ; Initializing CX to 1
L1:
ADD AX, 01 ; Increment AX
ADD BX, AX ; Add AX to BX
SHL CX, 1 ; shift left CX, this in turn doubles the CX value
JMP L1 ; repeats the statements
4
8086 Microprocessor
Instruction Set
4. branch Instructions
Mnemonics: Unconditional jump & conditional jump
Unconditional jump
Example
org 100h
mov ax, 5 ; set ax to 5.
mov bx, 2 ; set bx to 2.
calc:
add ax, bx ; add bx to ax.
jmp back ; go 'back'.
stop:
ret ; return to operating system.
5
8086 Microprocessor
Instruction Set
4. branch Instructions
Mnemonics: Unconditional jump & conditional jump
Conditional jump
• There are numerous conditional jump instructions, depending upon the condition
and data.
• The flag conditions are checked depending upon the instruction, if
they are true the program control is transferred to the memory
address pointed by the IP register. If the condition is not satisfied,
then the program continues in a sequential manner.
6
8086 Microprocessor
Instruction Set
Table below shows the mnemonics of all the conditional branches instructions.
Instructions Operation Testing Condition
8086 Microprocessor
Instruction Set
8086 Microprocessor
Instruction Set
5. Loop Instructions
Mnemonics: Loop instructions
For example:-
The following code snippet can be used for executing the loop-body 10 times.
MOV CL, 10
L1:
<LOOP-BODY>
DEC CL
JNZ L1
The basic LOOP instruction has the following syntax:
LOOP label
The above code snippet could be written as:
MOV CX,10
L1:
< LOOP-BODY>
Loop L1
10
8086 Microprocessor
Instruction Set
5. Loop Instructions
Mnemonics: Loop instructions
تعليمات الحلقات
و هذه التعليمات يمكن.هناك ثالث تعليمات مصممة بشكل خاص لتحقيق عملية الحلقة
: و هي مبينة في الجدول التالي.استعمالها بدال ً من تعليمات القفز الشرطي
The various LOOP instructions and their functions are listed below.
8086 Microprocessor
Instruction Set
5. Loop Instructions
Mnemonics: Loop instructions
Example
By 8086 assembly language write ten stares (*), using loop instruction.
ORG 100h
mov cx,50
label1:
mov ah,02h ; Dos function 02h to Write character
mov dl,'*' ; character to write
int 21h ; dos interrupt 21h
loop label1
RET
12
8086 Microprocessor
Instruction Set
5. Loop Instructions
Mnemonics: Loop instructions
Example
By 8086 assembly language write the English letters A-Z, using loop instruction.
ORG 100h
;PROGRAM TO PRINT A TO Z
MOV CX,26
MOV DX,65
L1:
MOV AH,2
INT 21H
INC DX
LOOP L1
RET
13