VS code Sample project https://github.com/Traineratwot/Ic10-and-Icx-Sample
{
"version": "0.2.0",
"configurations": [
{
"type": "ic10",
"request": "launch",
"name": "Debug ic10",
"program": "${file}",
"stopOnEntry": true,
"trace": false
}
]
}
OR FOR ICX
{
"version": "0.2.0",
"configurations": [
{
"type": "ic10",
"request": "launch",
"name": "Debug ic10",
"program": "${fileWorkspaceFolder}${pathSeparator}${fileBasenameNoExtension}.ic10",
"stopOnEntry": true,
"trace": false
}
]
}
use comments
on first lineuse comments var a = 1 # comment ic10 var b = 1 #! comment icX # comment2 ic10 #! comment2 icX
move r0 1 # comment ic10 move r1 1 # comment2 ic10
var a = 10
move r0 10
use aliases var a = 10
alias a r0 move a 10
use constants const PI = 3.14
define PI 3.14
var a = 0 a++
move r0 0 add r0 r0 1
var a = 0 a--
move r0 0 sub r0 r0 1
var x = 5 + 5 * 2
move r0 15
const x = 2 + 2 const y = x + 2 var z = y + 2
move r0 8
var k = 2 var y = 5 var x = y + y * k
move r0 2 move r1 5 mul r15 r1 r0 add r2 r1 r15 add r2 r2 5
< : Less than (Compares)
== : Equal to (Compares)
> : Greater Than (Compares)
<= : Less than OR Equal To (Compares)
>= : Greater than OR Equal to (Compares)
|| : OR (Compares)
&& : AND (Compares)
~= : Almost Equals (Compares)
!= : NOT Equal to (Compares)
dse : connected port?
var a = 8 var b = -1 if a > 5 && d1 dse 1 b = 1 else b = 0 end
move r0 8 move r1 -1 sgt r15 r0 5 sdns r14 d1 and r13 r15 r14 beqz r13 if0else move r1 1 j if0exit if0else: move r1 0 if0exit:
synonyms
var a = 0 while a >= 10 a++ end
move r0 0 while0: sge r15 r0 10 beqz r15 while0exit add r0 r0 1 j while0 while0exit:
d0.Setting = 1 # Set device param var a = d0.Setting # Load device param into a register var b = d0.slot(a).PrefabHash # Using a slot of the device a = d(5438547545).Setting(Sum) # Batch load, where 5438547545 is hash of the device d(5438547545).Setting = b # Batch configuration
s d0 Setting 1 l r0 d0 Setting ls r1 d0 r0 PrefabHash lb r0 5438547545 Setting Sum sb 5438547545 Setting r1
synonyms
{function name}()
function {function name}
{code}
end
use comments var x = 5 const y = 15 if x < 5 d0.Setting =0 end function update(b, c=0) d0.Setting = b d0.Vertical = c end update(80,y) function pifagor(b, c =10) var a = (b*b) + (c*c) return a end var result = pifagor(x)
move r0 5 slt r15 r0 5 beqz r15 if0exit s d0 Setting 0 if0exit: move r15 80 move r14 15 jal update move r15 r0 move r14 10 jal pifagor move r2 r14 jr 11 update: s d0 Setting r15 s d0 Vertical r14 j ra pifagor: mul r11 r13 r13 mul r10 r12 r12 add r1 r11 r10 j ra
all s-functions can be used in assignment
use aliases var a = seq(1,1) a = seq(1,2)
alias a r0 seq a 1 1 seq a 1 2
use aliases use const var a = 1 const b = 2 stack a b 8 r3
alias a r0 move a 1 push a push 2 push 8 push r3
synonyms
var YourVariabele = 0 foreach YourVariabele if YourVariabele == 32 var b = 5 end end
move r0 0 move sp 0 while0: peek r0 seq r15 r0 32 beqz r15 if0exit move r1 5 if0exit: breqz r0 3 add sp sp 1 j while0
To loop the application, use use loop
use loop var a = 1 var b = 2 function test1 debug a end function test2 debug b end
move r0 1 move r1 2 j 0 # that loop test1: j ra test2: j ra
use comments #Example #!Example var a = 0 var on = d1.Open #Example #Example d0.On = on test() function test var c = 1 end
#Example move r0 0 l r1 d1 Open #Example #Example s d0 On r1 jal test jr 4 test: move r2 1 j ra
use comments use constants #d0 111111 #set device hash #d0 Activate 1 #set device parameter #d0 0 PrefabHash 22222 #set slot parameter const PI = 3.14 stack 2 4 8 16 32 64 debug d0.Activate debug d0.hash debug d0.slot.0.PrefabHash debug PI debug d0.Activate debug 1 2 3 debug r0 r1 r2 debug "Some text" debug sp
#d0 111111 #set device hash #d0 Activate 1 #set device parameter #d0 0 PrefabHash 22222 #set slot parameter define PI 3.14 push 2 push 4 push 8 push 16 push 32 push 64 #log d0.Activate #log d0.hash #log d0.slot.0.PrefabHash #log PI #log d0.Activate #log 1 2 3 #log r0 r1 r2 #log "Some text" #log sp
var a = d0.Mode switch a case 1 act1() end case 2 act2() end case 3 act3() end end function act1 debug 'act1' end function act2 debug 'act2' end function act3 debug 'act3' end
l r0 d0 Mode brne r0 1 2 jal act1 brne r0 2 2 jal act2 brne r0 3 2 jal act3 jr 7 act1: j ra act2: j ra act3: j ra
# --=<< MeteorSbor >>=--
# Mine position and Battery
define Distance 90 # Meters 90m
define Direction 340 # Degrees 0-360°
define MinBat 10000 # 10k/72k
define MinBatStart 71900 # 99.9%
# Battery 36000 288000 2304000 Cell 12000 72000
alias BaseX r10 # Base
alias BaseY r11
alias BaseZ r12
alias MineX r13 # Mine
alias MineY r14
alias MineZ r15
alias Robot db # Port Robot
alias Status r9 # Return No/Yes
l BaseX Robot PositionX # Setup Base
l BaseY Robot PositionY
l BaseZ Robot PositionZ
div r0 Direction 180 # Mine Position
mul r0 r0 3.1415
cos r1 r0
sin r0 r0
sub r0 0 r0 #-MineZ
mul r1 r1 Distance
mul r0 r0 Distance
add MineX r1 BaseX
move MineY BaseY
add MineZ r0 BaseZ
move sp 0
Start: # ---------- Start ----------
yield
move r0 2 # Ore UnLoad Ok
move r1 0
ls r3 Robot r0 Occupied
add r1 r1 r3
add r0 r0 1
brlt r0 10 -3
brlt r1 0.9 3 # Emple
s Robot Mode 4 # UnLoad
j GoBase # or Start ++++++++++++++++++++++++++
ls r0 Robot 0 Charge # Battery
blt r0 MinBatStart GoBase
GoMine: # --- Go To Mine Position ---
move Status 0 # No Return
move r0 MineX
move r1 MineY
move r2 MineZ
jal GoTo # GoTo(r0,r1,r2)
Mine: # ---------- Mine -----------
s Robot Mode 3
yield
ls r0 Robot 0 Charge # Battery low
blt r0 MinBat GoBase
l r0 Robot Mode # Mine
breq r0 3 -3 # Mine End
beq r0 0 Mine
GoBase: # -------- Go To Base -------
move Status 1 # Return
jr 4 # Off New Setup Mine ========
l MineX Robot PositionX # Setup Mine
l MineY Robot PositionY
l MineZ Robot PositionZ
move r0 BaseX
move r1 BaseY
move r2 BaseZ
jal GoTo # GoTo(r0,r1,r2)
j Start # ====== END => UnLoad ======
s Robot Mode 2 # ----- Function Go To -----
yield
GoTo:
s Robot TargetX r0 # Position
s Robot TargetY r1
s Robot TargetZ r2
brnez Status 3 # Battery Low
ls r5 Robot 0 Charge
blt r5 MinBat GoBase
l r3 Robot PositionX # Stop
l r4 Robot PositionZ
sub r3 r3 r0
sub r4 r4 r2
mul r3 r3 r3
mul r4 r4 r4
add r3 r3 r4
brgt r3 1 -16 # sqrt 1
j ra