Computer-Architecture - Scott Bren#203
Conversation
| 0b00000001 // HLT | ||
|
|
||
|
|
||
| // Testing Mult instruction |
There was a problem hiding this comment.
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."
| stack[operandA]; | ||
| cpu->PC = cpu->registers[operandA]; | ||
|
|
||
| cpu_ram_read(cpu, cpu->PC); |
There was a problem hiding this comment.
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.
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.
Not entirely sure how you can call the right instruction this way.
Computer-Architecture - Scott Bren
@Tulf
Day 1: Get
print8.ls8runningstruct cpuincpu.hcpu_ram_readandcpu_ram_writecpu_init()cpu_run()HLTinstruction handlerLDIinstructionPRNinstructionDay 2: Add the ability to load files dynamically, get
mult.ls8andstack.ls8runningcpu_loadfunction to load an.ls8file given the filename passed in as an argumentmult8.ls8)stack.ls8programDay 3: Get
call.ls8runningcall.ls8programStretch