| | |
Question on CPU Simulator
Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Oct 2006
Posts: 3
Reputation:
Solved Threads: 0
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?
Also when declaring
#define STA 1
for the switch statement, the "1" above - can it be arbitary - or should it be related to OpCode?
Thanks
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?
Also when declaring
#define STA 1
for the switch statement, the "1" above - can it be arbitary - or should it be related to OpCode?
Thanks
You will want to use the numbers that are assigned to the mnuemonics. It looks like you are creating a 6502 simulator. In that case, use the information located here:
http://www.6502.org/tutorials/6502opcodes.html
Nathan.
http://www.6502.org/tutorials/6502opcodes.html
Nathan.
while (CPU is present) {some assembly required}
![]() |
Similar Threads
- motherboard or CPU? (Troubleshooting Dead Machines)
- need help with cpu question (Motherboards, CPUs and RAM)
- Buying second hand cpus? (Motherboards, CPUs and RAM)
- Help with a crashed PC (Troubleshooting Dead Machines)
- Presario 700- won't do anything! (Troubleshooting Dead Machines)
- Buiding A NEW COMPUTER (Troubleshooting Dead Machines)
- Help me with my HijackThis log (Viruses, Spyware and other Nasties)
Other Threads in the Assembly Forum
- Previous Thread: Reverse String - Assembly Language
- Next Thread: assembly code alteration for real time clock controller
| Thread Tools | Search this Thread |
Tag cloud for Assembly





