Actions

Difference between revisions of "MIPS/instructions"

From Unofficial Stationeers Wiki

m (ty)
(3 intermediate revisions by the same user not shown)
Line 6: Line 6:
  
 
{{MIPSInstruction|instruction=alias|description=Labels register or device reference with name, device references also affect what shows on the screws on the IC base.|syntax=alias str r?{{!}}d?
 
{{MIPSInstruction|instruction=alias|description=Labels register or device reference with name, device references also affect what shows on the screws on the IC base.|syntax=alias str r?{{!}}d?
|example={{MIPSCode|
+
|example=
 +
{{MIPSCode|
 
alias dAutoHydro1 d0
 
alias dAutoHydro1 d0
 
alias vTemperature r0
 
alias vTemperature r0
}}
+
}}}}
}}
 
 
{{MIPSInstruction|instruction=define|description=Creates a label that will be replaced throughout the program with the provided value.|syntax=define str num
 
{{MIPSInstruction|instruction=define|description=Creates a label that will be replaced throughout the program with the provided value.|syntax=define str num
|example={{MIPSCode|
+
|example=
 +
{{MIPSCode|
 
define ultimateAnswer 42
 
define ultimateAnswer 42
 
move r0 ultimateAnswer # Store 42 in register 0
 
move r0 ultimateAnswer # Store 42 in register 0
 
}}}}
 
}}}}
{{MIPSInstruction|instruction=hcf|description=Halt and catch fire.|syntax=hcf}}
+
{{MIPSInstruction|instruction=hcf|description=Halt and catch fire|syntax=hcf}}
 
{{MIPSInstruction|instruction=sleep|description=Pauses execution on the IC for a seconds|syntax=sleep a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sleep|description=Pauses execution on the IC for a seconds|syntax=sleep a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=yield|description=Pauses execution for 1 tick|syntax=yield}}
 
{{MIPSInstruction|instruction=yield|description=Pauses execution for 1 tick|syntax=yield}}
Line 25: Line 26:
 
|example=
 
|example=
 
{{MIPSCode|
 
{{MIPSCode|
add r0 r0 1 # increment r0 by one
+
define negativeNumber -10
}}
+
abs r0 negativeNumber # Compute the absolute value of -10 and store it in register 0
}}
+
}}}}
{{MIPSInstruction|instruction=add|description=Register = a + b.|syntax=add r? a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=add|description=Register = a + b.|syntax=add r? a(r?{{!}}num) b(r?{{!}}num)
{{MIPSInstruction|instruction=ceil|description=Register = smallest integer greater than a|syntax=ceil r? a(r?{{!}}num)}}
+
|example=
 +
{{MIPSCode|add r0 r0 1 # increment r0 by one}}
 +
{{MIPSCode|
 +
define num1 10
 +
define num2 20
 +
add r0 num1 num2 # Add 10 and 20 and store the result in register 0
 +
}}}}
 +
{{MIPSInstruction|instruction=ceil|description=Register = smallest integer greater than a|syntax=ceil r? a(r?{{!}}num)
 +
|example=
 +
{{MIPSCode|
 +
define floatNumber 10.3
 +
ceil r0 floatNumber # Compute the ceiling of 10.3 and store it in register 0
 +
}}}}
 
{{MIPSInstruction|instruction=div|description=Register = a / b|syntax=div r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=div|description=Register = a / b|syntax=div r? a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=exp|description=Register = exp(a) or e^a|syntax=exp r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=exp|description=exp(a) or e^a|syntax=exp r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=floor|description=Register = largest integer less than a|syntax=floor r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=floor|description=Register = largest integer less than a|syntax=floor r? a(r?{{!}}num)}}
{{MIPSInstruction|instruction=log|description=Register = base e log(a) or ln(a)|syntax=log r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=log|description=base e log(a) or ln(a)|syntax=log r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=max|description=Register = max of a or b|syntax=max r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=max|description=Register = max of a or b|syntax=max r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=min|description=Register = min of a or b|syntax=min r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=min|description=Register = min of a or b|syntax=min r? a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=mod|description=Register = a mod b (note: NOT a % b)|syntax=mod r? a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=mod|description=Register = a mod b (note: NOT a % b)|syntax=mod r? a(r?{{!}}num) b(r?{{!}}num)
 +
|example=
 +
{{MIPSCode|
 +
mod r0 10 20
 +
# Expected: r0 = 10
 +
 
 +
mod r1 22 20
 +
# Expected: r1 = 2
 +
 
 +
mod r2 22 -20
 +
# Expected: r2 = 18
 +
 
 +
mod r2 22 -10
 +
# Expected: r2 = 18
 +
}}}}
 
{{MIPSInstruction|instruction=move|description=Register = provided num or register value.|syntax=move r? a(r?{{!}}num)
 
{{MIPSInstruction|instruction=move|description=Register = provided num or register value.|syntax=move r? a(r?{{!}}num)
|example={{MIPSCode|
+
|example=
move r0 42 # Store 42 in register 0
+
{{MIPSCode|move r0 42 # Store 42 in register 0}}}}
}}
 
}}
 
 
{{MIPSInstruction|instruction=mul|description=Register = a * b|syntax=mul r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=mul|description=Register = a * b|syntax=mul r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=rand|description=Register = a random value x with 0 <= x < 1|syntax=rand r?}}
 
{{MIPSInstruction|instruction=rand|description=Register = a random value x with 0 <= x < 1|syntax=rand r?}}
Line 49: Line 74:
 
{{MIPSInstruction|instruction=trunc|description=Register = a with fractional part removed|syntax=trunc r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=trunc|description=Register = a with fractional part removed|syntax=trunc r? a(r?{{!}}num)}}
  
=== Trigonometric ===
+
=== Mathematical / Trigonometric ===
  
{{MIPSInstruction|instruction=acos|description=Returns the angle (radians) whose cosine is the specified value|syntax=acos r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=acos|description=Returns the angle (radians) whos cos is the specified value|syntax=acos r? a(r?{{!}}num)}}
{{MIPSInstruction|instruction=asin|description=Returns the angle (radians) whose sine is the specified value|syntax=asin r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=asin|description=Returns the angle (radians) whos sine is the specified value|syntax=asin r? a(r?{{!}}num)}}
{{MIPSInstruction|instruction=atan|description=Returns the angle (radians) whose tan is the specified value|syntax=atan r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=atan|description=Returns the angle (radians) whos tan is the specified value|syntax=atan r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=atan2|description=Returns the angle (radians) whose tangent is the quotient of two specified values: a (y) and b (x)|syntax=atan2 r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=atan2|description=Returns the angle (radians) whose tangent is the quotient of two specified values: a (y) and b (x)|syntax=atan2 r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=cos|description=Returns the cosine of the specified angle (radians)|syntax=cos r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=cos|description=Returns the cosine of the specified angle (radians)|syntax=cos r? a(r?{{!}}num)}}
Line 65: Line 90:
 
{{MIPSInstruction|instruction=getd|description=Seeks directly for the provided device id, attempts to read the stack value at the provided address, and places it in the register.|syntax=getd r? id(r?{{!}}num) address(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=getd|description=Seeks directly for the provided device id, attempts to read the stack value at the provided address, and places it in the register.|syntax=getd r? id(r?{{!}}num) address(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=peek|description=Register = the value at the top of the stack|syntax=peek r?}}
 
{{MIPSInstruction|instruction=peek|description=Register = the value at the top of the stack|syntax=peek r?}}
{{MIPSInstruction|instruction=poke|description=Stores the provided value at the provided address in the stack|syntax=poke address(r?{{!}}num) value(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=poke|description=Stores the provided value at the provided address in the stack.|syntax=poke address(r?{{!}}num) value(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=pop|description=Register = the value at the top of the stack and decrements sp|syntax=pop r?}}
 
{{MIPSInstruction|instruction=pop|description=Register = the value at the top of the stack and decrements sp|syntax=pop r?}}
 
{{MIPSInstruction|instruction=push|description=Pushes the value of a to the stack at sp and increments sp|syntax=push a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=push|description=Pushes the value of a to the stack at sp and increments sp|syntax=push a(r?{{!}}num)}}
{{MIPSInstruction|instruction=put|description=Using the provided device, attempt to write the provided value to the stack at the provided address.|syntax=put d? address(r?{{!}}num) value(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=put|description=Using the provided device, attempts to write the provided value to the stack at the provided address.|syntax=put d? address(r?{{!}}num) value(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=putd|description=Seeks directly for the provided device id, attempts to write the provided value to the stack at the provided address.|syntax=putd id(r?{{!}}num) address(r?{{!}}num) value(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=putd|description=Seeks directly for the provided device id, attempts to write the provided value to the stack at the provided address.|syntax=putd id(r?{{!}}num) address(r?{{!}}num) value(r?{{!}}num)}}
  
 
== Slot/Logic ==
 
== Slot/Logic ==
  
{{MIPSInstruction|instruction=l|description=Loads device LogicType to register by housing index value.|syntax=l r? d? logicType|example=
+
{{MIPSInstruction|instruction=l|description=Loads device LogicType to register by housing index value.|syntax=l r? d? logicType
 +
|example=
 
Read from the device on d0 into register 0
 
Read from the device on d0 into register 0
 
{{MIPSCode|l r0 d0 Setting}}
 
{{MIPSCode|l r0 d0 Setting}}
Line 82: Line 108:
 
alias Sensor d0
 
alias Sensor d0
 
l r0 Sensor Temperature
 
l r0 Sensor Temperature
}}
+
}}}}
}}
 
 
{{MIPSInstruction|instruction=ld|description=Loads device LogicType to register by direct ID reference.|syntax=ld r? id(r?{{!}}num) logicType}}
 
{{MIPSInstruction|instruction=ld|description=Loads device LogicType to register by direct ID reference.|syntax=ld r? id(r?{{!}}num) logicType}}
 
{{MIPSInstruction|instruction=lr|description=Loads reagent of device's ReagentMode where a hash of the reagent type to check for. ReagentMode can be either Contents (0), Required (1), Recipe (2). Can use either the word, or the number.|syntax=lr r? d? reagentMode int}}
 
{{MIPSInstruction|instruction=lr|description=Loads reagent of device's ReagentMode where a hash of the reagent type to check for. ReagentMode can be either Contents (0), Required (1), Recipe (2). Can use either the word, or the number.|syntax=lr r? d? reagentMode int}}
Line 94: Line 119:
 
alias robot d0
 
alias robot d0
 
alias charge r10
 
alias charge r10
ls charge robot 0 Charge  
+
ls charge robot 0 Charge
}}
+
}}}}
}}
+
{{MIPSInstruction|instruction=s|description=Stores register value to LogicType on device by housing index value.|syntax=s d? logicType r?
{{MIPSInstruction|instruction=s|description=Stores register value to LogicType on device by housing index value.|syntax=s d? logicType r?{{!}}num
 
 
|example=
 
|example=
 
{{MIPSCode|
 
{{MIPSCode|
 
s d0 Setting r0
 
s d0 Setting r0
}}
+
}}}}
}}
 
 
{{MIPSInstruction|instruction=sd|description=Stores register value to LogicType on device by direct ID reference.|syntax=sd id(r?{{!}}num) logicType r?}}
 
{{MIPSInstruction|instruction=sd|description=Stores register value to LogicType on device by direct ID reference.|syntax=sd id(r?{{!}}num) logicType r?}}
{{MIPSInstruction|instruction=ss|description=Stores register value to device stored in a slot LogicSlotType on device.|syntax=ss d? slotIndex logicSlotType r?{{!}}num}}
+
{{MIPSInstruction|instruction=ss|description=Stores register value to device stored in a slot LogicSlotType on device.|syntax=ss d? slotIndex logicSlotType r?}}
  
=== Batched ===
+
=== Slot/Logic / Batched ===
  
 
{{MIPSInstruction|instruction=lb|description=Loads LogicType from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lb r? deviceHash logicType batchMode}}
 
{{MIPSInstruction|instruction=lb|description=Loads LogicType from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lb r? deviceHash logicType batchMode}}
Line 112: Line 135:
 
{{MIPSInstruction|instruction=lbns|description=Loads LogicSlotType from slotIndex from all output network devices with provided type and name hashes using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lbns r? deviceHash nameHash slotIndex logicSlotType batchMode}}
 
{{MIPSInstruction|instruction=lbns|description=Loads LogicSlotType from slotIndex from all output network devices with provided type and name hashes using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lbns r? deviceHash nameHash slotIndex logicSlotType batchMode}}
 
{{MIPSInstruction|instruction=lbs|description=Loads LogicSlotType from slotIndex from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lbs r? deviceHash slotIndex logicSlotType batchMode}}
 
{{MIPSInstruction|instruction=lbs|description=Loads LogicSlotType from slotIndex from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.|syntax=lbs r? deviceHash slotIndex logicSlotType batchMode}}
{{MIPSInstruction|instruction=sb|description=Stores register value to LogicType on all output network devices with provided type hash.|syntax=sb deviceHash logicType int}}
+
{{MIPSInstruction|instruction=sb|description=Stores register value to LogicType on all output network devices with provided type hash.|syntax=sb deviceHash logicType r?}}
{{MIPSInstruction|instruction=sbn|description=Stores register value to LogicType on all output network devices with provided type hash and name.|syntax=sbn deviceHash nameHash logicType int}}
+
{{MIPSInstruction|instruction=sbn|description=Stores register value to LogicType on all output network devices with provided type hash and name.|syntax=sbn deviceHash nameHash logicType r?}}
{{MIPSInstruction|instruction=sbs|description=Stores register value to LogicSlotType on all output network devices with provided type hash in the provided slot.|syntax=sbs deviceHash slotIndex logicSlotType int}}
+
{{MIPSInstruction|instruction=sbs|description=Stores register value to LogicSlotType on all output network devices with provided type hash in the provided slot.|syntax=sbs deviceHash slotIndex logicSlotType r?}}
  
 
== Bitwise ==
 
== Bitwise ==
Line 131: Line 154:
  
 
{{MIPSInstruction|instruction=select|description=Register = b if a is non-zero, otherwise c|syntax=select r? a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)
 
{{MIPSInstruction|instruction=select|description=Register = b if a is non-zero, otherwise c|syntax=select r? a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)
|note=This operation can be used as a simple ternary condition}}
+
|example=
 +
{{MIPSCode|
 +
a
 +
# if r0 is non-zero, r1 = 10, otherwise r1 = 100
 +
select r1 r0 10 100
 +
}}
 +
|note=
 +
This operation can be used as a simple ternary condition}}
  
=== Compare Device Pin ===
+
=== Comparison / Device Pin ===
  
 
{{MIPSInstruction|instruction=sdns|description=Register = 1 if device is not set, otherwise 0|syntax=sdns r? d?}}
 
{{MIPSInstruction|instruction=sdns|description=Register = 1 if device is not set, otherwise 0|syntax=sdns r? d?}}
 
{{MIPSInstruction|instruction=sdse|description=Register = 1 if device is set, otherwise 0.|syntax=sdse r? d?}}
 
{{MIPSInstruction|instruction=sdse|description=Register = 1 if device is set, otherwise 0.|syntax=sdse r? d?}}
  
=== Compare Value ===
+
=== Comparison / Value ===
  
 
{{MIPSInstruction|instruction=sap|description=Register = 1 if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8), otherwise 0|syntax=sap r? a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sap|description=Register = 1 if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8), otherwise 0|syntax=sap r? a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sapz|description=Register = 1 if abs(a) <= max(b * abs(a), float.epsilon * 8), otherwise 0|syntax=sapz r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sapz|description=Register = 1 if abs(a) <= max(b * abs(a), float.epsilon * 8), otherwise 0|syntax=sapz r? a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=seq|description=Register = 1 if a = b, otherwise 0|syntax=seq r? a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=seq|description=Register = 1 if a == b, otherwise 0|syntax=seq r? a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=seqz|description=Register = 1 if a = 0, otherwise 0|syntax=seqz r? a(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=seqz|description=Register = 1 if a == 0, otherwise 0|syntax=seqz r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sge|description=Register = 1 if a >= b, otherwise 0|syntax=sge r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sge|description=Register = 1 if a >= b, otherwise 0|syntax=sge r? a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sgez|description=Register = 1 if a >= 0, otherwise 0|syntax=sgez r? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=sgez|description=Register = 1 if a >= 0, otherwise 0|syntax=sgez r? a(r?{{!}}num)}}
Line 161: Line 191:
 
== Branching ==
 
== Branching ==
  
{{MIPSInstruction|instruction=j|description=Jump execution to line a|syntax=j int}}
+
{{MIPSInstruction|instruction=j|description=Jump execution to line a|syntax=j int
{{MIPSInstruction|instruction=jal|description=Jump execution to line a and store next line number in ra|syntax=jal int}}
+
|example=
 +
{{MIPSCode|j 0 # jump line 0}}
 +
{{MIPSCode|
 +
j label # jump to a label
 +
 
 +
label:
 +
# your code here
 +
}}}}
 +
{{MIPSInstruction|instruction=jal|description=Jump execution to line a and store next line number in ra|syntax=jal int
 +
|example=
 +
jal provides a way to do function calls in IC10 mips
 +
 
 +
{{MIPSCode|
 +
move r0 1000
 +
move r1 0
 +
start:
 +
jal average
 +
s db Setting r0
 +
yield
 +
j start
 +
 
 +
average:
 +
add r0 r0 r1
 +
div r0 r0 2
 +
j ra # jump back
 +
}}}}
 
{{MIPSInstruction|instruction=jr|description=Relative jump to line a|syntax=jr int}}
 
{{MIPSInstruction|instruction=jr|description=Relative jump to line a|syntax=jr int}}
  
=== Branch Device Pin ===
+
=== Branching / Device Pin ===
  
 
{{MIPSInstruction|instruction=bdns|description=Branch to line a if device d isn't set|syntax=bdns d? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bdns|description=Branch to line a if device d isn't set|syntax=bdns d? a(r?{{!}}num)}}
Line 179: Line 234:
 
#Store line in ra and jump to label HarvestCrop if device d0 is assigned.
 
#Store line in ra and jump to label HarvestCrop if device d0 is assigned.
 
bdseal d0 HarvestCrop
 
bdseal d0 HarvestCrop
}}
+
}}}}
}}
 
 
{{MIPSInstruction|instruction=brdns|description=Relative jump to line a if device is not set|syntax=brdns d? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brdns|description=Relative jump to line a if device is not set|syntax=brdns d? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brdse|description=Relative jump to line a if device is set|syntax=brdse d? a(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brdse|description=Relative jump to line a if device is set|syntax=brdse d? a(r?{{!}}num)}}
  
=== Branching Comparison ===
+
=== Branching / Comparison ===
  
 
{{MIPSInstruction|instruction=bap|description=Branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)|syntax=bap a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bap|description=Branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)|syntax=bap a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
{{MIPSInstruction|instruction=bapal|description=Branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8) and store next line number in ra|syntax=bapal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=bapal|description=Branch to line c if a != b and store next line number in ra|syntax=bapal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bapz|description=Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)|syntax=bapz a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bapz|description=Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)|syntax=bapz a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bapzal|description=Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8) and store next line number in ra|syntax=bapzal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bapzal|description=Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8) and store next line number in ra|syntax=bapzal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
{{MIPSInstruction|instruction=beq|description=Branch to line c if a = b|syntax=beq a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=beq|description=Branch to line c if a == b|syntax=beq a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
{{MIPSInstruction|instruction=beqal|description=Branch to line c if a = b and store next line number in ra|syntax=beqal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=beqal|description=Branch to line c if a == b and store next line number in ra|syntax=beqal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
{{MIPSInstruction|instruction=beqz|description=Branch to line b if a = 0|syntax=beqz a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=beqz|description=Branch to line b if a == 0|syntax=beqz a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=beqzal|description=Branch to line b if a = 0 and store next line number in ra|syntax=beqzal a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=beqzal|description=Branch to line b if a == 0 and store next line number in ra|syntax=beqzal a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bge|description=Branch to line c if a >= b|syntax=bge a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bge|description=Branch to line c if a >= b|syntax=bge a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgeal|description=Branch to line c if a >= b and store next line number in ra|syntax=bgeal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgeal|description=Branch to line c if a >= b and store next line number in ra|syntax=bgeal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgez|description=Branch to line b if a >= 0|syntax=bgez a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgez|description=Branch to line b if a >= 0|syntax=bgez a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgezal|description=Branch to line b if a >= 0 and store next line number in ra|syntax=bgezal a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgezal|description=Branch to line b if a >= 0 and store next line number in ra|syntax=bgezal a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=bgt|description=Branch to line c if a > b|syntax=bgt a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=bgt|description=Branch to line c if a > b|syntax=bgt a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)
 +
|example=
 +
An example of a '''Schmitt''' trigger, turning on a device if the temperature is too low, and turning it off if it's too high and finally
 +
doing nothing if the temperature is within the desired range.
 +
{{MIPSCode|
 +
alias sensor d0
 +
alias device d1
 +
 
 +
define mintemp 293.15
 +
define maxtemp 298.15
 +
 
 +
start:
 +
yield
 +
l r0 sensor Temperature
 +
# If the temperature < mintemp, turn on the device
 +
blt r0 mintemp turnOn
 +
# If the temperature > maxtemp, turn off the device
 +
bgt r0 maxtemp turnOff
 +
j start
 +
 
 +
turnOn:
 +
s device On 1
 +
j start
 +
turnOff:
 +
s device On 0
 +
j start
 +
}}}}
 
{{MIPSInstruction|instruction=bgtal|description=Branch to line c if a > b and store next line number in ra|syntax=bgtal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgtal|description=Branch to line c if a > b and store next line number in ra|syntax=bgtal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgtz|description=Branch to line b if a > 0|syntax=bgtz a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bgtz|description=Branch to line b if a > 0|syntax=bgtz a(r?{{!}}num) b(r?{{!}}num)}}
Line 206: Line 286:
 
{{MIPSInstruction|instruction=blez|description=Branch to line b if a <= 0|syntax=blez a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=blez|description=Branch to line b if a <= 0|syntax=blez a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=blezal|description=Branch to line b if a <= 0 and store next line number in ra|syntax=blezal a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=blezal|description=Branch to line b if a <= 0 and store next line number in ra|syntax=blezal a(r?{{!}}num) b(r?{{!}}num)}}
{{MIPSInstruction|instruction=blt|description=Branch to line c if a < b|syntax=blt a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=blt|description=Branch to line c if a < b|syntax=blt a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)
 +
|example=
 +
An example of a '''Schmitt''' trigger, turning on a device if the temperature is too low, and turning it off if it's too high and finally
 +
doing nothing if the temperature is within the desired range.
 +
{{MIPSCode|
 +
alias sensor d0
 +
alias device d1
 +
 
 +
define mintemp 293.15
 +
define maxtemp 298.15
 +
 
 +
start:
 +
yield
 +
l r0 sensor Temperature
 +
# If the temperature < mintemp, turn on the device
 +
blt r0 mintemp turnOn
 +
# If the temperature > maxtemp, turn off the device
 +
bgt r0 maxtemp turnOff
 +
j start
 +
 
 +
turnOn:
 +
s device On 1
 +
j start
 +
turnOff:
 +
s device On 0
 +
j start
 +
}}}}
 
{{MIPSInstruction|instruction=bltal|description=Branch to line c if a < b and store next line number in ra|syntax=bltal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bltal|description=Branch to line c if a < b and store next line number in ra|syntax=bltal a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bltz|description=Branch to line b if a < 0|syntax=bltz a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=bltz|description=Branch to line b if a < 0|syntax=bltz a(r?{{!}}num) b(r?{{!}}num)}}
Line 221: Line 327:
 
{{MIPSInstruction|instruction=brap|description=Relative branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)|syntax=brap a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brap|description=Relative branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)|syntax=brap a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num) d(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brapz|description=Relative branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)|syntax=brapz a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brapz|description=Relative branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)|syntax=brapz a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
{{MIPSInstruction|instruction=breq|description=Relative branch to line c if a = b|syntax=breq a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=breq|description=Relative branch to line c if a == b|syntax=breq a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
{{MIPSInstruction|instruction=breqz|description=Relative branch to line b if a = 0|syntax=breqz a(r?{{!}}num) b(r?{{!}}num)}}
+
{{MIPSInstruction|instruction=breqz|description=Relative branch to line b if a == 0|syntax=breqz a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brge|description=Relative jump to line c if a >= b|syntax=brge a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brge|description=Relative jump to line c if a >= b|syntax=brge a(r?{{!}}num) b(r?{{!}}num) c(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brgez|description=Relative branch to line b if a >= 0|syntax=brgez a(r?{{!}}num) b(r?{{!}}num)}}
 
{{MIPSInstruction|instruction=brgez|description=Relative branch to line b if a >= 0|syntax=brgez a(r?{{!}}num) b(r?{{!}}num)}}

Revision as of 10:58, 29 April 2024

See MIPS for the primary page for IC10 MIPS. This page lists all available instructions


Utility

alias str r?|d? 

Labels register or device reference with name, device references also affect what shows on the screws on the IC base.

Example:

alias dAutoHydro1 d0
alias vTemperature r0


define str num 

Creates a label that will be replaced throughout the program with the provided value.

Example:

define ultimateAnswer 42
move r0 ultimateAnswer # Store 42 in register 0


hcf 

Halt and catch fire



sleep a(r?|num) 

Pauses execution on the IC for a seconds



yield 

Pauses execution for 1 tick



Mathematical

abs r? a(r?|num) 

Register = the absolute value of a

Example:

define negativeNumber -10
abs r0 negativeNumber # Compute the absolute value of -10 and store it in register 0


add r? a(r?|num) b(r?|num) 

Register = a + b.

Example:

add r0 r0 1 # increment r0 by one


define num1 10
define num2 20
add r0 num1 num2 # Add 10 and 20 and store the result in register 0


ceil r? a(r?|num) 

Register = smallest integer greater than a

Example:

define floatNumber 10.3
ceil r0 floatNumber # Compute the ceiling of 10.3 and store it in register 0


div r? a(r?|num) b(r?|num) 

Register = a / b



exp r? a(r?|num) 

exp(a) or e^a



floor r? a(r?|num) 

Register = largest integer less than a



log r? a(r?|num) 

base e log(a) or ln(a)



max r? a(r?|num) b(r?|num) 

Register = max of a or b



min r? a(r?|num) b(r?|num) 

Register = min of a or b



mod r? a(r?|num) b(r?|num) 

Register = a mod b (note: NOT a % b)

Example:


move r? a(r?|num) 

Register = provided num or register value.

Example:

move r0 42 # Store 42 in register 0


mul r? a(r?|num) b(r?|num) 

Register = a * b



rand r? 

Register = a random value x with 0 <= x < 1



round r? a(r?|num) 

Register = a rounded to nearest integer



sqrt r? a(r?|num) 

Register = square root of a



sub r? a(r?|num) b(r?|num) 

Register = a - b.



trunc r? a(r?|num) 

Register = a with fractional part removed



Mathematical / Trigonometric

acos r? a(r?|num) 

Returns the angle (radians) whos cos is the specified value



asin r? a(r?|num) 

Returns the angle (radians) whos sine is the specified value



atan r? a(r?|num) 

Returns the angle (radians) whos tan is the specified value



atan2 r? a(r?|num) b(r?|num) 

Returns the angle (radians) whose tangent is the quotient of two specified values: a (y) and b (x)



cos r? a(r?|num) 

Returns the cosine of the specified angle (radians)



sin r? a(r?|num) 

Returns the sine of the specified angle (radians)



tan r? a(r?|num) 

Returns the tan of the specified angle (radians)



Stack

clr d? 

Clears the stack memory for the provided device.



get r? d? address(r?|num) 

Using the provided device, attempts to read the stack value at the provided address, and places it in the register.



getd r? id(r?|num) address(r?|num) 

Seeks directly for the provided device id, attempts to read the stack value at the provided address, and places it in the register.



peek r? 

Register = the value at the top of the stack



poke address(r?|num) value(r?|num) 

Stores the provided value at the provided address in the stack.



pop r? 

Register = the value at the top of the stack and decrements sp



push a(r?|num) 

Pushes the value of a to the stack at sp and increments sp



put d? address(r?|num) value(r?|num) 

Using the provided device, attempts to write the provided value to the stack at the provided address.



putd id(r?|num) address(r?|num) value(r?|num) 

Seeks directly for the provided device id, attempts to write the provided value to the stack at the provided address.



Slot/Logic

l r? d? logicType 

Loads device LogicType to register by housing index value.

Example:

Read from the device on d0 into register 0

l r0 d0 Setting

Read the pressure from a sensor

l r1 d5 Pressure

This also works with aliases. For example:

alias Sensor d0
l r0 Sensor Temperature


ld r? id(r?|num) logicType 

Loads device LogicType to register by direct ID reference.



lr r? d? reagentMode int 

Loads reagent of device's ReagentMode where a hash of the reagent type to check for. ReagentMode can be either Contents (0), Required (1), Recipe (2). Can use either the word, or the number.



ls r? d? slotIndex logicSlotType 

Loads slot LogicSlotType on device to register.

Example:

Read from the second slot of device on d0, stores 1 in r0 if it's occupied, 0 otherwise.

ls r0 d0 2 Occupied

And here is the code to read the charge of an AIMeE:

alias robot d0
alias charge r10
ls charge robot 0 Charge


s d? logicType r? 

Stores register value to LogicType on device by housing index value.

Example:

s d0 Setting r0


sd id(r?|num) logicType r? 

Stores register value to LogicType on device by direct ID reference.



ss d? slotIndex logicSlotType r? 

Stores register value to device stored in a slot LogicSlotType on device.



Slot/Logic / Batched

lb r? deviceHash logicType batchMode 

Loads LogicType from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.



lbn r? deviceHash nameHash logicType batchMode 

Loads LogicType from all output network devices with provided type and name hashes using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.



lbns r? deviceHash nameHash slotIndex logicSlotType batchMode 

Loads LogicSlotType from slotIndex from all output network devices with provided type and name hashes using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.



lbs r? deviceHash slotIndex logicSlotType batchMode 

Loads LogicSlotType from slotIndex from all output network devices with provided type hash using the provide batch mode. Average (0), Sum (1), Minimum (2), Maximum (3). Can use either the word, or the number.



sb deviceHash logicType r? 

Stores register value to LogicType on all output network devices with provided type hash.



sbn deviceHash nameHash logicType r? 

Stores register value to LogicType on all output network devices with provided type hash and name.



sbs deviceHash slotIndex logicSlotType r? 

Stores register value to LogicSlotType on all output network devices with provided type hash in the provided slot.



Bitwise

and r? a(r?|num) b(r?|num) 

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.



nor r? a(r?|num) b(r?|num) 

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.



not r? a(r?|num) 

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.



or r? a(r?|num) b(r?|num) 

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.



sla r? a(r?|num) b(r?|num) 

Performs a bitwise arithmetic left shift operation on the binary representation of a value. It shifts the bits to the left and fills the vacated rightmost bits with a copy of the sign bit (the most significant bit).



sll r? a(r?|num) b(r?|num) 

Performs a bitwise logical left shift operation on the binary representation of a value. It shifts the bits to the left and fills the vacated rightmost bits with zeros.



sra r? a(r?|num) b(r?|num) 

Performs a bitwise arithmetic right shift operation on the binary representation of a value. It shifts the bits to the right and fills the vacated leftmost bits with a copy of the sign bit (the most significant bit).



srl r? a(r?|num) b(r?|num) 

Performs a bitwise logical right shift operation on the binary representation of a value. It shifts the bits to the right and fills the vacated leftmost bits with zeros



xor r? a(r?|num) b(r?|num) 

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.



Comparison

select r? a(r?|num) b(r?|num) c(r?|num) 

Register = b if a is non-zero, otherwise c

Note:

This operation can be used as a simple ternary condition

Example:


Comparison / Device Pin

sdns r? d? 

Register = 1 if device is not set, otherwise 0



sdse r? d? 

Register = 1 if device is set, otherwise 0.



Comparison / Value

sap r? a(r?|num) b(r?|num) c(r?|num) 

Register = 1 if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8), otherwise 0



sapz r? a(r?|num) b(r?|num) 

Register = 1 if abs(a) <= max(b * abs(a), float.epsilon * 8), otherwise 0



seq r? a(r?|num) b(r?|num) 

Register = 1 if a == b, otherwise 0



seqz r? a(r?|num) 

Register = 1 if a == 0, otherwise 0



sge r? a(r?|num) b(r?|num) 

Register = 1 if a >= b, otherwise 0



sgez r? a(r?|num) 

Register = 1 if a >= 0, otherwise 0



sgt r? a(r?|num) b(r?|num) 

Register = 1 if a > b, otherwise 0



sgtz r? a(r?|num) 

Register = 1 if a > 0, otherwise 0



sle r? a(r?|num) b(r?|num) 

Register = 1 if a <= b, otherwise 0



slez r? a(r?|num) 

Register = 1 if a <= 0, otherwise 0



slt r? a(r?|num) b(r?|num) 

Register = 1 if a < b, otherwise 0



sltz r? a(r?|num) 

Register = 1 if a < 0, otherwise 0



sna r? a(r?|num) b(r?|num) c(r?|num) 

Register = 1 if abs(a - b) > max(c * max(abs(a), abs(b)), float.epsilon * 8), otherwise 0



snan r? a(r?|num) 

Register = 1 if a is NaN, otherwise 0



snanz r? a(r?|num) 

Register = 0 if a is NaN, otherwise 1



snaz r? a(r?|num) b(r?|num) 

Register = 1 if abs(a) > max(b * abs(a), float.epsilon), otherwise 0



sne r? a(r?|num) b(r?|num) 

Register = 1 if a != b, otherwise 0



snez r? a(r?|num) 

Register = 1 if a != 0, otherwise 0



Branching

j int 

Jump execution to line a

Example:

j 0 # jump line 0


j label # jump to a label

label:
# your code here


jal int 

Jump execution to line a and store next line number in ra

Example:

jal provides a way to do function calls in IC10 mips

move r0 1000
move r1 0
start:
jal average
s db Setting r0
yield
j start

average:
add r0 r0 r1
div r0 r0 2
j ra # jump back


jr int 

Relative jump to line a



Branching / Device Pin

bdns d? a(r?|num) 

Branch to line a if device d isn't set



bdnsal d? a(r?|num) 

Jump execution to line a and store next line number if device is not set



bdse d? a(r?|num) 

Branch to line a if device d is set



bdseal d? a(r?|num) 

Jump execution to line a and store next line number if device is set

Example:

#Store line number and jump to line 32 if d0 is assigned.
bdseal d0 32


#Store line in ra and jump to label HarvestCrop if device d0 is assigned.
bdseal d0 HarvestCrop


brdns d? a(r?|num) 

Relative jump to line a if device is not set



brdse d? a(r?|num) 

Relative jump to line a if device is set



Branching / Comparison

bap a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)



bapal a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Branch to line c if a != b and store next line number in ra



bapz a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)



bapzal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8) and store next line number in ra



beq a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a == b



beqal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a == b and store next line number in ra



beqz a(r?|num) b(r?|num) 

Branch to line b if a == 0



beqzal a(r?|num) b(r?|num) 

Branch to line b if a == 0 and store next line number in ra



bge a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a >= b



bgeal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a >= b and store next line number in ra



bgez a(r?|num) b(r?|num) 

Branch to line b if a >= 0



bgezal a(r?|num) b(r?|num) 

Branch to line b if a >= 0 and store next line number in ra



bgt a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a > b

Example:

An example of a Schmitt trigger, turning on a device if the temperature is too low, and turning it off if it's too high and finally doing nothing if the temperature is within the desired range.

alias sensor d0
alias device d1

define mintemp 293.15
define maxtemp 298.15

start:
yield
l r0 sensor Temperature
# If the temperature < mintemp, turn on the device
blt r0 mintemp turnOn
# If the temperature > maxtemp, turn off the device
bgt r0 maxtemp turnOff
j start

turnOn:
s device On 1
j start
turnOff:
s device On 0
j start


bgtal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a > b and store next line number in ra



bgtz a(r?|num) b(r?|num) 

Branch to line b if a > 0



bgtzal a(r?|num) b(r?|num) 

Branch to line b if a > 0 and store next line number in ra



ble a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a <= b



bleal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a <= b and store next line number in ra



blez a(r?|num) b(r?|num) 

Branch to line b if a <= 0



blezal a(r?|num) b(r?|num) 

Branch to line b if a <= 0 and store next line number in ra



blt a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a < b

Example:

An example of a Schmitt trigger, turning on a device if the temperature is too low, and turning it off if it's too high and finally doing nothing if the temperature is within the desired range.

alias sensor d0
alias device d1

define mintemp 293.15
define maxtemp 298.15

start:
yield
l r0 sensor Temperature
# If the temperature < mintemp, turn on the device
blt r0 mintemp turnOn
# If the temperature > maxtemp, turn off the device
bgt r0 maxtemp turnOff
j start

turnOn:
s device On 1
j start
turnOff:
s device On 0
j start


bltal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a < b and store next line number in ra



bltz a(r?|num) b(r?|num) 

Branch to line b if a < 0



bltzal a(r?|num) b(r?|num) 

Branch to line b if a < 0 and store next line number in ra



bna a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Branch to line d if abs(a - b) > max(c * max(abs(a), abs(b)), float.epsilon * 8)



bnaal a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8) and store next line number in ra



bnan a(r?|num) b(r?|num) 

Branch to line b if a is not a number (NaN)



bnaz a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if abs(a) > max (b * abs(a), float.epsilon * 8)



bnazal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if abs(a) > max (b * abs(a), float.epsilon * 8) and store next line number in ra



bne a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a != b



bneal a(r?|num) b(r?|num) c(r?|num) 

Branch to line c if a != b and store next line number in ra



bnez a(r?|num) b(r?|num) 

branch to line b if a != 0



bnezal a(r?|num) b(r?|num) 

Branch to line b if a != 0 and store next line number in ra



brap a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Relative branch to line d if abs(a - b) <= max(c * max(abs(a), abs(b)), float.epsilon * 8)



brapz a(r?|num) b(r?|num) c(r?|num) 

Relative branch to line c if abs(a) <= max(b * abs(a), float.epsilon * 8)



breq a(r?|num) b(r?|num) c(r?|num) 

Relative branch to line c if a == b



breqz a(r?|num) b(r?|num) 

Relative branch to line b if a == 0



brge a(r?|num) b(r?|num) c(r?|num) 

Relative jump to line c if a >= b



brgez a(r?|num) b(r?|num) 

Relative branch to line b if a >= 0



brgt a(r?|num) b(r?|num) c(r?|num) 

relative jump to line c if a > b



brgtz a(r?|num) b(r?|num) 

Relative branch to line b if a > 0



brle a(r?|num) b(r?|num) c(r?|num) 

Relative jump to line c if a <= b



brlez a(r?|num) b(r?|num) 

Relative branch to line b if a <= 0



brlt a(r?|num) b(r?|num) c(r?|num) 

Relative jump to line c if a < b



brltz a(r?|num) b(r?|num) 

Relative branch to line b if a < 0



brna a(r?|num) b(r?|num) c(r?|num) d(r?|num) 

Relative branch to line d if abs(a - b) > max(c * max(abs(a), abs(b)), float.epsilon * 8)



brnan a(r?|num) b(r?|num) 

Relative branch to line b if a is not a number (NaN)



brnaz a(r?|num) b(r?|num) c(r?|num) 

Relative branch to line c if abs(a) > max(b * abs(a), float.epsilon * 8)



brne a(r?|num) b(r?|num) c(r?|num) 

Relative branch to line c if a != b



brnez a(r?|num) b(r?|num) 

Relative branch to line b if a != 0