Andre Myrick - Computer Architecture#201
Conversation
codejoncode
left a comment
There was a problem hiding this comment.
It wasn't needed today but maybe needed down the road add a flag to your cpu struct unsigned char FL;
codejoncode
left a comment
There was a problem hiding this comment.
great job Andre looks like you should be able to read files.
There was a problem hiding this comment.
unsigned char operandA = ram[(cpu->PC + 1) & 0xff];
unsigned char operandB = ram[(cpu->PC + 2) & 0xff];
// True if this instruction might set the PC
int instruction_set_pc = (IR >> 4) & 1;
//Above^^^^^^^^^^^should before the while loop
// increase PC after the switch
if (!instruction_set_pc) {
cpu->PC += ((IR >> 6) & 0x3) + 1;
}
//this is because the first 2 bits to the left of the instruction will tell you how many operands
this will prevent you from having to use two switch statements.
Some more advance stuff but you could do this instead of incrementing on each individual switch. I know you're usually interested in less lines.
Day 1: Get
print8.ls8runningstruct cpuincpu.hcpu_ram_readandcpu_ram_writecpu_init()cpu_run()HLTinstruction handlerLDIinstructionPRNinstructionDay 2: Add the ability to load files dynamically, get
mult.ls8andstack.ls8runningcpu_loadfunction to load an.ls8file given the filename passed in as an argumentmult8.ls8)stack.ls8programDay 3: Get
call.ls8runningcall.ls8programStretch