• 全部
  • 问答

帮我读读这个程序! 高手来看 就这么多分了!

nmywg 2004-01-02 05:05:42
我有点不懂.希望那位高手把代码给我加个注释.越详细越好!!

STACK SEGMENT PARA STACK'STACK'
DW 256 DUP(0)
STACK ENDS
DATA SEGMENT
STRING0 DB 0AH,0DH,'DO YOU WANT TO INPUT DATA?(y/n)','$'
STRING1 DB 0AH,0DH,'PLEASE INPUT YOUR DATA.','$'
STRING2 DB 0AH,0DH,'A=','$'
DB 0AH,0DH,'B=','$'
DB 0AH,0DH,'C=','$'
DB 0AH,0DH,'D=','$'
DB 0AH,0DH,'E=','$'
STRING3 DB 0AH,0DH,'Y=A*B+C/D-E','$'
BUF1 DB 10,0,8 DUP(0)
BUF2 DB 10,0,8 DUP(0)
BUF3 DB 10,0,8 DUP(0)
BUF4 DB 10,0,8 DUP(0)
BUF5 DB 10,0,8 DUP(0)
BUFR DW 10 DUP(0)
DATA1 DW 5 DUP(0)
DATA2 DW 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START PROC FAR
BEGIN: MOV AX,DATA
MOV DS,AX
MOV AX,SS
MOV SS,AX
A2: LEA DX,STRING0
MOV AH,09H
INT 21H
MOV AH,01H
INT 21H
and al,0dfh
CMP AL,'Y'
JNE DONE
LEA DX,STRING1
MOV AH,09H
INT 21H
LEA DX,STRING3
MOV AH,09H
INT 21H
MOV CX,5
LEA BX,STRING2
LEA DI,BUF1
A0: MOV DX,BX
MOV AH,09H
INT 21H
MOV AH,0AH
MOV DX,DI
INT 21H
ADD BX,5
ADD DI,10
LOOP A0
MOV CX,5
LEA SI,BUF1
LEA DI,BUFR
A1: CALL INZH
ADD SI,10
ADD DI,2
LOOP A1
LEA DI,BUFR
LEA SI,DATA1
CALL JIS
JMP A2
DONE: MOV AH,4CH
INT 21H
RET
START ENDP
INZH PROC NEAR
PUSH SI
PUSH DX
PUSH CX
PUSH AX
MOV DX,0
MOV CX,0
MOV AX,0
MOV CL,[SI+1]
ZH0: MOV AL,[SI+2]
INC SI
SUB AL,30H
PUSH CX
PUSH AX
MOV AX,DX
MOV CL,10
MUL CL
MOV DX,AX
POP AX
ADD DX,AX
POP CX
LOOP ZH0
MOV [DI],DX
POP AX
POP CX
POP DX
POP SI
RET
INZH ENDP
JIS PROC NEAR
PUSH DI
PUSH SI
PUSH AX
PUSH BX
PUSH DX
MOV AX,[DI]
MOV BX,[DI+2]
MUL BX
MOV [SI],AX
mov dx,0
MOV AX,[DI+4]
MOV BX,[DI+6]
DIV BX
ADD [SI],AX
MOV BX,[DI+8]
MOV STRING3+13,'='
MOV AX,[SI]
SUB AX,BX
JL JIS1
MOV [SI],AX
MOV STRING3+14,' '
CALL OUTZH
JMP JIS2
JIS1: MOV DATA2,AX
NEG AX
MOV STRING3+14,'-'
CALL OUTZH
JIS2: POP DX
POP BX
POP AX
POP SI
POP DI
ret
JIS ENDP
OUTZH PROC NEAR
PUSH DX
PUSH CX
PUSH BX
PUSH SI
MOV CX,5
LEA SI,STRING3
ADD SI,19 ;20
mov byte ptr [si+1],24h
MOV DX,0
MOV BX,10
OUTZH1:
mov dx,0
DIV BX
XCHG AX,DX
ADD AX,30H
MOV [SI],Al ;aX
DEC SI
MOV AX,DX
LOOP OUTZH1
; MOV STRING3+21
MOV AH,09
LEA DX,STRING3
INT 21H
POP SI
POP BX
POP CX
POP DX
RET
OUTZH ENDP
CODE ENDS
END BEGIN
...全文
27 点赞 收藏 21
写回复
21 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
csdsjkk 2004-01-02
STACK SEGMENT PARA STACK'STACK'
DW 256 DUP(0) ;定义堆栈段
STACK ENDS
DATA SEGMENT
STRING0 DB 0AH,0DH,'DO YOU WANT TO INPUT DATA?(Y/N)','$'
STRING1 DB 0AH,0DH,'PLEASE INPUT YOUR DATA.','$'
STRING2 DB 0AH,0DH,'A=','$'
DB 0AH,0DH,'B=','$'
DB 0AH,0DH,'C=','$'
DB 0AH,0DH,'D=','$'
DB 0AH,0DH,'E=','$'
STRING3 DB 0AH,0DH,'Y=A*B+C/D-E','$'
BUF1 DB 10,0,8 DUP(0)
BUF2 DB 10,0,8 DUP(0)
BUF3 DB 10,0,8 DUP(0)
BUF4 DB 10,0,8 DUP(0) ;定义数据段
BUF5 DB 10,0,8 DUP(0)
BUFR DW 10 DUP(0)
DATA1 DW 5 DUP(0)
DATA2 DW 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START PROC FAR
BEGIN: MOV AX,DATA
MOV DS,AX
MOV AX,SS
MOV SS,AX
A2: LEA DX,STRING0
MOV AH,09H
INT 21H ;显示STRING0字符串
mov byte ptr string3[13],24h
MOV AH,01H
INT 21H
and al,0dfh ;字母转换为大写
CMP AL,'Y' ;检查输入的字符,如果输入y继续计算.否则退出程序
JNE DONE
LEA DX,STRING1
MOV AH,09H ;显示STRING1字符串
INT 21H
LEA DX,STRING3
MOV AH,09H
INT 21H ;显示STRING3字符串
MOV CX,5 ;设计数器
LEA BX,STRING2
LEA DI,BUF1
A0: MOV DX,BX
MOV AH,09H
INT 21H
MOV AH,0AH
MOV DX,DI
INT 21H
ADD BX,5
ADD DI,10
LOOP A0 ;把A,B,C,D,E,放入缓冲区
MOV CX,5
LEA SI,BUF1
LEA DI,BUFR
A1: CALL INZH
ADD SI,10
ADD DI,2
LOOP A1
LEA DI,BUFR
LEA SI,DATA1
CALL JIS
JMP A2
DONE: MOV AH,4CH
INT 21H ;结束

START ENDP
INZH PROC NEAR
PUSH SI
PUSH DX
PUSH CX
PUSH AX
MOV DX,0
MOV CX,0
MOV AX,0
MOV CL,[SI+1]
ZH0: MOV AL,[SI+2]
INC SI
SUB AL,30H
PUSH CX
PUSH AX
MOV AX,DX
MOV CL,10
MUL CL
MOV DX,AX
POP AX
ADD DX,AX
POP CX
LOOP ZH0
MOV [DI],DX
POP AX
POP CX
POP DX
POP SI
RET
INZH ENDP
JIS PROC NEAR
PUSH DI
PUSH SI
PUSH AX
PUSH BX
PUSH DX
MOV AX,[DI]
MOV BX,[DI+2]
MUL BX
MOV [SI],AX
mov dx,0
MOV AX,[DI+4]
MOV BX,[DI+6]
DIV BX
ADD [SI],AX
MOV BX,[DI+8]
MOV STRING3+13,'='
MOV AX,[SI]
SUB AX,BX
JL JIS1
MOV [SI],AX
MOV STRING3+14,' '
CALL OUTZH
JMP JIS2
JIS1: MOV DATA2,AX
NEG AX
MOV STRING3+14,'-'
CALL OUTZH
JIS2: POP DX
POP BX
POP AX
POP SI
POP DI
ret
JIS ENDP
OUTZH PROC NEAR
PUSH DX
PUSH CX
PUSH BX
PUSH SI
MOV CX,5
LEA SI,STRING3
ADD SI,19 ;20
mov byte ptr [si+1],24h
MOV DX,0
MOV BX,10
OUTZH1:
mov dx,0
DIV BX
XCHG AX,DX
ADD AX,30H
MOV [SI],Al ;aX
DEC SI
MOV AX,DX
LOOP OUTZH1
MOV AH,09
LEA DX,STRING3
INT 21H ;显示STRING3字符串
POP SI
POP BX
POP CX
POP DX
RET
OUTZH ENDP
CODE ENDS
END BEGIN

回复
nmywg 2004-01-02
回复人: snowerer(小祥) ( ) 信誉:100 2004-01-02 21:36:00 得分:0


sb

楼上的人素质是在是没的说了.你难道没学就会了啊!你不是神通吧.那你也到显露一手啊!



回复
snowerer 2004-01-02
sb
回复
nmywg 2004-01-02
再麻烦一下了!
LEA SI,STRING3 ;SI指向STRING3
ADD SI,19     
mov byte ptr [si+1],24h
MOV DX,0
MOV BX,10

mov byte ptr [si+1],24h 为什么要用这个啊
回复
nmywg 2004-01-02
谢谢老兄!
回复
csdsjkk 2004-01-02
把字符串形式的‘数字’转换为二进制数
回复
nmywg 2004-01-02
再给看看这段了!
MOV AL,[SI+2] ;B放到AL中
INC SI
SUB AL,30H
PUSH CX
PUSH AX
MOV AX,DX
MOV CL,10
MUL CL
MOV DX,AX
POP AX
ADD DX,AX
POP CX
LOOP ZH0
MOV [DI],DX
POP AX
POP CX
POP DX
POP SI
RET
回复
csdsjkk 2004-01-02
BUF1 DB 10,0,8 DUP(0)
BUF2 DB 10,0,8 DUP(0)
BUF3 DB 10,0,8 DUP(0)
BUF4 DB 10,0,8 DUP(0)
BUF5 DB 10,0,8 DUP(0)
每个输入缓冲区长度为10字节,因此 加 10


STRING2 DB 0AH,0DH,'A=','$'
DB 0AH,0DH,'B=','$'
DB 0AH,0DH,'C=','$'
DB 0AH,0DH,'D=','$'
DB 0AH,0DH,'E=','$'

每个提示串长5字节,因此加 5
回复
nmywg 2004-01-02
谢谢了.原来再这输入的啊
MOV DX,BX
MOV AH,09H
INT 21H ;依次输入并显示A=、B=、C=、D=、E=
MOV AH,0AH
MOV DX,DI
INT 21H
那 为什么要给BX,DI加5和10呢?
ADD BX,5
ADD DI,10
回复
nmywg 2004-01-02
MOV AH,01H
INT 21H
and al,0dfh ;字母转换为大写
CMP AL,'Y'
JNE DONE ;检查输入的字符,如果输入y继续计算.否则退出程序

这个只是接受y啊
回复
nmywg 2004-01-02
那接受数据是那个代码段啊
回复
csdsjkk 2004-01-02
di指向 BUF1 开始的5个输入缓冲区,分别接收输入的5个数(ascii码表示)
BUF1 DB 10,0,8 DUP(0)
BUF2 DB 10,0,8 DUP(0)
BUF3 DB 10,0,8 DUP(0)
BUF4 DB 10,0,8 DUP(0)
BUF5 DB 10,0,8 DUP(0)

bx指向 STRING2 5个数的提示信息
STRING2 DB 0AH,0DH,'A=','$'
DB 0AH,0DH,'B=','$'
DB 0AH,0DH,'C=','$'
DB 0AH,0DH,'D=','$'
DB 0AH,0DH,'E=','$'

LEA DI,BUFR
bufr 存放5个输入数的二进制值
回复
nmywg 2004-01-02
看这段,每行都给注下吧!

A0: MOV DX,BX
MOV AH,09H
INT 21H
MOV AH,0AH
MOV DX,DI
INT 21H
ADD BX,5
ADD DI,10
LOOP A0 ;把A,B,C,D,E,放入缓冲区
MOV CX,5 ;置计数器
LEA SI,BUF1
LEA DI,BUFR
回复
nmywg 2004-01-02
老兄
你加的啊
1
回复
csdsjkk 2004-01-02
头疼,
哪句不懂啊?
总不会一句都不懂吧
回复
nmywg 2004-01-02
再顶
回复
nmywg 2004-01-02
up
怎么没人啊!
难到会的只有一个人啊!
回复
nmywg 2004-01-02
这是我凑起来的啊!
所以好多地方不懂啊!可也没人问只好到这来了!
upup
up
有那位高手
csdsjkk() ( ) 信誉:99
"你写的程序当然你自己最了解,
为什么要别人来写注释呢?给解释一下啊"
你给改的我更就不懂了.可能你刚学的时候也应该有不会的时候吧.而且也希望能有人给你讲讲啊!并不是有现成的东西 .可在网上只能这样来问啊!
!
回复
csdsjkk 2004-01-02
你写的程序当然你自己最了解,
为什么要别人来写注释呢?
回复
nmywg 2004-01-02


STACK SEGMENT PARA STACK'STACK'
DW 256 DUP(0) ;定义堆栈段
STACK ENDS
DATA SEGMENT
STRING0 DB 0AH,0DH,'DO YOU WANT TO INPUT DATA?(Y/N)','$'
STRING1 DB 0AH,0DH,'PLEASE INPUT YOUR DATA.','$'
STRING2 DB 0AH,0DH,'A=','$'
DB 0AH,0DH,'B=','$'
DB 0AH,0DH,'C=','$'
DB 0AH,0DH,'D=','$'
DB 0AH,0DH,'E=','$'
STRING3 DB 0AH,0DH,'Y=A*B+C/D-E','$'
BUF1 DB 10,0,8 DUP(0)
BUF2 DB 10,0,8 DUP(0)
BUF3 DB 10,0,8 DUP(0)
BUF4 DB 10,0,8 DUP(0) ;定义数据段
BUF5 DB 10,0,8 DUP(0)
BUFR DW 10 DUP(0)
DATA1 DW 5 DUP(0)
DATA2 DW 5 DUP(0)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START PROC FAR
BEGIN: MOV AX,DATA
MOV DS,AX
MOV AX,SS
MOV SS,AX
A2: LEA DX,STRING0
MOV AH,09H
INT 21H ;显示STRING0字符串
MOV AH,01H
INT 21H
and al,0dfh ;字母转换为大写
CMP AL,'Y' ;检查输入的字符,如果输入y继续计算.否则退出程序
JNE DONE
LEA DX,STRING1
MOV AH,09H ;显示STRING1字符串
INT 21H
LEA DX,STRING3
MOV AH,09H
INT 21H ;显示STRING3字符串
MOV CX,5 ;设计数器
LEA BX,STRING2
LEA DI,BUF1
A0: MOV DX,BX
MOV AH,09H
INT 21H
MOV AH,0AH
MOV DX,DI
INT 21H
ADD BX,5
ADD DI,10
LOOP A0 ;把A,B,C,D,E,放入缓冲区
MOV CX,5
LEA SI,BUF1
LEA DI,BUFR
A1: CALL INZH
ADD SI,10
ADD DI,2
LOOP A1
LEA DI,BUFR
LEA SI,DATA1
CALL JIS
JMP A2
DONE: MOV AH,4CH
INT 21H ;结束

START ENDP
INZH PROC NEAR
PUSH SI
PUSH DX
PUSH CX
PUSH AX
MOV DX,0
MOV CX,0
MOV AX,0
MOV CL,[SI+1]
ZH0: MOV AL,[SI+2]
INC SI
SUB AL,30H
PUSH CX
PUSH AX
MOV AX,DX
MOV CL,10
MUL CL
MOV DX,AX
POP AX
ADD DX,AX
POP CX
LOOP ZH0
MOV [DI],DX
POP AX
POP CX
POP DX
POP SI
RET
INZH ENDP
JIS PROC NEAR
PUSH DI
PUSH SI
PUSH AX
PUSH BX
PUSH DX
MOV AX,[DI]
MOV BX,[DI+2]
MUL BX
MOV [SI],AX
mov dx,0
MOV AX,[DI+4]
MOV BX,[DI+6]
DIV BX
ADD [SI],AX
MOV BX,[DI+8]
MOV STRING3+13,'='
MOV AX,[SI]
SUB AX,BX
JL JIS1
MOV [SI],AX
MOV STRING3+14,' '
CALL OUTZH
JMP JIS2
JIS1: MOV DATA2,AX
NEG AX
MOV STRING3+14,'-'
CALL OUTZH
JIS2: POP DX
POP BX
POP AX
POP SI
POP DI
ret
JIS ENDP
OUTZH PROC NEAR
PUSH DX
PUSH CX
PUSH BX
PUSH SI
MOV CX,5
LEA SI,STRING3
ADD SI,19 ;20
mov byte ptr [si+1],24h
MOV DX,0
MOV BX,10
OUTZH1:
mov dx,0
DIV BX
XCHG AX,DX
ADD AX,30H
MOV [SI],Al ;aX
DEC SI
MOV AX,DX
LOOP OUTZH1
MOV AH,09
LEA DX,STRING3
INT 21H ;显示STRING3字符串
POP SI
POP BX
POP CX
POP DX
RET
OUTZH ENDP
CODE ENDS
END BEGIN
回复
发帖
汇编语言
创建于2007-08-27

2.0w+

社区成员

汇编语言(Assembly Language)是任何一种用于电子计算机、微处理器、微控制器或其他可编程器件的低级语言,亦称为符号语言。
申请成为版主
帖子事件
创建了帖子
2004-01-02 05:05
社区公告
暂无公告