---
# System prepended metadata

title: ChemiAssembler

---

# ChemiAssembler

Like the ChemiCompiler, but with assembly-like language.

#### Reason for updating the ChemiCompiler

The ChemiCompiler hasn't had any visual update since forever andthe ChemFuck language isn't really that comfortable to write. It's hard to interpept by looking at it, difficult to tell what ChemFuck does by just reading it and shouldn't require a transpiler most of the time in order to be used.

![](https://i.imgur.com/J3GOng5.png)

The layout of the ChemiCompiler is frustrating to use, the code area is too short to get a good overview, no comments allowed makes it hard to tell what part of the code does what, and there is not much response in how the program runs.

While the main part of the ChemiCompiler is to provide a layer of difficulty that requires learning to use, it should still give a gameplay element that is fun to use.

**Therefore a solution is to redesign all the concept and improve upon the main idea: use code to create chemicals.**

While the assembly-like language may seems intimidating to some, its main purpose to be readable by humans but still providing a challenge to those who want to make their chemical job more efficent.

So here is an example of the possible difference.

#### How to make salt:
Starting with the following setup
Slot 1: 33+ Water
Slot 2: 33+ Sodium
Slot 3: 33+ Chlorine
Slot 4: an empty beaker

(Old way)
```
+++++++++++++++++++++++++++++++++'>+}>++++)@>++}@>+++}@
```
(New way)
```javascript
// The first three lines sets the value of the three registers.

mov 33 ax //Sets transfer amount to 33u
mov 4 tx  //Sets target Slot to #4
mov 1 sx  //Start at Slot source #1

// These lines transfers the first 3 slots to slot #4

cal @     // Transfers 33u from Slot #1 to Slot #4 

add 1 sx  // sx 1 > 2
cal @     // Transfers 33u from Slot #2 to Slot #4 

add 1 sx  // sx 2 > 3
cal @     // Transfers 33u from Slot #3 to Slot #4
```
The code might change in the future, but the idea is to create a better overview of each program. And with the use of comments it's easy to describe what each part does.

# Things that need work
* Layout for a pleasing user experience
* Sounds for computer beep boop sound effects
* Design a nice color scheme for the syntax highlighter
* Create an import function for old ChemFuck code into the new way (maybe?)
* Handle error messages and syntax errors
* Deal with the console layout
* Create documentation for the new language
* **More to come**

# Layout Idea
![](https://i.imgur.com/cdcyzhC.png)

All components are WIP and will probably change.

### (1) Code Editor
A code editor panel with syntax highlighting
### (2) Registers
Works the same way as the ChemiCompiler
### (3) Variables
Possible to define variables and reuse them in the code, any declared variables show up here
### (4) Console
Possible to output text and values into the console, also display errors
### (5) Runtime info
Give information about the program as it is running
### (6) Reservoirs
Reservoirs that contain the liquids to be used by the machine.
### (7) Controls
Some controls to handle the program

# Instructions
#### Full list (**bold** = done, italic = being worked on, normal = not done):
##### Arithmetic: **add**, **sub**, **mul**, **div**, **mod**, **jmp**, **lbl**
##### Others: **var**, **mov**, print
##### Calls: cal $(heat/cool), cal €(measure temp), cal @(transfer liquid), cal #(isolate liquid), cal ¤(measure res)

### Arithmetic
Basic math instructions

##### add `val/reg/var reg/var`
```
add 10 sx ;Adds 10 into register sx
```

##### sub `val/reg/var reg/var`
```
add 10 sx ;Subtracts 10 into register sx
```

##### mul `val/reg/var reg/var`
```
mul 10 sx ;Multiplies sx by 10
```

##### div `val/reg/var reg/var`
```
mul 10 sx ;Divides sx by 10
```

##### mod `val/reg/var reg/var`
```
mod 10 sx ;Mods sx by 10
```

### Others
An asortment of helping instructions

##### var `val/reg/var name`
```
var 0 foo ; Sets variable foo to 0
```

##### mov `val/reg/var reg/var`
```
mov sx tx ;Copies the value of sx into tx
```

##### jmp `label`
```
jmp here ;Jumps to the location of lbl here
```

##### lbl `label`
```
lbl here ;Used with jmp to move to the location of lbl name
```

##### print `content`
```
print "sx is [sx]" ;Prints "sx is [value of sx]"
```

### Calls
Instructions used to interact with the machines functions, similar to the ChemiCompiler

##### cal $
Heat or cool reagent in sx to ((273 - tx) + ax) Kelvin.
Heating and cooling takes as long as the chemistry lab heater would take.

##### cal €
Measure the temeperature of reagents in reservoir sx and stores the value in ax.

##### cal @
Transfer ax units of reagent from reservoir sx to resevoir tx (1 to 10)
If tx is 11, it creates a pill with the reagents
If tx is 12, it creates a vial with the reagents
If tx is 13 or above, the content of the reservoir is ejected/destroyed

##### cal #
Isolates ax units of reagent number *ptr from reservoir sx to reservoir tx. Indexing begins at 1.

##### cal ¤
Measure the amount of reagent in reservoir sx and stores the value in ax.