从键盘输入一行字符(字符个数至少15个),统计字母、空格、数字、其他字符的个数,并显示。要求:提示输入一行字符串; 键盘输入字符串,并换行显示结果。

    xiaoxiao2022-06-27  148

    DATAS SEGMENT NUMZIMU DW 0 NUMSPACE DW 0 NUMSHUZI DW 0 NUMOTHER DW 0 TIP1 DB 'PLEASE KEY A STRING:',13,10,'$' TIP2 DB 13,10,'NUMBER OF SPACE:','$' TIP3 DB 13,10,'NUMBER OF FIGURES:','$' TIP4 DB 13,10,'NUMBER OF OTHER CHARACTER:','$' TIP5 DB 13,10,'NUMBER OF LETTER:','$' DATAS ENDS STACKS SEGMENT PARA STACK DW 128 DUP(?) STACKS ENDS CODES SEGMENT ASSUME CS:CODES,DS:DATAS,SS:STACKS START: MOV AX,DATAS MOV DS,AX LEA DX,TIP1 MOV AH,09H INT 21H CALL KEY CALL SHOW JMP QUIT KEY: MOV AH,01H INT 21H CMP AL,13 JZ R CMP AL,20H JZ SPACE CMP AL,30H JB OTHER CMP AL,39H JB SHUZI CMP AL,41H JB OTHER CMP AL,5AH JB ZIMU CMP AL,61H JB OTHER CMP AL,7AH JB ZIMU JA OTHER JMP KEY R: RET OTHER: LEA SI,NUMOTHER XOR BX,BX MOV BX,[SI] INC BX MOV [SI],BX JMP KEY SHUZI: LEA SI,NUMSHUZI XOR BX,BX MOV BX,[SI] INC BX MOV [SI],BX JMP KEY ZIMU: LEA SI,NUMZIMU XOR BX,BX MOV BX,[SI] INC BX MOV [SI],BX JMP KEY SPACE: LEA SI,NUMSPACE XOR BX,BX MOV BX,[SI] INC BX MOV [SI],BX JMP KEY SHOW: LEA SI,TIP2 CALL S1 MOV AX,NUMSPACE CALL OUTPUT LEA SI,TIP3 CALL S1 MOV AX,NUMSHUZI CALL OUTPUT LEA SI,TIP4 CALL S1 MOV AX,NUMOTHER CALL OUTPUT LEA SI,TIP5 CALL S1 MOV AX,NUMZIMU CALL OUTPUT RET S1: LEA DX,[SI] MOV AH,09H INT 21H RET OUTPUT PROC MOV BX,10 MOV CX,0 NEXT: MOV DX,0 DIV BX ADD DL,30H PUSH DX INC CX CMP AX,0 JNZ NEXT MOV AH,02H LOOP1: POP DX INT 21H LOOP LOOP1 MOV DL,' ' MOV AH,02H INT 21H RET OUTPUT ENDP QUIT: MOV AH,4CH INT 21H CODES ENDS END START


    最新回复(0)