汇编 实验报告5 字符串输入输出

;实验报告内容,输入一个字符串,去掉数字,输出
ASSUME DS:DATA,CS,CDOE,SS,STACK DATA SEGMENT MAXLEN DB 15 INPUTLEN DB 0 STR1 DB 15 DUP(0) STR2 DB 15 DUP(0) DATA ENDS STACK1 SEGMENT STACK DW 40H DUP(0) STACK1 ENDS CODE SEGMENT START: MOV AX,DATA ;INITIAL THE DS,SS MOV DS,AX MOV AX,STACK1 MOV SS,AX LEA DX,MAXLEN ;INPUT THE STRING MOV AH,0AH INT 21H CALL NEWLINE ;SET THE LOOP MOV AL,INPUTLEN MOV AH,0 MOV CX,AX MOV SI,0 MOV DI,0 LOOP1: MOV AL,STR1[SI] CMP AL,30H ;CMP JZ BREAK JC OK CMP AL,39H JZ BREAK JNC OK JMP BREAK OK: MOV STR2[DI],AL ;TRANSFER STR1 TO STR2 INC DI BREAK: INC SI LOOP LOOP1 MOV AL,24H ;ADD THE '$' MOV STR2[DI],AL MOV AL,0 LEA DX,STR2 MOV AH,09H INT 21H MOV AH,4CH INT 21H NEWLINE PROC MOV AH,02H MOV DL,0DH INT 21H MOV AH,02H MOV DL,0AH INT 21H RET NEWLINE ENDP CODE ENDS END START

  

posted @ 2014-10-20 12:01  雪溯  阅读(435)  评论(0编辑  收藏  举报