Question on CPU Simulator

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Oct 2006
Posts: 3
Reputation: sciconf is an unknown quantity at this point 
Solved Threads: 0
sciconf sciconf is offline Offline
Newbie Poster

Question on CPU Simulator

 
0
  #1
Oct 1st, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2005
Posts: 130
Reputation: Evenbit is on a distinguished road 
Solved Threads: 4
Evenbit's Avatar
Evenbit Evenbit is offline Offline
Junior Poster

Re: Question on CPU Simulator

 
0
  #2
Oct 6th, 2006
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.
while (CPU is present) {some assembly required}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC