Ian Cameron Computer Architecture#207
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.
You have a decent base for handling files.
codejoncode
left a comment
There was a problem hiding this comment.
int main(int argc, char **argv)
{
struct cpu cpu;
if (argc != 2) {
fprintf(stderr, "usage: ls8 file.ls8\n");
return 1;
}
cpu_init(&cpu);
cpu_load(argv[1], &cpu);
cpu_run(&cpu);
return 0;
}
If you update your main function like this you will need to make an adjustment in your cpu_load but it will be ready for arguments passed on the command line from there the code is a lot like the code provided in this mornings lecture. Major difference is your lines will be added to index's in cpu->ram
codejoncode
left a comment
There was a problem hiding this comment.
Push looks good. This could have been done without using the write function
void cpu_push(struct cpu *cpu, unsigned char val)
{
cpu->reg[7]--;
cpu->ram[cpu->reg[7]] = val;
}
codejoncode
left a comment
There was a problem hiding this comment.
push(cpu, operandA); in your push should be push(cpu, cpu->reg[operandA]);
No description provided.