簡體   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