Hi
I am doing a project of simulating a CPU using my pc and Turbo C.
I have,
void execInst(int inst)
{
int opCode;
int operand;
opCode = inst >> 8;
operand = inst & 0xff;
switch (opCode) {
// default: Handle illegal instruction here.
case LDA:
Cpu.a = operand;
break;
case STA:
Mem[operand] = Cpu.a;
break;
----
}
----
}
What is the justification for "8" above and also for "0xff" ? Are they correct?
I am doing a project of simulating a CPU using my pc and Turbo C.
I have,
void execInst(int inst)
{
int opCode;
int operand;
opCode = inst >> 8;
operand = inst & 0xff;
switch (opCode) {
// default: Handle illegal instruction here.
case LDA:
Cpu.a = operand;
break;
case STA:
Mem[operand] = Cpu.a;
break;
----
}
----
}
What is the justification for "8" above and also for "0xff" ? Are they correct?