循环结构、选择结构练习
试编写一程序,要求能从键盘接收一个个位数N,然后响铃N次(响铃的ASCII码为07H)。
-
DATAS SEGMENT
-
INFOR DB 'please input the number(0~9):$'
-
RING DB 0AH,0DH,'RING~$'
-
DATAS ENDS
-
-
CODES SEGMENT
-
MAIN PROC FAR
-
ASSUME CS:CODES,DS:DATAS
-
START:
-
PUSH DS
-
SUB AX,AX
-
PUSH AX
-
MOV AX,DATAS
-
MOV DS,AX
-
-
MOV DX,OFFSET INFOR
-
MOV AH,09H
-
INT 21H
-
-
MOV AH,01H
-
INT 21H
-
SUB AL,30H
-
MOV BL,AL
-
-
CMP BL,0
-
JLE EXIT
-
-
CMP BL,9
-
JG EXIT
-
-
RINGUP:
-
CALL WAITTIME
-
-
MOV AH,02H
-
MOV DL,07H
-
INT 21H
-
-
MOV DX,OFFSET RING
-
MOV AH,09H
-
INT 21H
-
-
DEC BL
-
JNZ RINGUP
-
-
EXIT:
-
MOV AH,4CH
-
INT 21H
-
MAIN ENDP
-
-
WAITTIME PROC
-
PUSH CX
-
MOV CX,2000H
-
-
WAITFOR:
-
CALL WAITTIME2
-
LOOP WAITFOR
-
POP CX
-
RET
-
-
WAITTIME ENDP
-
-
WAITTIME2 PROC
-
PUSH CX
-
MOV CX,3600H
-
-
WAITFOR2:
-
LOOP WAITFOR2
-
POP CX
-
RET
-
-
WAITTIME2 ENDP
-
-
CODES ENDS
-
END START