2 qq 36182187 qq_36182187 于 2016.09.19 20:34 提问

汇编语言,这个程序的字符串运动状态改成非来回的,每次从右到左,不要来回移动。每次移动到左边后直接消失

CODE SEGMENT
ASSUME CS:CODE,DS:CODE
START: MOV AX,CODE
MOV DS,AX
MOV AX,0B800H
MOV ES,AX
CLD
AGAIN: MOV AX,3
INT 10H
LEA DX,MENU
MOV AH,9
INT 21H
INPUT: MOV AH,0
INT 16H
CMP AL,'1'
JNZ CP2
CALL SUB01
JMP INPUT
CP2: CMP AL,'2'
JNZ CP3
CALL SUB02
JMP AGAIN
CP3: CMP AL,'3'
JNZ INPUT
LEA DX,MESG
MOV AH,9
INT 21H
MOV AH,1
INT 21H
MOV AH,4CH

INT 21H
DELAY PROC
PUSH CX
PUSH DX
MOV DX,800
D1: MOV CX,006FFH
LOOP $
DEC DX
JNZ D1
POP DX

POP CX
RET

DELAY ENDP

SUB01: MOV AX,0E0DH
INT 10H
MOV AL,0AH
INT 10H
LEA DX,STR
MOV AH,0AH
INT 21H
MOV AX,0E0AH
INT 10H
RET
SUB02: CMP BUF,0DH
JZ QUIT
CALL LINE
LEA SI,STR
INC SI
MOV DX,SI
MOV AL,' '
XCHG AL,[SI]
CBW
MOV BX,AX
INC BX
MOV BYTE PTR[BX+SI],' '
INC BX
PUSH BX
SHL BX,1
SUB RIGHT,BX
POP BX
MOV BP,LEFT
SHOW:
MOV SI,DX
MOV CX,BX
MOV DI,BP
NEXT: MOVSB
MOV AL,2
STOSB
LOOP NEXT
MOV AH,1
INT 16H
JNZ QUIT
CALL DELAY
ADD BP,NUM
CMP BP,RIGHT
JB T1
MOV NUM,-2
JMP HERE
T1: CMP BP,LEFT
JA HERE
MOV NUM,2
HERE: JMP SHOW
SSS: MOV BUF,0DH
QUIT: XOR DI,DI
MOV CX,80*25
MOV AX,720H
REP STOSW
RET
LINE:
MOV DI,(18*80+10)*2
MOV AL,201
MOV AH,4
STOSW
MOV CX,60-2
MOV AL,205
REP STOSW
MOV AL,187
STOSW
ADD DI,20*2
MOV AL,186
STOSW
MOV LEFT,DI
MOV CX,60-2
MOV AL,20H
REP STOSW
MOV RIGHT,DI
MOV AL,186
STOSW
ADD DI,20*2
MOV AL,200
STOSW
MOV CX,60-2
MOV AL,205
REP STOSW
MOV AL,188
STOSW
RET
MENU DB 5 DUP(0AH)
DB 31 DUP(' '),'MAIN MENU',0DH,0AH
DB 25 DUP(' '),201,21 DUP(205),187,0DH,0AH
DB 25 DUP(' '),186,'1.Input a String...',186,0DH,0AH
DB 25 DUP(' '),186,'2.Display Model...',186,0DH,0AH
DB 25 DUP(' '),186,'3.Return to Dos...',186,0DH,0AH
DB 25 DUP(' '),200,21 DUP(205),188,0DH,0AH
DB 28 DUP(' '),'Choice(1,2,3):$'
MESG DB 0DH,0AH,0DH,0AH,9,'Press any key to exit...$'
NUM DW 2
LEFT DW 0
RIGHT DW 0
STR DB 21
DB 0
BUF DB 0DH,20 DUP(0)
CODE ENDS
END START

1个回答

devmiao
devmiao   Ds   Rxr 2016.09.19 23:51
Csdn user default icon
上传中...
上传图片
插入图片