#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    47
    Rep Power
    0

    Reverse Array is returning all 0s'


    For some reason I am getting back all 0s' when I run this process in my program.

    Code:
    ;------------------
    ;Reverse the array.
    ;------------------
    reverseArray PROC
    	
    	mov ecx, lengthof the_array / 2
    	mov edx, offset the_array
    	add edx, sizeof the_array
    	sub edx, type the_array
    	mov esi, offset the_array
    	
    		L2:
    			mov eax, [esi]
    			mov ebx, [edx]
    			mov [esi], ebx
    			mov [edx], eax
    			sub edx, 4
    			add esi, 4
    		loop L2
    	
    ret
    reverseArray ENDP
    The array get accepted for example if I put in 3 6 9. I'll get back a 0 0 0 after I run the process when I should be getting back 9 6 3. I have been banging my head against a wall trying to figure it out. This code should work since I have used it in the past with success. I just don't see what's different.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    47
    Rep Power
    0
    Sorry if I forgot to mention but this is being coded in assembly. Using the Irvine32 library.
  4. #3
  5. /usr/bin/drinking
    Devshed Novice (500 - 999 posts)

    Join Date
    Jul 2004
    Posts
    719
    Rep Power
    1885
    Been years since I did anything with assembly, but my first check would be to make sure that it has read in the array correctly. ie print out what you enter.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2007
    Posts
    47
    Rep Power
    0
    Originally Posted by Muzza
    Been years since I did anything with assembly, but my first check would be to make sure that it has read in the array correctly. ie print out what you enter.
    That was my first guess but I call my printArray before I call my reverseArray and I got back the correct results. So putting in 3 6 9 prints 3 6 9 only after I call reverseArray does the array print as 0 0 0.

IMN logo majestic logo threadwatch logo seochat tools logo