I'm trying to better understand the assembly, and I'm a bit confused about how to call functions recursively when I have to deal with registers, popping / pushing, etc.
I embed the x86 assembly in C ++. Here I am trying to make a method that defines an array of integers that will build a linked list containing these integers in the order they appear in the array.
I do this by calling a recursive function:
insertElem (struct elem *head, struct elem *newElem, int data)
-head: list header
-data: the number to be inserted at the end of the list
-newElem: indicates the place in memory where I will store the new element (data field)
My problem is that I rewrite registers instead of a typical linked list. For example, if I pass the array {2,3,1,8,3,9} to it, my linked list will return the first element (head) and only the last element, since the elements will overwrite each other after the head is no more than null.
So my linked list looks something like this: 2 → 9 instead of 2 → 3 → 1 → 8 → 3 → 9
It seems to me that I do not understand how to organize and process registers. newElem is in EBX and just keeps on texting. Thanks in advance!
Davis source
share