主题:[讨论]哪里出问题了???
自己写的一个完整程序:
#include <iostream.h>
#include <stdlib.h>
#include "Afx.h"
fun(unsigned long *addr)
{
_asm{
push eax
mov eax, [addr]
pop eax
}
}
void main ()
{
unsigned long begin = GetTickCount();
for ( int i = 1; i < 10 ; ++i)
{
for ( int j = 1; j <= i ; ++j )
{
cout << j << "x" << i << " = " << i * j << " ";
if ( j == i)
{
cout << endl;
}
}
}
unsigned long cost_ms = GetTickCount() - begin;
unsigned long *addr = &cost_ms ;
fun( addr);
cout << cost_ms << endl;
}
以上这个程序在传参数的过程中为什么不能得到那个地址中的值啊,在调试的过程中还是只得到那个地址的值,而地址中的值却获取不到,而改写一下就能得到其传递过来的地址中的值,改写如下:
mov eax, addr
mov edx, [eax]
这样调试一下就能得到其地址中的值,为什么不改写直接用mov eax,[addr]就不能获得其中的值呢?
有谁帮忙说说吗?先谢谢了!~&~[em2]
#include <iostream.h>
#include <stdlib.h>
#include "Afx.h"
fun(unsigned long *addr)
{
_asm{
push eax
mov eax, [addr]
pop eax
}
}
void main ()
{
unsigned long begin = GetTickCount();
for ( int i = 1; i < 10 ; ++i)
{
for ( int j = 1; j <= i ; ++j )
{
cout << j << "x" << i << " = " << i * j << " ";
if ( j == i)
{
cout << endl;
}
}
}
unsigned long cost_ms = GetTickCount() - begin;
unsigned long *addr = &cost_ms ;
fun( addr);
cout << cost_ms << endl;
}
以上这个程序在传参数的过程中为什么不能得到那个地址中的值啊,在调试的过程中还是只得到那个地址的值,而地址中的值却获取不到,而改写一下就能得到其传递过来的地址中的值,改写如下:
mov eax, addr
mov edx, [eax]
这样调试一下就能得到其地址中的值,为什么不改写直接用mov eax,[addr]就不能获得其中的值呢?
有谁帮忙说说吗?先谢谢了!~&~[em2]