IC10 Cheat Sheet

Suffix Condition b- (branch) b-al (branch+store) br- (relative) s- (set reg)
unconditional jjal jr
▸ Equality & comparison (operands: a, b)
-eqa == bbeqbeqalbreqseq
-nea != bbnebnealbrnesne
-lta < bbltbltalbrltslt
-lea <= bbleblealbrlesle
-gta > bbgtbgtalbrgtsgt
-gea >= bbgebgealbrgesge
▸ Zero comparison  (operand: a)
-eqza == 0beqzbeqzalbreqzseqz
-neza != 0bnezbnezalbrnezsnez
-ltza < 0bltzbltzalbrltzsltz
-leza <= 0blezblezalbrlezslez
-gtza > 0bgtzbgtzalbrgtzsgtz
-geza >= 0bgezbgezalbrgezsgez
▸ Approximate equality  (operands: a, b, tolerance c)
-apa ≈ b (within c)bapbapalbrapsap
-apza ≈ 0 (within b)bapzbapzalbrapzsapz
-naa ≉ b (not approx eq)bnabnaalbrnasna
-naza ≉ 0 (not approx eq)bnazbnazalbrnazsnaz
▸ NaN  (operand: a)
-nana is NaNbnanbrnansnan
-nanza is not NaNsnanz
▸ Device pin  (operand: d = d0–d5 or db)
-dnsdevice d not setbdnsbdnsalbrdnssdns
-dsedevice d is setbdsebdsealbrdsesdse
b-  ·  Branch to line
Jump to absolute line or label. Last arg is target. bgt r0 100 tooHot
j start
s-  ·  Set register
Writes 1 (true) or 0 (false) to first arg. No jump. sgt r0 temp 300
# r0=1 if temp>300
b-al  ·  Branch + save ra
Like b- but saves next line in ra. Return with j ra. beqal r0 0 reset

reset:
j ra
br-  ·  Relative branch
Last arg is a signed line offset. Positive = forward. breq a b 3 # skip 3 if a==b
jr -5 # back 5 lines
Approx. equality

True if a and b are within c relative tolerance of each other.

sap r0 100 105 0.05
# r0=1 (5% apart, within 5%)
select  ·  Ternary

select r? a b c — sets r to b if a ≠ 0, else c.

select r0 flag 10 200
# r0=10 if flag≠0, else 200
l r0 valve On
select r0 r0 minT maxT
# pick threshold
alias & define

alias name r?|d? — gives a register or device pin a readable name; also labels the screw on the IC housing.

define name num — replaces a name with a fixed number everywhere in the script. Numbers only.

db — built-in device pin for the IC housing itself. Use for direct I/O or debugging.

alias temp r0
define maxTemp 303.15
s db Setting r0
Macros

HASH("Name") — CRC-32 hash of a name. Used as device type (h) or name filter (n) in batch calls.

STR("TEXT") — hex ASCII of a string. Hex literals use $ prefix.

lb r0 HASH("StructureGasSensor") Pressure Average
move r0 STR("HELLO") # r0=$48454C4C4F
Stack  ·  local & cross-IC

512-value stack per IC. sp = stack pointer (readable/writable).

push awrite a, increment sp
pop r?read top into r, decrement sp
peek r?read top, sp unchanged
poke addr vwrite v to local stack[addr]
put d? addr vwrite to device d's stack[addr]
get r? d? addrread from device d's stack[addr]
putd id addr vput via ReferenceId
getd r? id addrget via ReferenceId
yield & sleep

yield — pause 1 tick (0.5 s). Scripts execute up to 128 lines/tick, then auto-pause until next tick; use yield to pause early.

sleep a — pause for a seconds.

main:
yield

j main
Math & trig reference
Arithmetic abs ceil floor round trunc sqrt exp log mod pow rand
Interpolation lerp a b c  interpolates from a to b by ratio c (clamped 0–1)
Trigonometry (radians) sin cos tan asin acos atan atan2
Bitwise logic and or xor nor not
Shifts sll srl  logical (fills 0s)
sla sra  arithmetic (preserves sign bit)