the error is in AfterLoop skope in the line " mov [esi], [edi]" . how can I resolve this issue? ; The function for node removing (headptr, nodeToremove)
removeNode proc
headPtr = 8
nodeToRemove = headPtr + 4
push ebp
mov ebp, esp
push esi
push edi
push ebx
mov esi, headPtr[ebp] ; esi = head of list
mov edi, [esi] ; edi = second item
cmp esi, nodeToRemove[ebp] ; head = nodeToRemove?
jne NextNode
mov edi, esi ; edi ( = currNode) = head
mov esi, [esi] ; new head = head->next
jmp AfterLoop
NextNode:
cmp edi, nodeToRemove[ebp] ; currNode = node to remove?
je AfterLoop
mov esi, edi ; prev node = currNode
mov edi, [edi] ; currNode = currNode->next
jmp NextNode
AfterLoop:
mov [esi], [edi] ; error!!! prev->next = curr->next
pop ebx
pop edi
pop esi
pop ebp
ret 8
removeNode endp
mem, mem
is not a valid combination of operands. Use a register as an intermediate, e.g.:Alternatively, if you can swap
esi
andedi
you could usemovsd
:(Note: the
+= 4
is true assuming that the direction flag is clear. Otherwise it will be-= 4
. Shouldn't matter in your case since youpop
esi
andedi
immediatly afterwards).