50 likes | 187 Views
Flow of Control Instruction/Control structure Looping structure Branching structure
E N D
Flow of Control Instruction/Control structure • Looping structure • Branching structure • For assembly language program to carry useful task , there must be a way to make decisions and repeat section of code . In this topic we show how these thing can be accomplished with the JMP and LOOP instruction. • The jump and loop instruction transfer control to another part of the program. This transfer can be unconditional or can depend on a particular combination of status flag settings. • Unconditional JMP/ Unconditional Branching. • JMP Instruction • The JMP instruction causes an unconditional transfer of control. • Syntax • JMP destination/Label name • Example
Conditional Jmp/Conditional Branching Instruction Symbols or Instruction JE // Then Jump Equal to JNE // Then Jump Not Equal to JG // Then Jump greater then JNLE // Then Jump not less then or equal JL // Then Jump less then JNLE JLE JNG JZ JNZ
Both types of Branching Main proc mov dl,0 start1: inc dl mov ah,2 int 21h cmp dl,5 je para_end jmp start1 Para_end: mov ah,4ch int 21h Main endp End main Unconditional branching Main proc mov dl,0 start1: inc dl mov ah,2 int 21h jmp start1: mov ah,4ch int 21h Main endp End main Conditional Branching Main proc mov dl,0 start1: inc dl mov ah,2 int 21h cmp dl,5 jne start1: mov ah,4ch int 21h Main endp End main
Prog.-(12)* Write a program to input a number and display the number is Even or Odd by using control branching structure . • Store 2 into BL • Input a number in AL • Divide to AL from BL • If AH =0 Then go to step 6 • go to step no 8 • Display this is Even No. • Go to step 9 • Display this is Odd no • End of program
Start BL=2 Input AL AH = AL/ BL If AH=0 Yes Display EVEN NO No Display ODD NO End