내 배열을 뒤집는 작업을하고 있는데, 코드를 이미 인쇄 했으므로 두 번째 배열을 만들어서 저장하고 그 중 하나를 인쇄하는 것이 더 쉬운 방법일까요?nasm 어셈블리에서 어레이를 반전하는 가장 효과적인 방법은 무엇입니까?
segment .bss
newarray resd 40
segment .data
arrayis db "Inverted Array is: ", 0
space db ", ", 0
thanks db "Thanks", 0
segment .text
extern readdouble,print_string, read_int, writedouble, print_nl, print_int
global invertarray
invertarray:
pusha
mov ebx, [ebp] ;moves starting location of array1 into ebx
mov edi, [ebp+12] ;move quantity into edi
mov esi, 0 ;set esi to 0
mov eax, arrayis ;
call print_string ;
fld qword [ebx]
mov ecx, [ebx] ;move higher order into ecx
mov edx, [ebx+4] ;move lower order into edx
call writedouble
mov eax, space ;
call print_string ;
topofloop:
mov ecx, [ebx] ;move higher order into ecx
mov edx, [ebx+4] ;move lower order into edx
fld qword [ebx] ;move the first item of the stack onto st0
add ebx, 8 ;increment to next location
inc esi
mov ecx, [ebx] ;move first set of bits
mov edx, [ebx+4] ;move the second set of bits
call writedouble ;write the number
mov eax, space ;
call print_string ;
cmp esi, edi ;compare to see if all items have been printed
jz done_loop ;
jmp topofloop ;go back to top of the loop
done_loop:
popa
ret
윙윙 거리는 소리를 듣지 않으시겠습니까? – John
도움이되기를 바랍니다. http://classes.engr.oregonstate.edu/eecs/winter2011/cs271/resources/demo6.asm – Spyros