Skip to content

Kevin Sooter - Computer-Architecture#202

Open
kevin-sooter wants to merge 12 commits into
bloominstituteoftechnology:masterfrom
kevin-sooter:master
Open

Kevin Sooter - Computer-Architecture#202
kevin-sooter wants to merge 12 commits into
bloominstituteoftechnology:masterfrom
kevin-sooter:master

Conversation

@kevin-sooter
Copy link
Copy Markdown

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.

Kevin you should be updating cpu->ram we don't need data anymore.

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.

Looks Good Kevin getting MUL to work nicely.

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.

// 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.

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.

ret = strtoul(c, &endptr, 2); inside of cpu_load lets make ret = strtol(line, &endchar, 2);

in cpu_load function

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.

char c[100] lets make a little bigger char c[1024]

also change your while loop while (fgets(line, sizeof line, fp) != NULL)

in cpu_load function

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.

// Open the source file in Cpu_load function

FILE *ptr; 
  if ((ptr = fopen(argv, "r")) == NULL) {
    fprintf(stderr, "Cannot open file %s\n", filename);
    exit(2);
  }

This condidtion should help us spot errors if there are any.

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.

FILE *fptr;
  if ((fptr = fopen(argv[1], "r")) == NULL)
  {
    printf("No such file.\n");
    exit(1);
  }
  fclose(fptr);

No need for this to be in the main loop this should be in your cpu_load function.

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