auto remove unreachable instructions when executing ram machine
This commit is contained in:
parent
5169952816
commit
f2204df7d7
@ -128,7 +128,7 @@ int main() {
|
|||||||
fprintf(stderr, "Error creating file machine.py\n");
|
fprintf(stderr, "Error creating file machine.py\n");
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
fprintf(file, "from ram import *\n\n%s\nram = Ram(instructions, input_registers)\nram.execute()\nprint(\"Result:\", ram.output_registers)\n", result);
|
fprintf(file, "from ram import *\n\n%s\nram = Ram(instructions, input_registers)\nram.remove_unreachable_instr()\nram.execute()\nprint(\"Result:\", ram.output_registers)\n", result);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2,5 +2,10 @@
|
|||||||
ADD(i0 ,1 ,r0)
|
ADD(i0 ,1 ,r0)
|
||||||
SUB(i1,3,r1)
|
SUB(i1,3,r1)
|
||||||
|
|
||||||
|
JUMP(2)
|
||||||
|
DIV(10,2,r1) // unreachable
|
||||||
|
|
||||||
MULT(r1,r0,o1)
|
MULT(r1,r0,o1)
|
||||||
ADD(5, i@i2, o2)
|
ADD(5, i@i2, o2)
|
||||||
|
JUMP(2)
|
||||||
|
JUMP(-5) // unreachable
|
||||||
|
Loading…
x
Reference in New Issue
Block a user