各位高手一道简单的汇编程序题求破:把一串字符从键盘输入,然后逆序输出;
2个回答
展开全部
DSEG SEGMENT
SHOW DB 'Please input your name: $'
NAM DB 200
DB ?
DB 200 DUP(0)
DSEG ENDS
SSEG SEGMENT STACK
DB 200 DUP(?)
STACK_TOP LABEL WORD
SSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG, DS:DSEG, SS:SSEG
START:
MOV AX, DSEG
MOV DS, AX
MOV AX, SSEG
MOV SS, AX
MOV SP, OFFSET STACK_TOP
MOV DX, OFFSET SHOW
MOV AH, 09H
INT 21H
MOV DX, OFFSET NAM
MOV AH, 0AH
INT 21H
MOV DL, 0AH
MOV AH, 02H
INT 21H
MOV DL, 0DH
MOV AH, 02H
INT 21H
MOV CL, NAM + 1
MOV CH, 0
CMP CX, 0
JE EXIT
MOV SI, OFFSET NAM + 2
ADD SI, CX
MOV AH, 02H
L1:
DEC SI
MOV DL, [SI]
INT 21H
LOOP L1
EXIT:
MOV AH, 4CH
INT 21H
CSEG ENDS
END START
输入:ABCD
输出:DCBA
SHOW DB 'Please input your name: $'
NAM DB 200
DB ?
DB 200 DUP(0)
DSEG ENDS
SSEG SEGMENT STACK
DB 200 DUP(?)
STACK_TOP LABEL WORD
SSEG ENDS
CSEG SEGMENT
ASSUME CS:CSEG, DS:DSEG, SS:SSEG
START:
MOV AX, DSEG
MOV DS, AX
MOV AX, SSEG
MOV SS, AX
MOV SP, OFFSET STACK_TOP
MOV DX, OFFSET SHOW
MOV AH, 09H
INT 21H
MOV DX, OFFSET NAM
MOV AH, 0AH
INT 21H
MOV DL, 0AH
MOV AH, 02H
INT 21H
MOV DL, 0DH
MOV AH, 02H
INT 21H
MOV CL, NAM + 1
MOV CH, 0
CMP CX, 0
JE EXIT
MOV SI, OFFSET NAM + 2
ADD SI, CX
MOV AH, 02H
L1:
DEC SI
MOV DL, [SI]
INT 21H
LOOP L1
EXIT:
MOV AH, 4CH
INT 21H
CSEG ENDS
END START
输入:ABCD
输出:DCBA
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用栈,迅速搞定。
追问
能不能弄个程序上来啊,我急啊,还要富有注释,要讲给老师听的,满意的可再追加50分的啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询