Semantics
How the ops move values, and how Sanguis 3 lowered them to the grid.
The stack
BloodCode is a stack machine. pulse and pulse_str push values; ops consume from the top and push their result. Arithmetic (combine, subtract, scale, divide) takes two, leaves one.
Organs and fields
grow_organ builds a structure with named fields; read_field and write_field move its state. On the grid, a field is a wire: writing it drives the wire, reading it senses the wire.
Control
route jumps unconditionally (the label is a junction). gate jumps when the top of the stack is false. dispatch calls a cell and pushes its return value.
Guards
checktype and checkret assert a value's type at a call boundary. On uncovered hardware they are the safety fence; on covered hardware they compile to nothing.
System cells (4.0)
| Rule | Behavior |
|---|---|
| Type | One integer type per cell, declared by its ->. It types every operation and compare. |
| add, sub, mul | Wrap on the 64-bit pattern, exact. |
| divide, remainder | By 0 answer 0. i64 minimum / -1 stays the minimum. i64 remainder by -1 answers 0. |
| shifts | By 64 or more answer 0 (u64, shl). shr sign-fills in i64. |
| compares | Typed: -20 < 0 is 1 in an i64 cell, 0 in a u64 cell. |
| memory | Loads and stores typed by width, 8 to 64 bits, bounded by the layout accessors. |
| refused | Strings, lists, records, floats and infix shifts inside a system cell. |