Hello, I attempted to create a linked list in Assembly which takes the values from x and stores them into the list LinkNode. While it does work properly in doing this, I am unable to get any calls to procedures to work after calling my GetLink procedure. The calls seem to work if I comment out

mov esi, edx

specifically. Can anyone tell me why calls to procedures dont work after my call to GetLink?

INCLUDE Irvine32.inc

LLNode STRUCT
	NodeData dword 0
	NextNode dword 0
LLNode ENDS

Counter = 0

.data
x sdword 100, -100, 200, -200, -300, 300

LinkNode LLNode {6}

GetLink PROTO

.code
main PROC

invoke GetLink

mov esi,offset LinkNode
NextNode:

	mov eax,[esi].LLNode.NodeData
	cmp eax, NULL
	je quit
	
	;mov eax, [esi].LLNode.NodeData
	mov eax, (LLNode PTR [esi]).NodeData
	call WriteInt
	call Crlf
	
	mov esi, [esi].LLNode.NextNode
	jmp NextNode
quit:

exit
main ENDP

GetLink Proc USES esi edi edx ebx
	
	mov ecx, 6
	
	mov esi, offset LinkNode
	mov edi, offset x
	mov edx, offset LinkNode + type LinkNode
	
	StackData:
		mov ebx, [edi]
		
		mov (LLNode PTR [esi]).NodeData, ebx
		mov (LLNode PTR [esi]).NextNode, edx
		
		;mov [esi].LLNode.NodeData, ebx
		;mov [esi].LLNode.NextNode, edx
		
		
		call dumpregs
		mov esi, edx
		add edx, type LinkNode
		add edi, type x
	loop StackData
	

	mov [esi].LLNode.NodeData, 0
	ret
GetLink ENDP

END main

Have you plotted this on paper?
esi is 1st node
edx is next node
esi[0] save data
esi = edx
esi[1] save data

esi[5] save data
esi=edx
esi[6]=0 <---- mov [esi].LLNode.NodeData, 0
You're writing into index #6, which is a stack overwrite.

Thanks for heads up, I missed the fact that the linked list i had made was one short. I went back and extended the length one more, and tested the program but it still yields the same result unfortunately.

I changed from

LinkNode LLNode {6}

To

LinkNode LLNode {7}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.