diff --git a/src/ram.y b/src/ram.y index 130471c..f356dc5 100644 --- a/src/ram.y +++ b/src/ram.y @@ -128,7 +128,7 @@ int main() { fprintf(stderr, "Error creating file machine.py\n"); return 1; } 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); } return 0; diff --git a/src/test.asm b/src/test.asm index 8e85802..a403cfa 100644 --- a/src/test.asm +++ b/src/test.asm @@ -2,5 +2,10 @@ ADD(i0 ,1 ,r0) SUB(i1,3,r1) +JUMP(2) +DIV(10,2,r1) // unreachable + MULT(r1,r0,o1) ADD(5, i@i2, o2) +JUMP(2) +JUMP(-5) // unreachable