1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Accessing Array from ASM passed from C++?

Discussion in 'Assembly Language Programming (ALP) Forum' started by of1983vintage, Nov 27, 2006.

  1. of1983vintage

    of1983vintage New Member

    Nov 27, 2006
    Likes Received:
    Trophy Points:
    I've been studying assemby for about a semester now. I am having a horrible time figuring out how to access the data I pass from C++ to ASM. The data is a array of strings which I will have to sort in ASM and return a sorted array back to C++. The biggest problem I am having is accessing the data itself. The array is being passed at [ebp+8]... Any help with this is appreciated.

    This is the C++ code I'm working with;
    extern "C" int Sort (char [] [20], int, int);
    	Sort (Strings, 10, 20);
    	cout << "Sorted Strings are" << endl;
    	for (i = 0; i < 10; i++)
    		cout << '\t' << Strings [i] << endl;
    You can probably ignore my code, but I figure I would put it anyways;
    _Sort proc
    		push		ebp
    		mov			ebp, esp 
    		push		edi
    		mov			eax, [ebp+08]
    		mov			array_ptr, eax
    		mov			eax, [ebp+12]
    		mov			array_length, eax
    		mov			eax, [ebp+16]
    		mov			bytes_per_line, eax
    		mov			eax, array_length
    		cmp			eax, 0			;jump if array has length of 0
    		jnae		EndTRow
    		mov			ebx, found_length
    		inc			ebx			;add 1 to found_length's sum
    		cmp			ebx, eax	;jump if at last row
    		ja			EndTrow
    ;		mov			found_length, ebx
    		mov			eax, char_position
    		mov			ebx, bytes_per_line
    		cmp			eax, ebx
    		jnb			TRows
    ... ...and it becomes useless jargon here
    		pop			edi		
    		pop			ebp
    _Sort endp

Share This Page