alias furnace d0 alias hottank d1 alias hotpump d2 alias selector d3 alias coldtank d4 alias coldpump d5 alias targettemp r15 alias targetpressure r14 alias furnacetemp r13 alias furnacemoles r12 alias hottemp r11 alias coldtemp r10 alias hotmoles r9 alias coldmoles r8 alias targetmoles r7 define R 8.3144 move targettemp 700 move targetpressure 150 start: yield l r0 furnace On bnez r0 operate s coldpump On r0 s hotpump On r0 j start operate: l furnacetemp furnace Temperature ls r0 furnace 0 Quantity #unmelted beqz r0 ready sle r0 furnacetemp 400 # not all the inputs have melted. l r0 furnace Pressure bgt r0 1500 purge trick: s coldpump On 0 s hotpump On r0 s hotpump Setting 10 s furnace SettingInput 100 s furnace SettingOutput 0 j start ready: mul r0 targetpressure 1000 div r0 r0 R div targetmoles r0 targettemp l furnacemoles furnace TotalMoles l hottemp hottank Temperature l coldtemp coldtank Temperature sub r0 furnacetemp hottemp mul r0 r0 furnacemoles sub r1 hottemp targettemp mul r1 r1 targetmoles add r0 r0 r1 sub r1 hottemp coldtemp div coldmoles r0 r1 sub r0 targetmoles furnacemoles sub hotmoles r0 coldmoles jal furnacepump j start furnacepump: alias coldvol r4 alias hotvol r3 mul r0 coldmoles R mul r0 r0 coldtemp l r1 coldtank Pressure div r0 r0 r1 # r0=V=nRT/P mul r0 r0 0.5 # kludge min coldvol r0 100 mul r0 hotmoles R mul r0 r0 hottemp l r2 hottank Pressure div r0 r0 r2 mul r0 r0 0.5 # kludge min hotvol r0 100 slt r0 coldvol -1 slt r1 hotvol -1 or r0 r0 r1 bnez r0 depressurize s coldpump Setting coldvol sgtz r0 coldvol s coldpump On r0 s hotpump Setting hotvol sgtz r0 hotvol s hotpump On r0 s furnace SettingInput 100 s furnace SettingOutput 0 j ra ## depressurize: s coldpump Setting 0 s hotpump Setting 0 alias furnacemoles1 r4 alias furnacemoles2 r3 sub r0 hottemp targettemp mul r0 r0 targetmoles sub r1 hottemp furnacetemp div furnacemoles1 r0 r1 # if we only use hot, how much to leave in furnace sub r0 coldtemp targettemp mul r0 r0 targetmoles sub r1 coldtemp furnacetemp div furnacemoles2 r0 r1 #if we only use cold, how much to leave in furnace slt r2 furnacetemp targettemp select r0 r2 furnacemoles1 furnacemoles2 sub r1 furnacemoles r0 #moles to remove mul r1 r1 1000 div r1 r1 furnacemoles blt r1 5 nokludge1 mul r1 r1 0.5 # kludge nokludge1: min r1 r1 100 s furnace SettingInput 0 s furnace SettingOutput r1 s furnace On 1 j ra purge: s furnace SettingOutput 100 s furnace SettingInput 0 s coldpump Setting 0 s hotpump Setting 0 yield l r0 furnace Pressure bgt r0 10 purge 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.