-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhile.asm
43 lines (28 loc) · 1.12 KB
/
while.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
TITLE while : An AL Program to print Upper Case Letters from A to Z
; ( Simulation of While Loop ).
.MODEL SMALL
.STACK 100H
.DATA
PROMPT DB 'The Upper Case Letters from A to Z are : $'
.CODE
MAIN PROC
MOV AX, @DATA ; initialize DS
MOV DS, AX
LEA DX, PROMPT ; load and print PROMPT
MOV AH, 9
INT 21H
MOV CX, 26 ; initialize CX
MOV AH, 2 ; set output function
MOV DL, 41H ; initialize DL=A
@WHILE_LOOP: ; loop label
CMP CX, 0 ; compare CX and 0
JE @END_LOOP ; jump to label @END_LOOP if CX=0
INT 21H ; print character
INC DL ; increment DL to next ASCII character
DEC CX ; decrement CX
JMP @WHILE_LOOP ; jump to label @WHILE_LOOP
@END_LOOP: ; jump label
MOV AH, 4CH ; return control to DOS
INT 21H
MAIN ENDP
END MAIN