furnace
advanced-furnace.mips
arc-furnace-room-control.mips
furnace-calc-pre.mips
furnace-ingot-recipe.mips
furnace-operate.mips
furnace-room-vacuum-pump.mips
hot-cold-waste-tank-manager.mips
hot-tank-filler.mips
pressurize-furnace.mips
waste-tank-to-cold-tank-with-chiller.mips
furnace-waste-chiller.mips

manufacturing
vend-ingots-to-printer.mips
vending-ore-counter-omni-fast.mips
vending-ore-counter-omni-slow.mips
vending-ore-counter-single.mipsr
vending-ore-counter-triple.mips

greenhouse
greenhouse-ac.mips
greenhouse-o2-pressure-display.mips
greenhouse-oxygen-harvest.mips
greenhouse-temperature.mips
harvie-triple.mips
seed-distributer.mips
seed-sorter-old.mips
seed-sorter.mips
stacker-vending-button.mips

atmospherics
base-atmosphere-control.mips
battery-room-atmosphere.mips
battery-room-vent-setter.mips
harvest-cold-atmosphere.mips
harvest-liquid-from-atmosphere.mips
refrigeration-room.mips

mining rocket
rocket-driving.mips
rocket-miner-readout.mips

ore warehousing
ore-sorter-multi.mips
ore-sorter2-multi.mips
gas-rock-sorter.mips
centrifuge-ore.mips

gas handling
gas-filter-chain.mips
co2-tank-pressure-management.mips
fuel-mixer.mips
gas-harvester.mips
gas-mixer-nitrous.mips
n2o-heater.mips
pump-feed-nitrolyzer.mips
show-gas-pressure-triple.mips
manage-coolant-from-atmosphere.mips

doors
weather-gate.mips
door-switch-logic.mips

solar
solar-old.mips
1-axis-solar-panel-control.mips
2-axis-solar-panel-control.mips

biomass fuel
biomass-generator-pipeline.mips
biomass-generator-silo.mips
biomass-recycler.mips
charcoal-stockpile-display.mips

AIMeE
aimee-old.mips
aimee-position-display.mips
aimee.mips


airlock-tank-accelerator-mgmt.mips
batch-solar-control.mips
centrifuge-miner-manager.mips
chamber-liquification-mgr.mips
cooling-gas-buffer-room.mips
cooling-gas-buffer.mips
display-avionics.mips
exhaust-gas-cooler-control.mips
fuel-mixer-n2o.mips
fuel-mixer-o2.mips
larre-config-1.mips
larre-farming-hardcoded.mips
larre-farming-stack.mips
light-console.manager.mips
light-manager.mips
loulan-airlock.mips
loulan-arc-furnace-room.mips
loulan-greenhouse.mips
measure-condensation-rate.mips
nitrolyzer-battery-threshold.mips
nitrous-warmer.mips
power-consumption-triple.mips
radiator-control.mips
simpler-gate.mips
sorter-feeding-autooven.mips
trader-scanner.mips
vend-ingots-to-printer-2.mips

alias temp_f r15
alias temp_c r14
alias temp_h r13
alias moles_f r12
alias target_moles r11
alias target_temperature r10
alias target_pressure r9
alias hot_temperature r8
alias cold_temperature r7
alias hot_moles r6
alias cold_moles r5
alias furnace_temperature r4
alias furnace_moles r3

define HASH_LED_s HASH("StructureConsoleLED5")
define HASH_TANK_si HASH("StructureTankSmallInsulated")
define HASH_MEMORY HASH("StructureLogicMemory")
define R 8.3145
define HASH_FURNACE HASH("StructureAdvancedFurnace")

sbn HASH("StructureConsoleLED5") HASH("ColdTemp") Setting -1

start:
yield

lbn cold_temperature HASH_TANK_si HASH("cold tank") Temperature 0
lbn hot_temperature HASH_TANK_si HASH("hot tank") Temperature 0
#s db Setting r0
sbn HASH_LED_s HASH("ColdTemp") Setting cold_temperature
sbn HASH_LED_s HASH("HotTemp") Setting hot_temperature

lbn target_temperature HASH_MEMORY HASH("Target Temperature") Setting Average
lbn target_pressure HASH_MEMORY HASH("Target Pressure") Setting Average
lb furnace_temperature HASH_FURNACE Temperature Average
lb furnace_moles HASH_FURNACE TotalMoles Average
# n=PV/(RT)
mul r0 R target_temperature
div r0 target_pressure r0
mul target_moles 1000 r0

sbn HASH_LED_s HASH("Target Moles") Setting target_moles
sbn HASH_LED_s HASH("Furnace Temperature") Setting furnace_temperature


sub r1 hot_temperature target_temperature
mul r1 target_moles r1
sub r2 furnace_temperature hot_temperature
mul r2 furnace_moles r2
add r1 r1 r2
sub r2 hot_temperature cold_temperature
div cold_moles r1 r2
sub r0 target_moles furnace_moles
sub hot_moles r0 cold_moles

sgtz r0 hot_moles
sgtz r1 cold_moles
and r0 r1 r0
blez r0 depressurize

s db Setting hot_moles

sbn HASH_LED_s HASH("Hot Moles") Setting hot_moles
sbn HASH_LED_s HASH("Cold Moles") Setting cold_moles

# V=nRT/P
mul r0 hot_moles R
mul r0 r0 hot_temperature
lbn r1 HASH_TANK_si HASH("hot tank") Pressure Average
div r0 r0 r1
sbn HASH_MEMORY HASH("Hot Volume") Setting r0

mul r0 cold_moles R
mul r0 r0 cold_temperature
lbn r1 HASH_TANK_si HASH("cold tank") Pressure Average
div r0 r0 r1
sbn HASH_MEMORY HASH("Cold Volume") Setting r0

sbn HASH_MEMORY HASH("Furnace Volume") Setting 0

j start

depressurize:

sub r0 target_temperature furnace_temperature
mul r0 r0 target_moles

slt r1 furnace_temperature target_temperature
select r1 r1 hot_temperature cold_temperature
sub r1 r1 furnace_temperature

div r0 r0 r1
add r0 furnace_moles r0
sub r0 r0 target_moles

div r1 r0 furnace_moles
mul r0 r1 1000

sbn HASH_MEMORY HASH("Hot Volume") Setting 0
sbn HASH_MEMORY HASH("Cold Volume") Setting 0
sbn HASH_MEMORY HASH("Furnace Volume") Setting r0

j start

MIPS is the programming language used by IC (integrated circuits) in the game Stationeers. Stationeering web site has a MIPS emulator with syntax highlighting and error detection.