编程:按下数字键0--9中任何一键,编程子程序把对应按键的ASC码以二进制数形式显示在屏幕上。要求写出主程序和子程序。
DATA SEGMENT
PROMPT DB 'PLEASE INPUT A NUMBER(0-9):','$'
PROMPT1 DB 0AH,0DH,'ERROR',0AH,0DH,'$'
DA DB ?
DA2 DB 8
DB ?
DB 8 DUP(0),0AH,0DH,'$'
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20H DUP(0)
STACK1 ENDS
COSEG SEGMENT
ASSUME CS:COSEG,DS:DATA,SS:STACK1
START: MOV AX,DATA
MOV DS,AX
ROP: MOV DX,OFFSET PROMPT
MOV AH,09
INT 21H
MOV AH,01
INT 21H
CMP AL,'0'
JL ERROR
CMP AL,'9'
JG ERROR
CALL PROC1
MOV AH,4CH
INT 21H
ERROR:
MOV DX,OFFSET PROMPT1
MOV AH,09
INT 21H
JMP ROP
PROC1 PROC NEAR
MOV DI,OFFSET DA2+2
MOV CX,8
LOP: XOR BL,BL
ROL AL,1
RCL BL,1
ADD BL,30H
MOV [DI],BL
INC DI
LOOP LOP
MOV DX,0AH
MOV AH,02H
INT 21H
MOV DX,0DH
MOV AH,02H
INT 21H
MOV DX,OFFSET DA+2
MOV AH,09H
INT 21H
RET
PROC1 ENDP
COSEG ENDS
END START