-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Consider the below code
set [someOtherProgram + 0], 0xac02 ;add a, 10
set [someOtherProgram + 1], 0xac02 ;add 1, 10
set [someOtherProgram + 2], 0x8781 ;set pc, 0
:someOtherProgram
A lot of kernels do this (i.e, for loading a program from disk to memory) however DCPU16-IDE fails this test due to the following line (694) of code in emulator.js on the first if statement.
this.step = function() {
if(this.PC.get() < this.program.length) {
this.nextInstruction();
if(this.attachedDebugger && this.paused)
this.attachedDebugger.onStep(this.PC.get());
// process one interrupt if we have one
if(this.interruptQueueingEnabled == false && this.interruptQueue.length > 0) {
this.processInterrupt(this.interruptQueue.shift());
}
return true;
}
else return false;
};
The fix would be to simply remove the if statement. A DCPU program never really ends. If you change this, PC can grow to an invalid value (ie, outside the bounds of 16 bit register) due to the increments on step. So this fix also requires another change (most safely in Emulator.js line 12:
Register.prototype.set = function(val) { this.contents = val & 0xFFFF; }
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels