main.cpp
#include <stdio.h>
#include <stdlib.h> //srand function

extern "C" bool ReverseArray(int* y, const int* x, int n);

int main(int argc, char* argv[])
{
	const int n = 21;
	int x[n], y[n];
	
	// Initialize test array
	srand(31);
	for (int i = 0; i < n; i++)
		x[i] = rand() % 1000;
	
	if(ReverseArray(y, x, n)){
	
		printf("\nResults for ReverseArray\n");
		for (int i = 0; i < n; i++)
		{
			printf("  i: %2d  y: %5d  x: %5d\n", i, y[i], x[i]);
			if (x[i] != y[n - 1 - i])
				printf("  Compare failed!\n");
		}
	}else{
		printf("n cannot be negative\n");
	}
	return 0;
}
reversearray.asm
; Name:     reversearray.asm
;
; Build:    g++ -m32 -c main.cpp -o main.o
;           nasm -f elf32 -o reversearray.o reversearray.asm
;           g++ -m32 -o reversearray reversearray.o main.o
;
; Source:   Modern x86 Assembly Language Programming p.83

global  ReverseArray

section .text

; extern "C" bool ReverseArray(int* y, const int* x, int n);
;
; Description:  The following function saves the elements of array 'x'
;               to array 'y' in reverse order.
;
; Returns       0 = Invalid 'n'
;               1 = Success

%define y   [ebp+8]
%define x   [ebp+12]
%define n   [ebp+16]

ReverseArray:
    push    ebp
    mov     ebp,esp
    push    esi
    push    edi
    ; Load arguments, make sure 'n' is valid
    xor     eax,eax                 ;error return code
    mov     ecx,n                   ;ecx = 'n'
    test    ecx,ecx
    jle     .error                  ;jump if 'n' <= 0
    ; Initialize pointer to x[n - 1] and direction flag
    mov     esi, x
    lea     esi,[esi+ecx*4-4]       ;esi = &x[n - 1]
    pushfd                          ;save current direction flag
    std                             ;EFLAGS.DF = 1
    mov     edi, y                  ;edi = *y
    ; Repeat loop until array reversal is complete
.repeat:
    lodsd                           ;eax = *x--
    mov     [edi],eax               ;*y = eax
    add     edi,4                   ;y++
    dec     ecx                     ;n--
    jnz     .repeat
    popfd                           ;restore direction flag
    mov     eax,1                   ;set success return code
.error:  
    pop     edi
    pop     esi
    pop     ebp
    ret
build
g++ -m32 -c main.cpp -o main.o
nasm -f elf32 -o reversearray.o reversearray.asm
g++ -m32 -o reversearray reversearray.o main.o