1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| STACKS SEGMENT STACK DW 100H DUP(?) TOP LABEL WORD STACKS ENDS --定义栈 DATAS SEGMENT TABLE DB 100H DUP(?) DATAS ENDS --定义变量 CODES SEGMENT ASSUME CS:CODE,SS:STACKS,DS:DATAS MAIN PROC FAR MOV AX,STACKS MOV SS,AX LEA SP,TOP MOV AX,DATAS MOV DS,AX MOV CX,000DH --为输出设置一个结束标志,当遇到回车时结束输出 PUSH CX MOV CX,40 L1: MOV AH,1 INT 21H CMP AL,0DH --判断输入的值是否是回车符,如果是,则表示输入结束,跳转至L2 JZ L2 MOV AH,0 PUSH AX LOOP L1 --循环输入 MOV CX,40 L2: POP DX CMP DL,0DH --判断是否遇到回车时结束输出 JZ EXIT MOV AH,2 INT 21H LOOP L2 EXIT: MOV AH,4CH INT 21H MAIN ENDP CODES ENDS END MAIN
|