Skip to content

Computer-Architecture - Scott Bren#203

Open
smbren wants to merge 16 commits into
bloominstituteoftechnology:masterfrom
smbren:master
Open

Computer-Architecture - Scott Bren#203
smbren wants to merge 16 commits into
bloominstituteoftechnology:masterfrom
smbren:master

Conversation

@smbren
Copy link
Copy Markdown

@smbren smbren commented Mar 4, 2019

Computer-Architecture - Scott Bren

@Tulf

Day 1: Get print8.ls8 running

  • Inventory what is here
  • Implement struct cpu in cpu.h
  • Add RAM functions cpu_ram_read and cpu_ram_write
  • Implement cpu_init()
  • Implement the core of cpu_run()
  • Implement the HLT instruction handler
  • Add the LDI instruction
  • Add the PRN instruction

Day 2: Add the ability to load files dynamically, get mult.ls8 and stack.ls8 running

  • Un-hardcode the machine code
  • Implement the cpu_load function to load an .ls8 file given the filename passed in as an argument
  • Implement a Multiply instruction and Print the result (run mult8.ls8)
  • Implement the System Stack and be able to run the stack.ls8 program

Day 3: Get call.ls8 running

  • Implement the CALL and RET instructions
  • Implement Subroutine Calls and be able to run the call.ls8 program

Stretch

  • Add the timer interrupt to the LS-8 emulator
  • Add the keyboard interrupt to the LS-8 emulator

Comment thread ls8/cpu.c Outdated
0b00000001 // HLT


// Testing Mult instruction
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Great you're commenting out the instructions and the switch to the registers. A rather cumbersome process but I hope it's demystifying the "black box for you."

Comment thread ls8/cpu.c Outdated
stack[operandA];
cpu->PC = cpu->registers[operandA];

cpu_ram_read(cpu, cpu->PC);
Copy link
Copy Markdown

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

Copy link
Copy Markdown

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.

Copy link
Copy Markdown

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.

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