;----------------------------------DATAS SEGMENTIN_1 DB 100N1 DB ?BUFF DB 100 DUP("$")MSG1 DB 10, 13, "Please Input STR : $"MSG2 DB 10, 13, "The STR Long is : $"CRLF DB 10, 13, "$"DATAS ENDS;----------------------------------CODES SEGMENTASSUME CS:CODES, DS:DATASSTART:MOV AX, DATASMOV DS, AXMOV DX, OFFSET MSG1 ;提示輸入.MOV AH, 09HINT 21HMOV DX, OFFSET IN_1 ;接收鍵盤輸入.MOV AH, 0AHINT 21HMOV DX, OFFSET CRLF ;回車換行.MOV AH, 09HINT 21HMOV DX, OFFSET BUFF ;輸出原字串.MOV AH, 09HINT 21HMOV DX, OFFSET MSG2 ;提示長度.MOV AH, 09HINT 21H;----------------------------------MOV AL, N1MOV BL, 10MOV CX, 0L1:MOV AH, 0DIV BLPUSH AXINC CXAND AL, ALJNZ L1L2:POP DXMOV DL, DHADD DL, 48MOV AH, 2INT 21HLOOP L2;----------------------------------MOV AH, 4CHINT 21HCODES ENDSEND START;----------------------------------
;----------------------------------DATAS SEGMENTIN_1 DB 100N1 DB ?BUFF DB 100 DUP("$")MSG1 DB 10, 13, "Please Input STR : $"MSG2 DB 10, 13, "The STR Long is : $"CRLF DB 10, 13, "$"DATAS ENDS;----------------------------------CODES SEGMENTASSUME CS:CODES, DS:DATASSTART:MOV AX, DATASMOV DS, AXMOV DX, OFFSET MSG1 ;提示輸入.MOV AH, 09HINT 21HMOV DX, OFFSET IN_1 ;接收鍵盤輸入.MOV AH, 0AHINT 21HMOV DX, OFFSET CRLF ;回車換行.MOV AH, 09HINT 21HMOV DX, OFFSET BUFF ;輸出原字串.MOV AH, 09HINT 21HMOV DX, OFFSET MSG2 ;提示長度.MOV AH, 09HINT 21H;----------------------------------MOV AL, N1MOV BL, 10MOV CX, 0L1:MOV AH, 0DIV BLPUSH AXINC CXAND AL, ALJNZ L1L2:POP DXMOV DL, DHADD DL, 48MOV AH, 2INT 21HLOOP L2;----------------------------------MOV AH, 4CHINT 21HCODES ENDSEND START;----------------------------------