alias larre d0 alias stacker d1 alias import d2 alias export d3 alias hash r15 alias address r14 alias lockerIndex r13 alias oldIndex r12 alias hashToStack r11 alias qty r10 define lockerStation 4 define importStation 3 define exportStation 2 define MODULUS 55 mul sp 2 MODULUS add sp sp 5 handoff: put db 120 4 # activate pre-fabrication counter s db Setting -99 waitMyTurn: yield get r0 db 120 bne r0 0 waitMyTurn # some other IC has larre larreDeposit: s db Setting -1 yield ls r0 larre 0 Occupied beqz r0 checkExport # nothing in my claw ls r0 larre 0 OccupantHash s db Setting r0 s larre Setting lockerStation jal waitLarreIdle move lockerIndex 0 stowScan: s db Setting lockerIndex #yield s larre TargetSlotIndex lockerIndex ls r0 larre 255 Occupied add lockerIndex 1 lockerIndex bnez r0 stowScan s db Setting 73 s larre Activate 1 jal waitLarreIdle checkExport: s db Setting 2 # check export ls r0 export 0 Occupied blez r0 survey s larre Setting exportStation s larre TargetSlotIndex 0 jal waitLarreIdle s larre Activate 1 jal waitLarreIdle j larreDeposit survey: yield s db Setting 3 s larre Setting lockerStation move address 0 zeroram: put db address -1 add address address 1 blt address MODULUS zeroram # jal waitLarreIdle move lockerIndex 0 inventory: #s db Setting lockerIndex s larre TargetSlotIndex lockerIndex ls hash larre 255 OccupantHash beqz hash skipSlot # nothing in the slot ls r1 larre 255 Quantity mod address hash MODULUS add r2 address MODULUS get qty db r2 # what is the stack size bge r1 qty skipSlot #skip if full stack get oldIndex db address s db Setting oldIndex bgez oldIndex coalesce put db address lockerIndex skipSlot: add lockerIndex lockerIndex 1 blt lockerIndex 30 inventory s stacker Activate 1 j handoff coalesce: s db Setting -4 move hashToStack hash s larre Activate 1 jal waitLarreIdle put db 120 2 # activate coalesce IC j waitMyTurn waitLarreIdle: #s db Setting 10 yield l r0 larre Idle blez r0 waitLarreIdle j ra # stockcount in ram from 0..MODULUS # SUBTASKS # scan locker for duplicates # coalesce specific hash # scan export bins # schedule fabrication # mode 0 = stacker # mode 1 = fabricator # mode 2 = coalesce # mode 3 = trucker # mode 4 = pre-fabricator # = stacker config |
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.