任何帮助都是无济于事的,我好几天都无法确定。
我有一套链接列表。例如: 0,0,0,0,0或1,1,1,1或-10,-5,0,5,10
我可以访问链接列表的第一个元素很好!第一个是堆栈,但第二个不在堆栈内存中。
下面是我访问链接列表的第一个值元素的代码
__declspec(naked) int valueLink(struct Node *head) {
__asm{
PUSH EBX
MOV EBX, [ESP+8] //get the address of the first element of linked list on the stack
MOV EAX, [EBX] // move the value to EAX
POP EBX
ret
}
}我会得到正确的输出如下:
该列表包含-1、-1、-1、-1、-1,正和为0。你的结果是-1。
列表包含1,1,1,1,1,1和5。
这个列表包含-10,-5,0,5,10,正和15。你的结果是-10。
但是现在我要访问链接列表的第二个值,我修改了代码->
__declspec(naked) int valueLink(struct Node *head) {
__asm{
PUSH EBX
MOV EBX, [ESP+8] //get the address of the first element of linked list on the stack
MOV EAX, [EBX+4] // move the second value to EAX
POP EBX
ret
}
}我会得到错误的价值!帮帮忙?!
该列表包含-1、-1、-1、-1、-1,正和为0。你的成绩是4760640
该列表包含1,1,1,1,1,1和5。结果是4760920。
这个列表包含-10,-5,0,5,10,正和15。你的结果是4769096。
发布于 2014-03-08 03:35:28
我没有看到在您的示例中定义的链接列表中节点的结构。假设使用next和value定义了一个名为node的结构,那么该节点的语法并从ebx指向的节点中添加一个值是:
node struct
next dd ?
value dd ?
node ends
; ...
add eax,node.value[ebx]
; ...https://stackoverflow.com/questions/22264597
复制相似问题