Actions

Editing IC10

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
[[Category:IC10 Programming]]
+
[[Category:MIPS Programming]]
=Scripting language for IC10 housings / chips=
+
=MIPS scripting language for IC10 housings / chips=
 
MIPS is [[Stationeers]]' inspiration for the in-game scripting language called IC10. It runs on [[Integrated Circuit (IC10)|IC10 chips]] crafted at the [[Electronics Printer]].  
 
MIPS is [[Stationeers]]' inspiration for the in-game scripting language called IC10. It runs on [[Integrated Circuit (IC10)|IC10 chips]] crafted at the [[Electronics Printer]].  
  
Line 60: Line 60:
  
 
=== Examples ===
 
=== Examples ===
 +
Stationeers online IC10 Emulators:
 +
* https://ic10.dev/
 +
* https://ic10emu.dev
  
 
Here are some examples demonstrating all three operations:
 
Here are some examples demonstrating all three operations:
Line 72: Line 75:
 
To set a device specific value (like '''On'''), you can write into this value.
 
To set a device specific value (like '''On'''), you can write into this value.
  
<code>s d0 On r0</code><br>Writes the value from register '''r0''' out to '''On''' parameter of device '''d0'''. In this example the device will be turned On, if valve of register r0 equals 1, otherwise (register r0 equals 0) it will turned off. See section [[IC10#Device_Variables|Device Variables]].
+
<code>s d0 On r0</code><br>Writes the value from register '''r0''' out to '''On''' parameter of device '''d0'''. In this example the device will be turned On, if valve of register r0 equals 1, otherwise (register r0 equals 0) it will turned off. See section [[MIPS#Device_Variables|Device Variables]].
  
It's recommended to use labels (like: ''someVariable'') instead of a direct reference to the register. See '''alias''' in section [[IC10#Instructions|Instructions]].
+
It's recommended to use labels (like: ''someVariable'') instead of a direct reference to the register. See '''alias''' in section [[MIPS#Instructions|Instructions]].
  
 
=== Special registers ===
 
=== Special registers ===
Line 80: Line 83:
  
 
==Stack Memory==
 
==Stack Memory==
;push r?: adds the value  '''r?''' and increments the '''sp''' by 1.
+
;push r?: adds the value  '''sp''' and increments the '''sp''' by 1.
 
;pop r?: loads the value in the stack memory at index <code>sp-1</code> into register '''r?''' and decrements the '''sp''' by 1.
 
;pop r?: loads the value in the stack memory at index <code>sp-1</code> into register '''r?''' and decrements the '''sp''' by 1.
 
;peek r?: loads the value in the stack memory at index <code>sp-1</code> into register '''r?'''.
 
;peek r?: loads the value in the stack memory at index <code>sp-1</code> into register '''r?'''.
Line 97: Line 100:
  
 
Traversing the stack can be done similarly to how an array would be traversed in some other languages:
 
Traversing the stack can be done similarly to how an array would be traversed in some other languages:
{{ICCode|
+
{{MIPSCode|
 
#this will traverse indices {min value} through {max value}-1
 
#this will traverse indices {min value} through {max value}-1
 
move sp {min value}
 
move sp {min value}
Line 112: Line 115:
  
 
Alternatively, you can use the pop function's decrementing to make a more efficient loop:
 
Alternatively, you can use the pop function's decrementing to make a more efficient loop:
{{ICCode|
+
{{MIPSCode|
 
move sp {max value}
 
move sp {max value}
 
add sp sp 1
 
add sp sp 1
Line 132: Line 135:
  
 
The '''l''' (load) or '''s''' (set) instructions you have to read or set these values to your device. Examples:
 
The '''l''' (load) or '''s''' (set) instructions you have to read or set these values to your device. Examples:
{{ICCode|
+
{{MIPSCode|
 
#Reads the 'Temperature' from an atmosphere sensor
 
#Reads the 'Temperature' from an atmosphere sensor
 
# at device port 'd0' into register 'r0'.
 
# at device port 'd0' into register 'r0'.
 
l r0 d0 Temperature
 
l r0 d0 Temperature
 
}}  
 
}}  
{{ICCode|
+
{{MIPSCode|
 
# Writes the value of the register 'r0' to the
 
# Writes the value of the register 'r0' to the
 
# device on port 'd1' into the variable 'Setting'.
 
# device on port 'd1' into the variable 'Setting'.
Line 145: Line 148:
 
==Labels==
 
==Labels==
 
Labels are used to make it easier to jump between lines in the script. The label will have a numerical value that is the same as its line number. Even though it's possible to use a labels value for calculations, doing so is a bad idea since any changes to the code can change the line numbers of the labels.
 
Labels are used to make it easier to jump between lines in the script. The label will have a numerical value that is the same as its line number. Even though it's possible to use a labels value for calculations, doing so is a bad idea since any changes to the code can change the line numbers of the labels.
{{ICCode|
+
{{MIPSCode|
 
main: # define a jump mark with label 'main'
 
main: # define a jump mark with label 'main'
 
j main # jumps back to 'main'
 
j main # jumps back to 'main'
Line 151: Line 154:
 
==Constants==
 
==Constants==
 
Instead of using a register to store a fixed value, a constant can be made. Using this name will refer to the assigned value. With the help of Constants you can save register places.
 
Instead of using a register to store a fixed value, a constant can be made. Using this name will refer to the assigned value. With the help of Constants you can save register places.
{{ICCode|
+
{{MIPSCode|
 
# defines a Constant with name 'pi'
 
# defines a Constant with name 'pi'
 
# and set its value to 3.14159
 
# and set its value to 3.14159
Line 157: Line 160:
 
}}  
 
}}  
  
You can use these constants like any other variables (see: alias in section [[IC10#Instructions|Instructions]]). Example:
+
You can use these constants like any other variables (see: alias in section [[MIPS#Instructions|Instructions]]). Example:
{{ICCode|
+
{{MIPSCode|
 
# set the value of register 'r0' to the value of constant named 'pi'.
 
# set the value of register 'r0' to the value of constant named 'pi'.
 
move r0 pi  
 
move r0 pi  
Line 165: Line 168:
 
==Indirect referencing==
 
==Indirect referencing==
 
This is a way of accessing a register by using another register as a pointer. Adding an additional r in front of the register turns on this behaviour. The value stored in the register being used as the pointer must be between 0 to 15, this will then point to a register from r0 to r15, higher or lower values will cause an error.
 
This is a way of accessing a register by using another register as a pointer. Adding an additional r in front of the register turns on this behaviour. The value stored in the register being used as the pointer must be between 0 to 15, this will then point to a register from r0 to r15, higher or lower values will cause an error.
{{ICCode|
+
{{MIPSCode|
 
move r0 5 # stores the value 5 in r0
 
move r0 5 # stores the value 5 in r0
 
move rr0 10  
 
move rr0 10  
Line 173: Line 176:
  
 
Additional r's can be added to do indirect referencing multiple times in a row.
 
Additional r's can be added to do indirect referencing multiple times in a row.
{{ICCode|
+
{{MIPSCode|
 
move r1 2
 
move r1 2
 
move r2 3
 
move r2 3
Line 182: Line 185:
  
 
This also works with devices
 
This also works with devices
{{ICCode|
+
{{MIPSCode|
 
move r0 2 # stores the value 2 in r0
 
move r0 2 # stores the value 2 in r0
 
s dr0 On 1  
 
s dr0 On 1  
Line 194: Line 197:
  
 
The 8 channels (Channel0 to Channel7) are however volatile, in that data is destroyed if any part of the cable network is changed, removed, or added to, and also whenever the world is exited. All these channels default to NaN. Strictly speaking, they default to what we would call "quiet NaN", in that its not an error it simply means its not a number yet. Recommend you use these channels for reading and writing between networks, rather than as a data store. This effectively means an IC can read all the networks for all devices to connected to it, so not just their own local network, but any networks any device they can reference is connected to.
 
The 8 channels (Channel0 to Channel7) are however volatile, in that data is destroyed if any part of the cable network is changed, removed, or added to, and also whenever the world is exited. All these channels default to NaN. Strictly speaking, they default to what we would call "quiet NaN", in that its not an error it simply means its not a number yet. Recommend you use these channels for reading and writing between networks, rather than as a data store. This effectively means an IC can read all the networks for all devices to connected to it, so not just their own local network, but any networks any device they can reference is connected to.
{{ICCode|
+
{{MIPSCode|
 
# d0 is device zero, and the :0 refers
 
# d0 is device zero, and the :0 refers
 
# to that device's 0 connection
 
# to that device's 0 connection
Line 203: Line 206:
 
==Comments==
 
==Comments==
 
Comments can be placed using a '''#''' symbol. All comments are ignored by the game when it reads commands. Below is an example of valid code with two comments.
 
Comments can be placed using a '''#''' symbol. All comments are ignored by the game when it reads commands. Below is an example of valid code with two comments.
{{ICCode|
+
{{MIPSCode|
 
alias MyAlias r0 # Text after the hash tag will be ignored to the end of the line.
 
alias MyAlias r0 # Text after the hash tag will be ignored to the end of the line.
 
# You can also write comments on their own lines, like this.
 
# You can also write comments on their own lines, like this.
Line 215: Line 218:
 
<code>s db Setting 137</code>  # sets/writes the number 137 into the parameter '''Setting''' of the IC Housing('''db''')
 
<code>s db Setting 137</code>  # sets/writes the number 137 into the parameter '''Setting''' of the IC Housing('''db''')
  
Always use unique names for labels. When a label is named after a IC10 keyword like "Temperature:" or "Setting:" the original meaning of the keyword is overwritten, so when an instruction tries to use it an error will occur.
+
Always use unique names for labels. When a label is named after a MIPS keyword like "Temperature:" or "Setting:" the original meaning of the keyword is overwritten, so when an instruction tries to use it an error will occur.
  
 
A [[Cartridge#Configuration|configuration cartridge]] installed in a [[Handheld_Tablet|tablet]]  can be used to see all available values and configuration parameter for all devices you focus on.
 
A [[Cartridge#Configuration|configuration cartridge]] installed in a [[Handheld_Tablet|tablet]]  can be used to see all available values and configuration parameter for all devices you focus on.
  
==Learning IC10==
+
==Learning MIPS==
IC10 can be difficult to get started with. So here is a list of instructions that are useful for beginners. These can be used to write many different scripts.
+
MIPS can be difficult to get started with. So here is a list of instructions that are useful for beginners. These can be used to write many different scripts.
  
 
General:
 
General:
Line 271: Line 274:
  
 
<br>Notes:
 
<br>Notes:
<br>-All instructions and variables can be seen in-game in the IC editor window by clicking the "f", "x" and "s(x)" buttons on the top right.
+
<br>-All instructions and variables can be seen in-game in the MIPS editor window by clicking the "f", "x" and "s(x)" buttons on the top right.
 
<br>-The stationpedia is the best source to see which variables are available to each device.
 
<br>-The stationpedia is the best source to see which variables are available to each device.
 
<br>-Most scripts are loops, they end with a jump instruction that leads back up to the start. Otherwise they will just run once and then stop.
 
<br>-Most scripts are loops, they end with a jump instruction that leads back up to the start. Otherwise they will just run once and then stop.
Line 285: Line 288:
 
----
 
----
  
See [[IC10/instructions]]
+
See [[MIPS/instructions]]
  
{{:IC10/instructions}}
+
{{:MIPS/instructions}}
  
 
[https://www.cs.tufts.edu/comp/140/lectures/Day_3/mips_summary.pdf Other examples]
 
[https://www.cs.tufts.edu/comp/140/lectures/Day_3/mips_summary.pdf Other examples]
Line 326: Line 329:
 
| -nan || if a == NaN || bnan ||  || brnan || snan
 
| -nan || if a == NaN || bnan ||  || brnan || snan
 
|-
 
|-
| -nanz || if a != NaN ||  ||  || || snanz
+
| -nan || if a != NaN ||  ||  || || snanz
 
|-
 
|-
 
| -dns || if device d is not set          || bdns || bdnsal || brdns || sdns
 
| -dns || if device d is not set          || bdns || bdnsal || brdns || sdns
Line 385: Line 388:
 
<div id="Color"></div>
 
<div id="Color"></div>
 
;Color
 
;Color
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#212AA5;"></div>&nbsp;0 (or lower) = Blue
+
:    <span style="color:blue;">▇▇▇</span>&nbsp; 0 (or lower) = Blue
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#7B7B7B;"></div>&nbsp;1 = Grey  
+
:    <span style="color:grey;">▇▇▇</span>&nbsp;1 = Grey  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#3F9B39;"></div>&nbsp;2 = Green  
+
:    <span style="color:green;">▇▇▇</span>&nbsp;2 = Green  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FF662B;"></div>&nbsp;3 = Orange  
+
:    <span style="color:orange;">▇▇▇</span>&nbsp;3 = Orange  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E70200;"></div>&nbsp;4 = Red  
+
:    <span style="color:red;">▇▇▇</span>&nbsp;4 = Red  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#FFBC1B;"></div>&nbsp;5 = Yellow  
+
:    <span style="color:yellow;">▇▇▇</span>&nbsp;5 = Yellow  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E7E7E7;"></div>&nbsp;6 = White  
+
:    <span style="color:white;">▇▇▇</span>&nbsp;6 = White  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#080908;"></div>&nbsp;7 = Black  
+
:    <span style="color:black;">▇▇▇</span>&nbsp;7 = Black  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#633C2B;"></div>&nbsp;8 = Brown  
+
:    <span style="color:brown;">▇▇▇</span>&nbsp;8 = Brown  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#63633F;"></div>&nbsp;9 = Khaki  
+
:    <span style="color:khaki;">▇▇▇</span>&nbsp;9 = Khaki  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#E41C99;"></div>&nbsp;10 = Pink  
+
:    <span style="color:pink;">▇▇▇</span>&nbsp;10 = Pink  
:    <div style="display: inline-block; vertical-align: top; height: 20px; width: 20px; border: 1px solid black; margin-right: 5px; background-color:#732CA7;"></div>&nbsp;11 (or higher) = Purple  
+
:    <span style="color:purple;">▇▇▇</span>&nbsp;11 (or higher) = Purple  
 
<div id="CompletionRatio"></div>
 
<div id="CompletionRatio"></div>
 
;CompletionRatio
 
;CompletionRatio
Line 585: Line 588:
  
 
<div class="mw-collapsible mw-collapsed" data-expandtext="{{int:Expand, Automated Harvie Script}}" data-collapsetext="{{int:Collapse, Automated Harvie Script}}">
 
<div class="mw-collapsible mw-collapsed" data-expandtext="{{int:Expand, Automated Harvie Script}}" data-collapsetext="{{int:Collapse, Automated Harvie Script}}">
{{ICCode|
+
{{MIPSCode|
 
alias dHarvie d0
 
alias dHarvie d0
 
alias dTray d1
 
alias dTray d1
Line 629: Line 632:
 
===Solar Panel 2-axis tracking===
 
===Solar Panel 2-axis tracking===
 
<div class="mw-collapsible mw-collapsed" data-expandtext="{{int:Expand, Solar Panel 2-axis tracking}}" data-collapsetext="{{int:Collapse, Solar Panel 2-axis tracking}}">
 
<div class="mw-collapsible mw-collapsed" data-expandtext="{{int:Expand, Solar Panel 2-axis tracking}}" data-collapsetext="{{int:Collapse, Solar Panel 2-axis tracking}}">
{{ICCode|
+
{{MIPSCode|
 
#2 Axis Solar Tracking adapted from CowsAreEvil.
 
#2 Axis Solar Tracking adapted from CowsAreEvil.
 
#Place all panels in uniform manner.
 
#Place all panels in uniform manner.
Line 687: Line 690:
 
===Example experiment: how many lines of code are executed each tick?===
 
===Example experiment: how many lines of code are executed each tick?===
 
To determine this, a script without <code>yield</code> will be used. It should have as few lines as possible (so no labels are used, but a reset value at the top will be needed) and count the number of lines, the IC Housing will be used to display the result.
 
To determine this, a script without <code>yield</code> will be used. It should have as few lines as possible (so no labels are used, but a reset value at the top will be needed) and count the number of lines, the IC Housing will be used to display the result.
{{ICCode|
+
{{MIPSCode|
 
move r0 1  #the first line has number 0
 
move r0 1  #the first line has number 0
 
add r0 r0 3
 
add r0 r0 3
Line 711: Line 714:
 
=Links=
 
=Links=
 
----
 
----
* Stationeers online IC10 Emulators so you can develop your code without repeatedly dying in game
+
* [https://stationeering.com/tools/ic] Stationeering.com offers a programmable circuits simulator so you can develop your code without repeatedly dying in game!
** [https://ic10.dev/] Stationeers Code Simulator
 
** [https://ic10emu.dev] Stationeers IC10 Editor & Emulator - A feature packed code editor for Stationeers IC10 code, paired with a robust debugger and emulator. Edit, test, and share code.
 
** [https://stationeering.com/tools/ic] Stationeering provides a simulation of the IC10 chip inside Stationeers. IDE with error checking, full visibility of stack and registers.
 
 
* [http://www.easy68k.com/] EASy68K is a 68000 Structured Assembly Language IDE.
 
* [http://www.easy68k.com/] EASy68K is a 68000 Structured Assembly Language IDE.
 
* [https://marketplace.visualstudio.com/items?itemName=Traineratwot.stationeers-ic10] syntax highlighting for IC10 MIPS for Visual Studio Code (updated Feb 10th 2022)
 
* [https://marketplace.visualstudio.com/items?itemName=Traineratwot.stationeers-ic10] syntax highlighting for IC10 MIPS for Visual Studio Code (updated Feb 10th 2022)

Please note that all contributions to Unofficial Stationeers Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Unofficial Stationeers Wiki:Copyrights for details). Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)