Scope Woes

  • Thread starter Thread starter Yuri Vanzine
  • Start date Start date
Y

Yuri Vanzine

I have a class with a private member function:

void H6809_CPU::StoreWord(Word Data, Word Address)
{
Memory[Address] = Data >> 8; // High byte of Data
Memory[Address+1] = Data & 0xFF; // Low byte of X
cout<<"Inside Store Word:"<<MemoryWord(Address)<<endl;
}
I call it from another public member function:

cout<<hex<<PC<<endl;
StoreWord(PC,MemoryWord(SP));
cout<<hex<<MemoryWord(SP)<<endl;

MemoryWord(SP) reads 2 elems of the Memory array (private member):

HighByte = Memory[Address];
LowByte = Memory[Address+1];

Here is the problem:

When I run MemoryWord(Address) inside the StoreWord func, I get good values,
but if I run MemoryWord(SP) outside of the StoreWord func, I get
uninitialized 0

Please help!!!!!

yv
 
Dear Yuri,

Would you please provider more details ?
I think you have a problem initializing one or more variable.

I tried this code on VC++ 6.0 and it is working without problems

You may use the debugger to check what is going on

Thanks,
Mohamed
 
Back
Top