我正在查看我的一门课程的模拟考试,我只是不明白问题的某些方面,所以也许你可以帮助我(如果你了解 x86,可能真的很容易)。
所以这是问题8: http ://www.coe.utah.edu/~cs4400/schedule/exam3.F10.pdf
解决方案在这里: http://www.coe.utah.edu/~cs4400/schedule/exam3_solns.F10.pdf \
我只是不明白解决方案中的值是如何获得的。让我来看看我是如何解释堆栈的:
08048510 <callfoo>:
08048510: 55 pushl %ebp # old frame pointer is pushed to the stack
08048511: 89 e5 movl %esp,%ebp # frame pointer = stack pointer
08048513: 83 ec 08 subl $0x8,%esp # allocates 8 bytes for stack
08048516: 83 c4 f4 addl $0xfffffff4,%esp # this I believe allocates 4 bytes to the stack??
08048519: 68 9c 85 04 08 pushl $0x804859c # push string address
0804851e: e8 d1 ff ff …Run Code Online (Sandbox Code Playgroud) 我似乎无法弄清楚如何使这个功能工作.重要的是要看到tStat = xmlhttp2.responseText似乎被延迟了.我用.innerHTML + ="withintest"+ Stat来测试它.它打印出"内部测试内部测试0".所以它做了几次迭代,直到它有值?0是我想要的Stat值,checktStatus.php从数据库中获取它.
但由于此函数返回一个值,并且我将其从另一个函数调用到该值的变量中,因此在返回之前不能延迟DB读取.但我无法弄清楚如何实现这一目标!救命?
编辑:拿出一些注释代码,但问题仍然存在.它返回一个"未定义"值,然后才能得到一个真值.
function gettStatus()
{
var tStat;
if (window.XMLHttpRequest)
{ // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp2=new XMLHttpRequest();
}
else
{ // code for IE6, IE5
xmlhttp2=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp2.onreadystatechange=function()
{
if (xmlhttp2.readyState==4 && xmlhttp2.status==200)
{
tStat=xmlhttp2.responseText;
document.getElementById("txtHint").innerHTML+=" withintest "+tStat;
return tStat;
}
}
xmlhttp2.open("GET","checktStatus.php?tID=1",true);
xmlhttp2.send();
}
Run Code Online (Sandbox Code Playgroud)