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

	NodeData dword 0
	NextNode dword 0

Counter = 0

x sdword 100, -100, 200, -200, -300, 300

LinkNode LLNode {6}


main PROC

invoke GetLink

mov esi,offset LinkNode

	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

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
		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
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[6]=0 <---- mov [esi].LLNode.NodeData, 0
You're writing into index #6, which is a stack overwrite.

Edited 6 Years Ago by wildgoose: n/a

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}


LinkNode LLNode {7}
This article has been dead for over six months. Start a new discussion instead.