繁体   English   中英

如何用Irvine汇编语言反转数组?

[英]How to reverse an array in Irvine Assembly Language?

我正在编写一个数字操作程序,其中一个步骤是反转数组。 到目前为止,我有

reverseArray proc
mov eax, arraySize
mov temp, eax
Imul eax, 4
mov esi, eax
mov eax, 0
mov number, 0
jne L1
L1: 
cmp temp, 0
je L3

mov eax, numbers[esi]
mov tempnumbers[ecx], eax

mov eax, tempnumbers[ecx]
call writeDec
call crlf


sub esi,4
add ecx, 4
sub temp, 1

loop L1


L2:
ret


L3:

.If(number >= 0)

 mov esi, 0
.ENDIF
mov eax, number
cmp eax, arraySize
je L2


mov eax, tempnumbers[esi]
mov numbers[esi], eax

add esi, 4
add number, 1
loop L3

但是,这只反转了我数组的一半。 我在esi或ecx计数器上做错什么了吗? 任何帮助,将不胜感激。

使用edi代替ecx,并在开始时将其设置为0。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM