用汇编语言在键盘输入一个字符串,并将其从左向右滚动显示,求完整程序
发布网友
发布时间:2022-04-24 02:44
我来回答
共2个回答
热心网友
时间:2023-10-22 17:48
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
MSG1 DB 13, 10, 'Please input string: ', 13, 10, '$'
IN_MAX DB 8
IN_N DB ?
IN_BUF DB 10 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 BYTE PTR 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
热心网友
时间:2023-10-22 17:48
DATA SEGMENT
buf db 100
BUF1 DB 0
BUF2 db 100 p(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
mov ah,0ah
mov dx,offset buf
int 21h
MOV AL,BUF1
INC AL
MOV BUF,AL
MOV AL,' '
MOV BUF1,AL
MOV DL,0
NEXT:
MOV AH,02
MOV DH,15 ;HANG
MOV BH,0
INT 10H
PUSH DX
MOV SI,OFFSET BUF1
MOV CL,BUF
XOR CH,CH
L1:
MOV AH,0EH
MOV AL,[SI]
MOV BL,0
INT 10H
INC SI
LOOP L1
CALL DELAY
POP DX
INC DL
CMP DL,80
JE EXIT
MOV AH,BUF
MOV BH,DL
ADD BH,AH
CMP BH,80
JB NEXT
DEC BUF
JNZ NEXT
INC BUF
JMP NEXT
EXIT: MOV AH,4CH
INT 21H
DELAY:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX,03000H
D0:
MOV BX,03FF0H
D1:
MOV AX,1
MUL AX
DEC BX
JNZ D1
LOOP D0
POP DX
POP CX
POP BX
POP AX
RET
CODE ENDS
END START
热心网友
时间:2023-10-22 17:48
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
MSG1 DB 13, 10, 'Please input string: ', 13, 10, '$'
IN_MAX DB 8
IN_N DB ?
IN_BUF DB 10 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 BYTE PTR 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
热心网友
时间:2023-10-22 17:48
DATA SEGMENT
buf db 100
BUF1 DB 0
BUF2 db 100 p(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
mov ah,0ah
mov dx,offset buf
int 21h
MOV AL,BUF1
INC AL
MOV BUF,AL
MOV AL,' '
MOV BUF1,AL
MOV DL,0
NEXT:
MOV AH,02
MOV DH,15 ;HANG
MOV BH,0
INT 10H
PUSH DX
MOV SI,OFFSET BUF1
MOV CL,BUF
XOR CH,CH
L1:
MOV AH,0EH
MOV AL,[SI]
MOV BL,0
INT 10H
INC SI
LOOP L1
CALL DELAY
POP DX
INC DL
CMP DL,80
JE EXIT
MOV AH,BUF
MOV BH,DL
ADD BH,AH
CMP BH,80
JB NEXT
DEC BUF
JNZ NEXT
INC BUF
JMP NEXT
EXIT: MOV AH,4CH
INT 21H
DELAY:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX,03000H
D0:
MOV BX,03FF0H
D1:
MOV AX,1
MUL AX
DEC BX
JNZ D1
LOOP D0
POP DX
POP CX
POP BX
POP AX
RET
CODE ENDS
END START
热心网友
时间:2023-10-22 17:48
ASSUME CS:CODE, DS:DATA
DATA SEGMENT
MSG1 DB 13, 10, 'Please input string: ', 13, 10, '$'
IN_MAX DB 8
IN_N DB ?
IN_BUF DB 10 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 BYTE PTR 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
热心网友
时间:2023-10-22 17:48
DATA SEGMENT
buf db 100
BUF1 DB 0
BUF2 db 100 p(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START: MOV AX,DATA
MOV DS,AX
mov ah,0ah
mov dx,offset buf
int 21h
MOV AL,BUF1
INC AL
MOV BUF,AL
MOV AL,' '
MOV BUF1,AL
MOV DL,0
NEXT:
MOV AH,02
MOV DH,15 ;HANG
MOV BH,0
INT 10H
PUSH DX
MOV SI,OFFSET BUF1
MOV CL,BUF
XOR CH,CH
L1:
MOV AH,0EH
MOV AL,[SI]
MOV BL,0
INT 10H
INC SI
LOOP L1
CALL DELAY
POP DX
INC DL
CMP DL,80
JE EXIT
MOV AH,BUF
MOV BH,DL
ADD BH,AH
CMP BH,80
JB NEXT
DEC BUF
JNZ NEXT
INC BUF
JMP NEXT
EXIT: MOV AH,4CH
INT 21H
DELAY:
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV CX,03000H
D0:
MOV BX,03FF0H
D1:
MOV AX,1
MUL AX
DEC BX
JNZ D1
LOOP D0
POP DX
POP CX
POP BX
POP AX
RET
CODE ENDS
END START