Homemade BIOS sketch problem.

Hi Arduino Forum!

I'm making a simple "homemade" computer.

I'm making a BIOS for my pc to simplify the operations.

Also i added 8 virtual registers for my BIOS sketch.

But i have a problem. My "move" void is not working.

My code:

typedef int Register;

void Mov(Register x, Register y);

Register VAX, VBX, VCX, VDX, VEX, VGX, VHX;

void Mov(Register x, Register y)
{
  x = y;
}

void setup()
{
  Serial.begin(9600);
  Mov (VAX, 15);
}

void loop()
{
 Serial.println(VAX);
}

But the serial output is always 0. My "mov" function doesn't change the VAX's value.

But if i write "VAX = 15;" instead of "Mov (VAX, 15);" there is no problem.

Is there a fix for it? I'm using Arduino Software 1.6.5 and Arduino Board Uno.

Thanks :)

You need to pass your variables by reference, otherwise you just work with local copies.

void Mov(Register &x, Register y) { ** x = y;** }

The left hand side is a reference now.

pYro_65: You need to pass your variables by reference, otherwise you just work with local copies.

void Mov(Register &x, Register y) { ** x = y;** }

The left hand side is a reference now.

Wow thanks! It worked. Thank you very much.