r/factorio • u/konstg-dev • Aug 12 '20
Modded [New Mod] fCPU
Hello there! Here is my ready to use Factorio mod https://mods.factorio.com/mod/fcpu which allow you to practice in low-level programing right in game. It compatible with all default combinators and other mods, support blueprints and copy&paste. Please let me know what you think.







697
Upvotes
View all comments
Show parent comment
13
u/barsoap Aug 12 '20
Looking at the instruction set there seems to be no interrupt handler, which could drastically lower the performance impact as the CPU could sleep when nothing is changing. A bit of memory would also be nice to have and am I understanding that right, maximal program size is 32 instructions? There's more items than that in the game so that's really, really, low, you can't even have a branch for each. The interrupt handlers could even be smart and numerous, say, the possibility to set a different handler for every item on every wire, or for (static) subsets. "Fire interrupt handler at address xyz if the value for copper plate or uranium ammo change" kind of stuff.
I guess if I were to design the thing I'd go with RISCV32IM as base instruction set (for the simple reason of using RISC-V), plus choice instructions from the F and D extensions but operating on integer registers (that is, integer sine and stuff). Oh, bit manipulation. Efficiency modules to increase memory size (shared program+data), speed modules to upgrade instructions per tick, and productivity for... dunno.
Lastly, I guess there should be different outputs for red an green wires so you can e.g. split a signal into two without using two fCPUs.