Q. Determine the use of LOOP instruction?
Program:This program prints the alphabets (A-Z)
; Register used: AX, CX, DX
CODE SEGMENT
ASSUME: CS: CODE.
MAINP: MOV CX, 1AH ; 26 in decimal = 1A in hexadecimal Counter.
MOV DL, 41H ; Loading DL with ASCII hexadecimal of A.
NEXTC: MOV AH, 02H ; display result character in DL
INT 21H ; DOS interrupt
INC DL ; Increment DL for next char
LOOP NEXTC ; Repeat until CX=0. (Loop automatically decrements
; CS and checks whether it is zero or not)
MOV AX, 4C00H ; Exit DOS
INT 21H ; DOS Call
CODE ENDS
END MAINP