以下代码是我尝试查找频率表中的最小两个值。我不想使用任何排序算法。一旦我检测到数组中的两个最小值。我保存他们的索引并执行添加。到目前为止我已经这样做了。有人可以帮我这个吗?那现在我该做什么。感谢
freq dd 512 dup(0)
min dw ?
smallval proc
push bx
sub bx,bx
cal:
mov ax,freq[bx] ;moving the address of frequence to source index
cmp ax,0 ;comparing the frequency array one by one
jmp incr ;increased the address of frequency by two since its a byte
call check
mov freq[bx],0 ;replace that min value with zero
mov ind,bx
cal1:
add bx,2 ;now trying to find the next smallest value in the array
mov ax,freq[bx]
cmp ax,0
jmp cal1
call check
mov freq[bx],0
add ax,min ;addition of two minimum values
incr:
add bx,2
jmp cal
endval:
smallval endp
;=======================================================================================
;checking for the smallest value in the array
check proc
mov ax,freq[bx] ;assigning lowest value in the frequency array in min
variable
mov min,ax
l1: ;loop that checks each value of array with min
variable
add bx,2 ;and see if something is smaller then that will be a
new min
mov ax,freq[bx]
cmp min,ax
jge assign
cmp bx,1024
jmp end
jmp l1
assign: ;upon next smallest value min variable will be
replaced by that
mov ax,freq[bx] ;smallest value
mov min,ax
jmp l1
end:
ret
check endp
答案 0 :(得分:0)
这里有一个无限循环:
cal1:
add bx,2
mov ax,freq[bx]
cmp ax,0
jmp cal1
这里有一些可疑的流量控制:
cmp bx,1024
jmp end
jmp l1