Stationeers

Stationeers

View Stats:
Tux Aug 17, 2023 @ 5:45pm
MIPS for Stationeers tutorial
mid level is what I am looking for.

Specifically how to do an IF Else condition in which I know MIPS can do but I am not sure if it can in Stationeers, or exactly how.

thanks
< >
Showing 1-12 of 12 comments
JeanDeaux Aug 17, 2023 @ 6:09pm 
There's no IF THEN ELSE option in MIPS, but you can kinda sorta get it done. My favorite method is using the Set Register command, this basically translates to if the condition is True then the result is 1 otherwise the result is 0 which is saved to a register of your choosing; this is about as close as you'll get to the the IF ELSE condition.

Let's assign a value to a variable: "define Var 100"
Now the variable "Var" has a value of 100
Let's test to see if this value is less than 50, if it is we want a True condition, a value of "1"

"slt r0 Var 50" would be your command line. In this case, 100 is not less than 50 so the result would be 0. The advantage of true/false returns of 1 or 0 is that we can often turn around and directly use those results to turn on/off a device without additional processing by sending those values directly to a devices "ON" parameter, for example.

"sgt r0 Var 50" would return a true since 100 is greater than 50.

There are plenty of variations for the Set command, you can list these easily in the Functions tab of your IC editor.

Other ways to use these results is to guide a branch condition.
"beqz r0 Start" would return you to the program label "Start" if the return was false.

Hope this gets you moving in the direction you want.
Last edited by JeanDeaux; Aug 17, 2023 @ 6:14pm
Tux Aug 17, 2023 @ 6:20pm 
Originally posted by JeanDeaux:
There's no IF THEN ELSE option in MIPS, but you can kinda sorta get it done. My favorite method is using the Set Register command, this basically translates to if the condition is True then the result is 1 otherwise the result is 0 which is saved to a register of your choosing; this is about as close as you'll get to the the IF ELSE condition.

Let's assign a value to a variable: "define Var 100"
Now the variable "Var" has a value of 100
Let's test to see if this value is less than 50, if it is we want a True condition, a value of "1"

"slt r0 Var 50" would be your command line. In this case, 100 is not less than 50 so the result would be 0. The advantage of true/false returns of 1 or 0 is that we can often turn around and directly use those results to turn on/off a device without additional processing by sending those values directly to a devices "ON" parameter, for example.

"sgt r0 Var 50" would return a true since 100 is greater than 50.

There are plenty of variations for the Set command, you can list these easily in the Functions tab of your IC editor.

Other ways to use these results is to guide a branch condition.
"beqz r0 Start" would return you to the program label "Start" if the return was false.

Hope this gets you moving in the direction you want.

ok fair enough, I was just briefly looking at a website that was explaining how to do an ELSE and I took it as meaning they actually had such operators.

is it fair enough to assume Stationeers MIPS is 100% real MIPS and if I see a tutorial of MIPS that I should be able to do it in Stationeers as well?I also do not know if MIPS gets continuous updates to the syntax, I would assume it does not.
JeanDeaux Aug 18, 2023 @ 1:01am 
Probably will need a Dev to give an accurate response to that question. I work under the assumption that the only features of MIPS that are supported are the ones listed in their Function library display. I too looked up some MIPS tutorials when I first started getting into it and while there are some variations from what I found online vs their Function library display, they were pretty aligned for the most part.

I have seen a recent post where someone was using some command syntax I didn't recognize from that function library so perhaps there is indeed some capabilities beyond what they list, again a Dev would need to chime in here for a more accurate response.

Still, no harm in experimenting as the worst you'll get is an error. I've found the link below a useful tool in developing, though it's lacking the new named batch features that were just introduced.

https://stationeering.com/tools/ic
Rocket  [developer] Aug 18, 2023 @ 5:16am 
Stationeers implementation of MIPS is relatively MIPS compliant and implements all the core MIPS functionality. Like many, if not all, chipsets it implements some of its own new instructions that are related to its special use case. In the case of Stationeers, this is mainly instructions provided for batch conducting instructions.

So I don't think it's fair, or useful, to say stationeers is "not the same as real-world MIPS". In fact, I would say such a statement is quite wrong. MIPS is not a specific set of instructions, for example if you look at a variety of MIPS implementations currently in use at major universities you will see some significant differences. It is a family of implementations based around a common approach of a very reduced instruction set to control a processor. Many of the core instructions used in MIPS in stationeers, are close to if not exactly the same in most MIPS family implementations.

While some good answers to the OPs questions, nobody has touched on an explanation of *why* there is no else. The simple answer is that there *is* else, but that there is no short hand for IF ... ELSE. This is because underneath any IF... ELSE in programming, there are a series of instructions. With MIPS, you are operating at a lower level from high level programming - so you will need to include the logic that, combined, will reach IF.. ELSE.

The following offers a good outline of how jumps (such as IF ... ELSE) can be decomplied and represented in MIPS instructions:

https://fog.ccsf.edu/~gboyd/cs270/online/mipsII/if.html
Last edited by Rocket; Aug 18, 2023 @ 5:16am
Tux Aug 18, 2023 @ 5:24am 
Originally posted by JeanDeaux:
Probably will need a Dev to give an accurate response to that question. I work under the assumption that the only features of MIPS that are supported are the ones listed in their Function library display. I too looked up some MIPS tutorials when I first started getting into it and while there are some variations from what I found online vs their Function library display, they were pretty aligned for the most part.

I have seen a recent post where someone was using some command syntax I didn't recognize from that function library so perhaps there is indeed some capabilities beyond what they list, again a Dev would need to chime in here for a more accurate response.

Still, no harm in experimenting as the worst you'll get is an error. I've found the link below a useful tool in developing, though it's lacking the new named batch features that were just introduced.

https://stationeering.com/tools/ic

and even though my orginal post said 'IF ELSE' what I am really looking for is AND.
Last night while trying to go to sleep I got how I would do the AND statement in MIPS as my current MUPS understanding is but it sure would be a lot cleaner if AND operator exstised. Example:

bgt r0 ValueX AND r0 ValueY Go

Go:
Rocket  [developer] Aug 18, 2023 @ 5:38am 
I think the key to remember is that low-level languages are about getting the processor to do something, not a combined bunch of somethings *unless* the processor has been predefined a way to do a bunch of things together.

Think about MIPS more as the processor is always going to execute the next line, so if you don't want that - you need to do something.

If you take AND in the traditional sense, it's a *boolean* or *binary* operation, in c notation | or || are actually slightly different, for example.

So if you want AND functionality, you need to prepare the binary yourself. Which is, actually, what the compiler will be doing in a higher level language when you use such syntax in programming. If you study the instructions involved in, say, a simulator when using c# or C++ you can see how programming *commands* turn into many *instructions* for the CPU.
Last edited by Rocket; Aug 18, 2023 @ 5:38am
Tux Aug 18, 2023 @ 5:41am 
Originally posted by Rocket:
I think the key to remember is that low-level languages are about getting the processor to do something, not a combined bunch of somethings *unless* the processor has been predefined a way to do a bunch of things together.

Think about MIPS more as the processor is always going to execute the next line, so if you don't want that - you need to do something.

If you take AND in the traditional sense, it's a *boolean* or *binary* operation, in c notation | or || are actually slightly different, for example.

So if you want AND functionality, you need to prepare the binary yourself. Which is, actually, what the compiler will be doing in a higher level language when you use such syntax in programming. If you study the instructions involved in, say, a simulator when using c# or C++ you can see how programming *commands* turn into many *instructions* for the CPU.

yup that is what I figured but I was not sure.
I would like to know most of the operators before I start so that I do not get code overly messy.
Ghevd Aug 19, 2023 @ 1:51pm 
Mick taught me everything I know about MIPS. His tutorial playlist was a game changer, literally.

Until I found it I was too intimidated to even try to use IC10 chips.

Hope this helps.

https://www.youtube.com/playlist?list=PLZFLVIAJ1exr5lI94EUwrqbN1ck1wVIa3
JeanDeaux Aug 19, 2023 @ 3:59pm 
The current headache with Stationeers MIPS and the AND, OR, NOR, NOT commands is that you're likely expecting a gate result but what we're actually getting is a byte result. The documentation here is absolutely terrible as it's not telling us how many bits are manipulated in the operation. I've seen some posts showing 4 bits (0101) and I've seen some showing 8 bits (01010101) and while looking at the instructions in the MIPS editor it's showing only a single digit/bit. Some have even mentioned that MIPS is using the first digit as a polarity value (positive or negative) and the remaining 7 digits is the data value. With answers just all over the place, I too am confused as to what the heck is going on here.

So if you're doing a command of "AND" between the values of 0 and 1, the question is are you doing this operation to a single bit (0 and 1), or are you getting a result between the ANSI code value of "0" and "1", which is 00110000 and 00110001 (and is it just the last 4 or all 8 bits)?

I haven't tested this part out yet and have limited my programming to using the "Set Register" option to avoid these headaches. I am eager for some proper documentation on what's happening under hood with these operations.
Last edited by JeanDeaux; Aug 19, 2023 @ 4:01pm
Rocket  [developer] Aug 20, 2023 @ 6:39am 
This the change log for the update of the various binary instructions to be in line with the bitshifting update:

https://steamcommunity.com/games/544550/announcements/detail/3681176566145924827

  • Added NOT bitwise operation. Performs a bitwise logical NOT operation flipping each bit of the input value, resulting in a binary complement. If a bit is 1, it becomes 0, and if a bit is 0, it becomes 1.
  • Changed AND to be a bitwise and not a boolen operation. In most circumstances, this will not cause any issues with scripts. Performs a bitwise logical AND operation on the binary representation of two values. Each bit of the result is determined by evaluating the corresponding bits of the input values. If both bits are 1, the resulting bit is set to 1. Otherwise the resulting bit is set to 0.
  • Changed OR to be a bitwise and not a boolen operation. In most circumstances, this will not cause any issues with scripts. Performs a bitwise logical OR operation on the binary representation of two values. Each bit of the result is determined by evaluating the corresponding bits of the input values. If either bit is 1, the resulting bit is set to 1. If both bits are 0, the resulting bit is set to 0.
  • Changed XOR to be a bitwise and not boolen operation. In most circumstances, this will not cause any issues with scripts. Performs a bitwise logical XOR (exclusive OR) operation on the binary representation of two values. Each bit of the result is determined by evaluating the corresponding bits of the input values. If the bits are different (one bit is 0 and the other is 1), the resulting bit is set to 1. If the bits are the same (both 0 or both 1), the resulting bit is set to 0.
  • Changed NOR to be a bitwise and not boolen operation. In most circumstances, this will not cause any issues with scripts. Performs a bitwise logical NOR (NOT OR) operation on the binary representation of two values. Each bit of the result is determined by evaluating the corresponding bits of the input values. If both bits are 0, the resulting bit is set to 1. Otherwise, if at least one bit is 1, the resulting bit is set to 0.
Last edited by Rocket; Aug 20, 2023 @ 6:42am
Tux Aug 20, 2023 @ 6:43am 
Update:
at least for now I am good.
I created what I needed so until much later in the game it appears I know enough to do what I want.
So, the air blows into a radiator system connected to my greenhouse, then blows it back out once a temp threashold is set.

Why? because given the moon if you leave gas in the pipe system eventually you will have Phase and broken pipes.

I know i know, 'create a cooling system using Pol and Chambers'...no
JeanDeaux Aug 20, 2023 @ 8:59am 
Originally posted by Rocket:
This the change log for the update of the various binary instructions to be in line with the bitshifting update:

Thanks for the reply, I still look forward to the StationPedia being updated vs having to remember which update announcement displayed these especially since that sub-forum doesn't appear to be searchable. And that bitwise is 8 bits, polarity + 7 bits, 4 bits? I'd like to assume 8 bits (1 byte) or do I get 64 bits on my x64 Windows system?
< >
Showing 1-12 of 12 comments
Per page: 1530 50

Date Posted: Aug 17, 2023 @ 5:45pm
Posts: 12