/web-ide/simulator/src/cpu/cpu.ts wrongly updates the D register during the tick. Therefore the following sequence will fail:
@0
M=1 // init RAM[0]=1
D=1
MD=D+1
D is 2 as expected, but RAM[0] will be 3 !
The CPU simulator acts as follows:
cpuTick(): D=D+1
cpuTock(): outM=[updatedD]+1=[originalD]+1+1 // new ALU calculation is triggered
Finally tick() writes the wrong outM to the memory
Any computation involving D with destinationD set, will result in the wrong value written to memory.
i.e. AMD=D+A, etc.
Additional Comments
No response
Do you want to try to fix this bug?
[ ] I want to try to add this feature!
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Tool
CPU Emulator
Interface
Website (https://nand2tetris.github.io/web-ide)
Contact Details
No response
What happened?
/web-ide/simulator/src/cpu/cpu.ts wrongly updates the D register during the tick. Therefore the following sequence will fail:
D is 2 as expected, but RAM[0] will be 3 !
The CPU simulator acts as follows: cpuTick(): D=D+1 cpuTock(): outM=[updatedD]+1=[originalD]+1+1 // new ALU calculation is triggered Finally tick() writes the wrong outM to the memory
Any computation involving D with destinationD set, will result in the wrong value written to memory. i.e. AMD=D+A, etc.
Additional Comments
No response
Do you want to try to fix this bug?
Code of Conduct