Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   Accessing Array from ASM passed from C++? (http://www.go4expert.com/forums/accessing-array-asm-passed-cpp-t2018/)

of1983vintage 27Nov2006 10:55

Accessing Array from ASM passed from C++?
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

All times are GMT +5.5. The time now is 09:05.