字符串与数组及相关编程知识
1. 数组填充与排序相关
在编程中,有时需要用随机的32位有符号整数填充数组。以下是一个实现此功能的代码:
; Fills an array with a random sequence of 32-bit signed
; integers between LowerRange and (UpperRange - 1).
; Returns: nothing
;-----------------------------------------------------------
mov
edi,pArray
; EDI points to the array
mov
ecx,Count
; loop counter
mov
edx,UpperRange
sub
edx,LowerRange
; EDX = absolute range (0..n)
cld
; clear direction flag
L1:
mov
eax,edx
; get absolute range
call
RandomRange
add
eax,LowerRange
; bias the result
stosd
; store EAX into [edi]
loop
L1
ret
FillArray ENDP
END
此代码的流程如下:
1. 将 edi 指向数组。
2. 设置循环计数器 ecx 。
3. 计算绝对范围并存储在 edx 中。
4. 清除方向标志。
5.
超级会员免费看
订阅专栏 解锁全文

1194

被折叠的 条评论
为什么被折叠?



