Skip to content

Ian Cameron Computer Architecture#207

Open
codypeak wants to merge 21 commits into
bloominstituteoftechnology:masterfrom
codypeak:master
Open

Ian Cameron Computer Architecture#207
codypeak wants to merge 21 commits into
bloominstituteoftechnology:masterfrom
codypeak:master

Conversation

@codypeak
Copy link
Copy Markdown

@codypeak codypeak commented Mar 4, 2019

No description provided.

Copy link
Copy Markdown

@codejoncode codejoncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It wasn't needed today but maybe needed down the road add a flag to your cpu struct unsigned char FL;

Copy link
Copy Markdown

@codejoncode codejoncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a decent base for handling files.

Copy link
Copy Markdown

@codejoncode codejoncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

@codejoncode codejoncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
}

Copy link
Copy Markdown

@codejoncode codejoncode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

push(cpu, operandA); in your push should be push(cpu, cpu->reg[operandA]);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants