從鍵盤上輸入一系列以$為結束符的字串,然後對其中的數字字元計數,並顯示出計數結果。 S1 SEGMENT STACK DW 100H DUP(?) TOP LABEL WORD S1 ENDS S2 SEGMENT CRLF DW 0DH,0AH,24H S2 ENDS S3 SEGMENT ASSUME CS:S3,DS:S2,SS:S1 MAIN PROC NEAR MOV AX,S1 MOV SS,AX LEA SP,TOP MOV AX,S2 MOV DS,AX XOR CX,CX L1:MOV AH,1 INT 21H CMP AL,24H JE L2 CMP AL,30H JB L1 CMP AL,39H JA L1 INC CX JMP L1 L2: LEA DX,CRLF MOV AH,9 INT 21H MOV AX,CX XOR CX,CX L3: MOV SI,10 XOR DX,DX DIV SI PUSH DX INC CX OR AX,AX JNZ L3 L4: POP DX ADD DL,30H MOV AH,2 INT 21H LOOP L4 MOV AH,4CH INT 21H MAIN ENDP S3 ENDS END MAIN
從鍵盤上輸入一系列以$為結束符的字串,然後對其中的數字字元計數,並顯示出計數結果。 S1 SEGMENT STACK DW 100H DUP(?) TOP LABEL WORD S1 ENDS S2 SEGMENT CRLF DW 0DH,0AH,24H S2 ENDS S3 SEGMENT ASSUME CS:S3,DS:S2,SS:S1 MAIN PROC NEAR MOV AX,S1 MOV SS,AX LEA SP,TOP MOV AX,S2 MOV DS,AX XOR CX,CX L1:MOV AH,1 INT 21H CMP AL,24H JE L2 CMP AL,30H JB L1 CMP AL,39H JA L1 INC CX JMP L1 L2: LEA DX,CRLF MOV AH,9 INT 21H MOV AX,CX XOR CX,CX L3: MOV SI,10 XOR DX,DX DIV SI PUSH DX INC CX OR AX,AX JNZ L3 L4: POP DX ADD DL,30H MOV AH,2 INT 21H LOOP L4 MOV AH,4CH INT 21H MAIN ENDP S3 ENDS END MAIN