-
Notifications
You must be signed in to change notification settings - Fork 6
Computer-Architecture - Scott Bren #203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
smbren
wants to merge
16
commits into
bloominstituteoftechnology:master
Choose a base branch
from
smbren:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 15 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b534a9e
initial commit
smbren d6d31d4
working on cpu_init() method
smbren af2e45e
cpu_init initializes PC, registers, and ram to 0
smbren 09ee131
working on cpu_run
smbren 1775f6f
fixed cpu_run
smbren 39c12cd
working on reading from files
smbren 2209395
added MUL instruction
smbren b166ef5
working on reading from a file
smbren 93b85a6
working on reading from a file
smbren 44eed72
fixed loading instructions from ls8 files
smbren e0a7c49
working on system stack
smbren 49922c4
system stack added, stack.ls8 runs
smbren b571fe1
fixed a bug in system stack
smbren 0937a08
working on CALL and RET instructions
smbren 751d167
working on CALL instruction
smbren 21938c4
all tests pass MVP complete
smbren File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,28 @@ | ||
| #include <stdio.h> | ||
| #include "cpu.h" | ||
| #include <stdlib.h> | ||
|
|
||
| /** | ||
| * Main | ||
| */ | ||
| int main(void) | ||
| int main(int argc, char **argv) | ||
| { | ||
| struct cpu cpu; | ||
| char *program; | ||
|
|
||
| cpu_init(&cpu); | ||
| cpu_load(&cpu); | ||
| cpu_run(&cpu); | ||
| if (argc < 2) { | ||
| fprintf(stderr, "Please specify which program the LS8 should run.\nUsage: ls8 program\n"); | ||
| exit(1); | ||
|
|
||
| } else { | ||
| program = argv[1]; | ||
|
|
||
| printf("%s\n", program); | ||
|
|
||
| cpu_init(&cpu); | ||
| cpu_load(&cpu, program); | ||
| cpu_run(&cpu); | ||
| } | ||
|
|
||
| return 0; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be writing to RAM instead:
cpu_ram_write(cpu, stack[sp], cpu->pc+2);But the way you setup your stack will conlfict with this. It may be easier for you to just create push and pop functions to increment and derement the stack pointer and then write the value you want to push to ram at the stack pointer.
Something like this:
push (struct *cpu, unsigned char val): { cpu->registers[sp] --; cpu_ram_write(cpu, val, cpu->reg[sp]); }There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So with what you're doing I think you're just reading from RAM at the program count, and never even referencing the stack.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure how you can call the right instruction this way.