在键盘输入一个字符串,并将其从左向右滚动显示,求完整程序。
题目链接:http://zhidao.baidu.com/question/2265949993258693388.html
做而论道编写的程序如下:
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
MSG1 DB 13, 10, 'Please input string: ', 13, 10, '$'
IN_MAX DB 18
IN_N DB ?
IN_BUF DB 20 DUP(?)
MSG2 DB 90 DUP('$')
DATA ENDS
CODE SEGMENT
START:
MOV AX, DATA
MOV DS, AX
;---------------------------
LEA DX, MSG1
MOV AH, 9
INT 21H
LEA DX, IN_MAX
MOV AH, 10
INT 21H
CMP IN_N, 0
JZ EXIT
;---------------------------
RIGHT:
MOV SI, 0
MOV DI, 0
MOV MSG2[BX - 1], ' '
ADD DI, BX
CALL UP_DISP
LEA DX, MSG2
MOV AH, 9
INT 21H
MOV AH, 2
MOV DL, 13
INT 21H
INC BX
CALL DELAY
CMP DI, 80
JNZ RIGHT
;---------------------------
EXIT:
MOV AH, 4CH
INT 21H
;---------------------------
UP_DISP:
MOV CH, 0
MOV CL, IN_N
LP1:
MOV AL, IN_BUF[SI]
MOV MSG2[DI], AL
INC SI
INC DI
CMP DI, 80
JZ EXIT_UP
LOOP LP1
EXIT_UP:
RET
;---------------------------
DELAY:
PUSH CX
PUSH DX
MOV DX, 1000
DL1:
LOOP $
DEC DX
CMP DX, 0
JNZ DL1
POP DX
POP CX
RET
;---------------------------
CODE ENDS
END START
经过实验,本程序可以满足题目要求。