版权声明:未经本人同意,禁止转载。 https://blog.csdn.net/qq_34022601/article/details/89052885
题目:
将从键盘输入的N个有符号数保存到数组TAB ,找出N个有符号数中绝对值大于X的最小负奇数存放到Min单元,如果没有找到则Min单元存放0。在终端上显示Min的绝对值。
TAB DD X1,……,XN
X DD xx(无符号数,自己设定)
Min DD ?
要求:1、求数据Min的功能用子程序实现
2、画主程序及子程序流程图
3、熟练掌握综合程序设计方法
流程图:
INCLUDE irvine32.inc
.data
TAB dd 10 dup(?)
cnt dd 3
X dd ?
Min dd 0
y dd 0
two dd 2
.code
start :
mov ecx,cnt
call print
call readint
mov X,eax
neg X ;取反
mov ecx,cnt
xor esi,esi
again:
mov eax,TAB[esi*4]
cmp eax,Min
jge next
;是负数且小于MIN,判断绝对值是否大于X
cmp eax,X
jge next
mov y,eax
neg eax
xor edx,edx
div two
cmp dx,0
je next
mov eax,y
mov Min,eax
next:
inc esi
loop again
mov eax,Min
call writeint
call crlf
exit
print proc
xor esi,esi
print_again:
call readint
mov TAB[esi*4],eax
inc esi
loop print_again
ret
print endp
end start