alias engine d0 alias avionics d1 alias homeLocation r15 move homeLocation 4116 # mars start: yield jal memorizeHome jal scanner jal land j start memorizeHome: l r0 avionics Altitude bnez r0 ra l homeLocation avionics CurrentCode s db Setting homeLocation j ra land: alias a r14 alias throttle r13 alias altitude r12 alias oldTTW r11 #define G -3.7 #define G -1 alias g r10 alias v1 r9 alias v2 r8 alias deltav r7 alias deltay r6 alias throttlefloor r5 l altitude avionics Altitude blez altitude ra # in space, don't manage l r0 engine On beqz r0 ra # engine is not on l r0 avionics DestinationCode beq r0 homeLocation land2 s engine Throttle 100 # launching to space j ra land2: l throttle engine Throttle bgt altitude 200 stage1 # final approach is more gentle move v2 0 move throttlefloor 0 sub deltay 0 altitude j calcthrust stage1: # primary descent move v2 -40 # 40m/s descending slt r1 throttle 70 select throttlefloor r1 80 70 # what is our floor? sub deltay 200 altitude calcthrust: #destined for home, let's land safely l v1 avionics VelocityRelativeY l oldTTW avionics ThrustToWeight l r1 avionics Weight l r2 avionics Mass div g r1 r2 sub g 0 g bgtz v1 ugh sub deltav v2 v1 mul r0 0.5 deltav add r0 v1 r0 # r0 = v1 + v/2 mul r0 r0 deltav # r0 = v(v1+v/2) div r0 r0 deltay # r0 = v/y (v1+v/2) = target_accel div r0 r0 g sub r0 1 r0 # r0 = target_ttw = 1-target_accel/g mul r0 throttle r0 div r0 r0 oldTTW # throttle = old_throttle * target_ttw / old_thrust_to_weight s db Setting r0 slt r1 throttle 70 slt r1 r0 throttlefloor sgt r2 altitude 20 and r1 r1 r2 select r0 r1 1 r0 # if we don't need much thrust, don't bother thrusting s engine Throttle r0 j ra ugh: s db Setting 0 s engine Throttle 0 j ra ###################################################################### scanner: l r0 avionics Mode sge r3 r0 3 #and r3 r3 r0 # only turn them on while it is scanning sb HASH("StructureRocketScanner") On r3 sge r3 r0 2 sb HASH("StructureRocketMiner") On r3 j ra ###################################################################### |
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.