Skip to main content

Operations

This category consists of execution related instructions such as sequential and conditional branching. Down counting timer and delay insertion are also included in this category.

0x00 Nop

Do nothing, program counter moves on to next line.

tip

Instruction 0x00 can be used as line-skipper. Leaving empty lines could be helpful for later use.

INST_NOPHEXOP-0OP-1
Do nothing0000000000
info
OP/sOPValue/RangeRemark
OP-00000Ignored
OP-10000Ignored

0x01 Set Digital Output Pins

Send a specific value to digital output pins, setting them to HIGH or to LOW.

The on-board mono colour LEDs are indicators of the output pins, a HIGH turns the corresponding LED on, a LOW turns it off.

tip

Digital output pins are typically used to drive electronic modules such as motor driver, power relay and so on.

caution

Some digital output pins may be occupied by specific modules or become not available as digital output pins when ultrasonic distance detector or MIDI player functions are enabled.

warning

Digital output pins can not afford high power load such as motors, they work on logic level only.

INST_DIGITAL_OUTPUTHEXsOP00sOP01sOP10sOP11
Set DO0 to HIGH0100000001
Set DO3-DO0 with HIGH, LOW, LOW, HIGH0100FF0009

Notice in the second example the 4 digital output pins are set to b1001 in consistent of the desired HIGH, LOW, LOW, HIGH:

(1001)2=23+20=9160=(09)16(1001)_{2}=2^{3}+2^{0}=9\cdot16^{0}=(09)_{16}

There for sOP11 should be 0x09.

Set one digital output pin
OP/sOPValueRemark
sOP0000Ignored
sOP0100~03Select output pin LED0~LED3 (DO0~DO3)
sOP1000Ignored
sOP1100Set digital output HIGH
01Set digital output LOW
Set all digital output pins
OP/sOPValueRemark
sOP0000Ignored
sOP01FFUse bitwise digital output configuration
sOP1000Ignored
sOP1100~0FCorresponding hexadecimal value for digital output pins

0x02 Set Delay

Set a delay to hold the program counter for a moment before pointing to the next line.

tip

The length of delay can be set by literal value or by a value stored in a register.

INST_PROG_DELAYHEXOP-0sOP10sOP11
Delay 1000 ms0203E80000
Delay R01 ms020001FF00
Delay based on literal value
OP/sOPValueRemark
OP-00000~FFFFValue for the delay
sOP1000Using literal value
sOP1100Unit: millisecond
01Unit: second
02Unit: Minute
Delay based on value stored in a register
OP/sOPValueRemark
OP-00000~003FRegister Index
sOP10FFUsing value in registers
sOP1100Unit: millisecond
01Unit: second
02Unit: Minute

0x03 Set Timer

Set a down counter as timer, the length is determined by a literal value or a register value, plus the unit specified in opcode. Register R23 is set to 0001; when the down counting is done, R23 is reset to 0000, indicating that the down counting reaches the end.

tip

Setting timer does not change the program counter and the execution order of lines.

caution

Down counter register R23 can be used as a regular user register, it's value will be overwritten when setting the timer or at time out.

INST_SET_TIMERHEXOP-0OP-1
Set a 5000 ms timer0313880000
Set a 10 s timer03000A0001
info
OP/sOPValue/RangeRemarks
OP-00000~FFFFDown counting value
OP-10000Unit: millisecond
0001Unit: second
0002Unit: minute

0x04 Conditional Jump: Greater than Literal Value

If value stored in register R00 is greater than the given literal, jump to target line, otherwise continue running to the next line.

INST_JUMP_IF_REG0_GRHEXOP-0OP-1
If value in R00 is greater than 00FF,jump to line 01C00400FF01C0
info
OP/sOPValue/RangeRemarks
OP-00000~FFFFInput values
OP-10000~01FFTarget line

0x05 Conditional Jump: Less than Literal Value

If value stored in register R00 is less than the given literal, jump to target line, otherwise continue running to the next line.

INST_JUMP_IF_REG0_LSHEXOP-0OP-1
If value in R00 is less than 00EA,jump to line 01C50500EA01C5
info
OP/sOPValue/RangeRemarks
OP-00000~FFFFInput values
OP-10000~01FFTarget line

0x06 Conditional Jump: Equals to Literal Value

If value stored in register R00 is equal to the given literal, jump to target line, otherwise continue running to the next line.

INST_JUMP_IF_REG0_EQHEXOP-0OP-1
If value in R00 is equal to 00EC,jump to line 00270600EC0027
info
OP/sOPValue/RangeRemarks
OP-00000~FFFFInput values
OP-10000~01FFTarget line

0x07 Conditional Jump: Greater than Register Value

If value stored in register R00 is greater than that in a selected register, jump to target line, otherwise continue running to the next line.

INST_REG0_REGx_JIGRHEXsOP00sOP01OP-1
If value in R00 is greater than that in R05,jump to line 00100700050010
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister Index
OP-10000~01FFTarget line

0x08 Conditional Jump: Less than Register Value

If value stored in register R00 is less than that in a selected register, jump to target line, otherwise continue running to the next line.

INST_REG0_REGx_JILSHEXsOP00sOP01OP-1
If value in R00 is less than that in R05,jump to line 00200800050020
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister Index
OP-10000~01FFTarget line

0x09 Conditional Jump: Equals to Register Value

If value stored in register R00 is equal to that in a selected register, jump to target line, otherwise continue running to the next line.

INST_REG0_REGx_JIEQHEXsOP00sOP01OP-1
If value in R00 is equal to that in R05,jump to line 00300900050030
info
OP/sOPValue/RangeRemarks
sOP0000Ignored
sOP0100~3FRegister Index
OP-10000~FFFFTarget line

0x0A Advanced Conditional Jump: Register Comparison

Compare the value stored in register R00 with that in a selected register, giving a judge condition, if the equality/inequality establishes, jump to target line, otherwise continue running to the next line.

INST_JUMP_CONDITIONHEXsOP00sOP01OP-1
If value in R00 is not equal to that in R05,jump to line 00300A02050030
If value in R00 is greater than that in R05,jump to line 00400A05050040
If value in R05 is zero,jump to line 00500A07050050
info
OP/sOPValue/RangeRemarks
sOP0001judge:=
02judge:≠
03judge:>
04judge:<
05judge:≥
06judge:≤
07judge:is zero
08judge:is not zero
sOP0100~3FRegister Index
OP-10000~01FFTarget line

0x0B Advanced Conditional Jump: Digital Input

The digital input signals on DI0-DI3 determines a line jump action.

INST_JUMP_IF_PORTHEXsOP00sOP01OP-1
If DI3 is HIGH,jump to line 00300B03010030
If the four digital inputs are b1101,jump to line 00500BFF0D0050

In the second example, binary value 1101 is converted to hexadecimal for comarison:

(1101)2=23+22+20=13160=(0D)16(1101)_{2}=2^{3}+2^{2}+2^{0}=13\cdot16^{0}=(0D)_{16}

Therefore sOP01 is 0D.

Check one digital input pin
OP/sOPValue/RangeRemarks
sOP0000~03Pin DIN0~DIN3
sOP0100Input signal is a LOW
01Input signal is a HIGH
OP-10000~01FFTarget line
Check all digital input pins
OP/sOPValue/RangeRemarks
sOP00FFAll digital input pins
sOP0100~0Fhexadecimal value corresponding to the four input pins
OP-10000~01FFTarget line

0x0C Call: Jump to A Subroutine

The call instruction interrupts the flow of a program and jump to a target subroutine. A return instruction is needed to go back to the interrupted position.

tip

Multi-level Call+Return is supported.

caution

The target subroutine must contain a 0D instruction to return to the interrupted position to continue.

INST_ROUTINEHEXOP-0OP-1
Call subroutine at line 00800C00800000
info
OP/sOPValue/RangeRemarks
OP-00000~01FFTarget line
OP-10000Ignored

0x0D Return: Back from a Subroutine

Leave the current subroutine and return to the previous interrupted position where a 0C was called, and continue with the next line.

caution

This instruction must be used together with 0C

INST_RETURNHEXOP-0OP-1
Return to the previous interrupted position0D00000000
info
OP/sOPValue/RangeRemarks
OP-00000Ignored
OP-10000Ignored

0x0E Unconditional Jump

Jump to target line without any condition.

INST_JUMP_TOHEXOP-0OP-1
Jump to line 00100E00000010
info
OP/sOPValue/RangeRemarks
OP-00000Ignored
OP-10000~01FFTarget line

0x0F Program Termination

Terminate the program and stop.

caution

If there is not a 0F instruction in the program, it will run till 0x1FF.

INST_TERMINATEHEXOP-0OP-1
Stop running the program0F00000000
info
OP/sOPValue/RangeRemarks
OP-00000Ignored
OP-10000Ignored