class Register
{
private:
DWORD ax,dx,cx,bx; // POH
DWORD bp,sp;
DWORD flag, ip;
public:
//====================================================
Register()
{
ax = 0x0;
dx = 0x0;
cx = 0x0;
bx = 0x0;
bp = 0x0;
memset(&this->sp,0,sizeof(sp));
sp = 0x0;
flag = 0x0;
ip = 0x0;
}
//====================================================
~Register()
{
}
//====================================================
void setAx(DWORD d)
{
ax=d;
}
//====================================================
void setDx(DWORD d)
{
dx=d;
}
//====================================================
void setCx(DWORD d)
{
cx=d;
}
//====================================================
void setBx(DWORD d)
{
bx=d;
}
//====================================================
void setBp(DWORD d)
{
bp=d;
}
//====================================================
void incSp()
{
sp = sp+1;
}
void decSp()
{
if(sp == 0)
{
sp = 0;
}
sp = sp - 1;
}
//====================================================
void setFlag(DWORD d)
{
flag=d;
}
//====================================================
void setIp(DWORD d)
{
ip=d;
}
//====================================================
DWORD getAx()
{
return ax;
}
//====================================================
DWORD getDx()
{
return dx;
}
//====================================================
DWORD getCx()
{
return cx;
}
//====================================================
DWORD getBx()
{
return bx;
}
//====================================================
DWORD getBp()
{
return bp;
}
//====================================================
DWORD getSp()
{
return this->sp;
}
//====================================================
DWORD getFlag()
{
return flag;
}
//====================================================
DWORD getIp()
{
return ip;
}
//====================================================
};
Why when i use getSp(); function like this:
PReg->getSp();
it gives me an AV error, I traced this variable at the point where I initialize it gives me a random number insted of zero, which I set to and at the point of problem function the sp variable is "????" ?
Register *PReg; - PReg :)
PReg? - MatPReg? - 逆さまRegister? - ChadPReg? If you aren't then it is garbage and would likely result in an access violation. - Michael Price