汇编语言找最大值最小值,这个程序只能求出最大值,怎么改才能把最小值也求出来啊?
来源:学生作业帮 编辑:搜狗做题网作业帮 分类:综合作业 时间:2024/08/19 02:00:57
汇编语言找最大值最小值,这个程序只能求出最大值,怎么改才能把最小值也求出来啊?
DATA \x05SEGMENT
BUFF\x05DB 5,9,3,7,2
MAX\x05DB\x05?
MIN\x05DB\x05?
DATA\x05ENDS
CODE SEGMENT
\x05ASSUME CS:CODE,DS:DATA
START:\x05MOV\x05AX,DATA
\x05MOV\x05DS,AX
\x05MOV\x05SI,0
\x05MOV\x05CX,OFFSET MAX
\x05MOV\x05BX,OFFSET BUFF
\x05SUB\x05CX,BX
\x05MOV\x05AL,[SI]
\x05MOV\x05MAX,AL
\x05MOV\x05BL,[SI]
\x05MOV\x05MIN,BL
LOOP1:\x05MOV\x05AL,[SI]
\x05CMP\x05MAX,AL
\x05JAE\x05NEXT1
\x05MOV\x05MAX,AL
\x05MOV\x05BL,[SI]
\x05CMP\x05MIN,BL
\x05JNB\x05NEXT2
\x05MOV\x05MIN,BL
NEXT1:
NEXT2:\x05INC \x05SI
\x05LOOP \x05LOOP1
\x05MOV\x05DL,MAX
\x05ADD\x05DL,30H
\x05MOV\x05AH,02H
\x05INT\x0521H
\x05MOV\x05DL,MIN
\x05ADD\x05DL,30H
\x05MOV\x05AH,02H
\x05INT\x0521H
\x05MOV \x05AH,4CH
\x05INT\x0521H
CODE\x05ENDS
\x05END\x05START
DATA \x05SEGMENT
BUFF\x05DB 5,9,3,7,2
MAX\x05DB\x05?
MIN\x05DB\x05?
DATA\x05ENDS
CODE SEGMENT
\x05ASSUME CS:CODE,DS:DATA
START:\x05MOV\x05AX,DATA
\x05MOV\x05DS,AX
\x05MOV\x05SI,0
\x05MOV\x05CX,OFFSET MAX
\x05MOV\x05BX,OFFSET BUFF
\x05SUB\x05CX,BX
\x05MOV\x05AL,[SI]
\x05MOV\x05MAX,AL
\x05MOV\x05BL,[SI]
\x05MOV\x05MIN,BL
LOOP1:\x05MOV\x05AL,[SI]
\x05CMP\x05MAX,AL
\x05JAE\x05NEXT1
\x05MOV\x05MAX,AL
\x05MOV\x05BL,[SI]
\x05CMP\x05MIN,BL
\x05JNB\x05NEXT2
\x05MOV\x05MIN,BL
NEXT1:
NEXT2:\x05INC \x05SI
\x05LOOP \x05LOOP1
\x05MOV\x05DL,MAX
\x05ADD\x05DL,30H
\x05MOV\x05AH,02H
\x05INT\x0521H
\x05MOV\x05DL,MIN
\x05ADD\x05DL,30H
\x05MOV\x05AH,02H
\x05INT\x0521H
\x05MOV \x05AH,4CH
\x05INT\x0521H
CODE\x05ENDS
\x05END\x05START
![汇编语言找最大值最小值,这个程序只能求出最大值,怎么改才能把最小值也求出来啊?](/uploads/image/z/1740343-31-3.jpg?t=%E6%B1%87%E7%BC%96%E8%AF%AD%E8%A8%80%E6%89%BE%E6%9C%80%E5%A4%A7%E5%80%BC%E6%9C%80%E5%B0%8F%E5%80%BC%2C%E8%BF%99%E4%B8%AA%E7%A8%8B%E5%BA%8F%E5%8F%AA%E8%83%BD%E6%B1%82%E5%87%BA%E6%9C%80%E5%A4%A7%E5%80%BC%2C%E6%80%8E%E4%B9%88%E6%94%B9%E6%89%8D%E8%83%BD%E6%8A%8A%E6%9C%80%E5%B0%8F%E5%80%BC%E4%B9%9F%E6%B1%82%E5%87%BA%E6%9D%A5%E5%95%8A%3F)
稍修改即可:
LOOP1:MOV AL,[SI]
CMP MAX,AL
JAE NEXT11
MOV MAX,AL
NEXT11:
MOV BL,[SI]
CMP MIN,BL
JNBN EXT2
MOV MIN,BL
NEXT1:
再问: 怎么出来的最小值和最大值一样都是9啊???![](http://img.wesiedu.com/upload/2/0b/20b3395ff572ff813e1dbb74756d6fe4.jpg)
再答: 已修改调试好,完整程序如下: DATA SEGMENTBUFF DB 5,9,3,7,2MAX DB ?MIN DB ?DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV SI,0 MOV CX,OFFSET MAX MOV BX,OFFSET BUFF SUB CX,BX MOV AL,[SI] MOV MAX,AL MOV BL,[SI] MOV MIN,BLLOOP1: MOV AL,[SI] CMP MAX,AL Ja NEXT11 MOV MAX,ALnext11: MOV BL,[SI] CMP MIN,BL Jb NEXT2 MOV MIN,BLNEXT1:NEXT2: INC SI LOOP LOOP1 MOV DL,MAX ADD DL,30H MOV AH,02H INT 21H MOV DL,MIN ADD DL,30H MOV AH,02H INT 21H MOV AH,4CH INT 21HCODE ENDS END START![](http://img.wesiedu.com/upload/7/51/7514ba46eec1d9813a679e446e6d1473.jpg)
LOOP1:MOV AL,[SI]
CMP MAX,AL
JAE NEXT11
MOV MAX,AL
NEXT11:
MOV BL,[SI]
CMP MIN,BL
JNBN EXT2
MOV MIN,BL
NEXT1:
再问: 怎么出来的最小值和最大值一样都是9啊???
![](http://img.wesiedu.com/upload/2/0b/20b3395ff572ff813e1dbb74756d6fe4.jpg)
再答: 已修改调试好,完整程序如下: DATA SEGMENTBUFF DB 5,9,3,7,2MAX DB ?MIN DB ?DATA ENDSCODE SEGMENT ASSUME CS:CODE,DS:DATASTART: MOV AX,DATA MOV DS,AX MOV SI,0 MOV CX,OFFSET MAX MOV BX,OFFSET BUFF SUB CX,BX MOV AL,[SI] MOV MAX,AL MOV BL,[SI] MOV MIN,BLLOOP1: MOV AL,[SI] CMP MAX,AL Ja NEXT11 MOV MAX,ALnext11: MOV BL,[SI] CMP MIN,BL Jb NEXT2 MOV MIN,BLNEXT1:NEXT2: INC SI LOOP LOOP1 MOV DL,MAX ADD DL,30H MOV AH,02H INT 21H MOV DL,MIN ADD DL,30H MOV AH,02H INT 21H MOV AH,4CH INT 21HCODE ENDS END START
![](http://img.wesiedu.com/upload/7/51/7514ba46eec1d9813a679e446e6d1473.jpg)
汇编语言找最大值最小值,这个程序只能求出最大值,怎么改才能把最小值也求出来啊?
输入n个 数,求出它们的最大值,最小值和平均值?用VB怎么编写程序
编写一个函数,既能求出最大值也能求出最小值.
代数式-X的平方+2X+1有最大值还是最小值 ,求出这个最小值
求使y=2-sinx取最大值、最小值的x的集合,并求出这个函数的最大值、最小值
编写一个程序,对输入的4个整数,求出其中的最大值和最小值
Matlab中,如何求出一组数中的最大值和最小值
求出下列函数的最大值、最小值和周期.
EXCEL如何求出每天当中温度的最大值和最小值
如何确定不等式可以求出最大值还是最小值
如何求出三个力的合力的最大值和最小值?
代数式-a平方-4a+10有最大值还是最小值 并求出这个最值