Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 15
Assembly Language
Control Transfer Instructions
Jump Instruction • It causes an unconditional transfer to a target location inside the code segment (another point in the program). • Syntax: – JMP Target/Label • Target can be either destination or address. • It will cause the IP to fetch an instruction from the location given by Target. Jump Instruction • JMP instruction can only take one operand. • Example: Given: Loopforever: MOV num1, 03h MOV ah, 04h Label JMP Loopforever • This program will be executed infinitely. This instruction does not affect any flags. Jump if Above Instruction • JA instruction has the following format: – JA Label – The Jump is executed if the carry flag (CF) is not set or equal to 0, or if the Zero flag (ZF) is not set or equal to 0. (CF=0 or ZF=0) • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Above Or Equal Instruction
• JAE instruction has the following format:
– JAE Label – The Jump is executed if the carry flag (CF) is not set or equal to 0 (CF=0). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Below Instruction
• JB instruction has the following format:
– JB Label – The Jump is executed if the carry flag (CF) is set or equal to 1 (CF=1). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Below Or Equal Instruction
• JBE instruction has the following format:
– JBE Label – The Jump is executed if the carry flag (CF) is set or equal to 1 or the value of ZF is set or equal to 1 (CF=1 or ZF=1). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Equal Instruction
• JE instruction has the following format:
– JE Label – The Jump is executed if the value of ZF is set or equal to 1 (ZF=1). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Sign Instruction
• JS instruction has the following format:
– JS Label – The Jump is executed if the value of SF is set or equal to 1 (SF=1). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Carry Instruction
• JC instruction has the following format:
– JC Label – The Jump is executed if the value of CF is set or equal to 1 (CF=1). • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. Jump if Counter Register Zero Instruction
• JCXZ instruction has the following format:
– JCXZ Label – The Jump is executed if the value of register CX is cleared or equal to 0 (CX=0). • It is used to prevent from entering a loop if the counter register is 0. • It will cause the IP to fetch an instruction from location given by Label. • Does not alter any flags. LOOP Instruction
• The LOOP instruction has the following syntax:
– LOOP Label • The Loop instruction is used to execute a set of instruction multiple times. • The number of times the instruction is executed depends on the value of CX. • The Loop instruction will decrement the value of CX and executes the set of instruction until the CX reaches zero. LOOP Instruction
• Extra precaution is needed before execution of
the LOOP instruction. Prior to execution, always check the value of CX such that it is not equal to 0. • Use JCXZ for the checking. • If the value of CX is 0, the LOOP will be executed 65536 times. LOOPZ Instruction
• LOOPZ has the following syntax:
– LOOPZ Label • The LOOPZ is used to implement do loop, while loop, and until loop. • LOOPZ will decrement the value of CX and check if it is zero. LOOPZ will branch to the target address if CX is not zero and the zero flag is set. • If CX=0 and ZF=0, it will execute the next instruction after the LOOPZ instruction. INT Instruction
• INT instruction (interrupt) has the following
syntax: – INT number • The interrupt instruction will call system and special routines based on the number supplied. • The number must be between 0 and 255, and each of this number represent a specific interrupt routine.