Skip to main content

Instruction Samples

40 complete example programs from the instruction manual. Copy a whole program to share it, or send it straight to the Code Analyzer for a line-by-line breakdown. Gray 00 marks unused placeholder bytes.

NOP - No OperationSKIP / 0x00
Do nothing, program counter moves on to next line. Can be used as a placeholder for future modifications.
000 00 0000 0000
001 00 0000 0000
002 00 0000 0000
003 0F 0000 0000
Set Digital Output / 0x01
Set digital output pins to HIGH or LOW. HIGH turns LED on, LOW turns LED off.
000 01 0000 0001
001 00 0000 0000
002 01 0000 0000
003 00 0000 0000
004 01 0000 0009
005 0F 0000 0000
Set DelayYS / 0x02
Set a delay before executing the next line. Unit can be millisecond, second, or minute.
000 01 0000 0001
001 02 03E8 0000
002 01 0000 0000
003 02 03E8 0000
004 0F 0000 0000
Set TimerDS / 0x03
Set a down counter as timer. Register R23 is set to 0001 during countdown, reset to 0000 when done.
000 03 1388 0000
001 03 0000 0000
002 0F 0000 0000
Conditional Jump: Greater than Literal ValueDYZ / 0x04
If value in R00 is greater than the given literal, jump to target line.
000 10 0000 0000
001 02 0001 0001
002 12 0000 0001
003 04 0008 0010
004 05 0008 0020
005 06 0008 0030
006 02 03E8 0000
007 0E 0000 0001
010 01 00FF 000C
011 0E 0000 0001
020 01 00FF 0003
021 0E 0000 0001
030 01 00FF 0006
031 0E 0000 0001
Conditional Jump: Greater than Register ValueDDZ / 0x07
If value in R00 is greater than the value in specified register, jump to target line.
000 10 0000 0000
001 10 0005 0008
002 12 0000 0001
003 07 0005 0010
004 08 0005 0020
005 09 0005 0030
006 02 03E8 0000
007 0E 0000 0002
010 01 00FF 0008
011 0E 0000 0001
020 01 00FF 0004
021 0E 0000 0001
030 01 00FF 0002
031 0E 0000 0001
Advanced Conditional Jump: Register ComparisonTJZ / 0x0A
Compare value in R00 with specified register, jump based on comparison result.
000 10 0000 0064
001 10 0000 0050
002 0A 0003 0005
003 01 0000 0001
004 0F 0000 0000
Advanced Conditional Jump: Digital InputTZ / 0x0B
Jump based on digital input signals on DI0-DI3 pins.
000 25 0000 000F
001 0B FF0D 0010
002 0E 0000 0000
003 00 0000 0000
010 01 00FF 00F0
011 0F 0000 0000
Call: Jump to SubroutineDY / 0x0C
Call a subroutine at the specified line. Use 0x0D to return.
000 00 0000 0000
001 0C 0010 0000
002 0F 0000 0000
003 00 0000 0000
004 00 0000 0000
010 01 00FF 00FF
011 0C 0020 0000
012 0D 0000 0000
020 02 0001 0001
021 01 00FF 0000
022 0D 0000 0000
Unconditional JumpZY / 0x0E
Jump to the specified line without any condition.
000 25 0000 000F
001 0B FF0D 0010
002 0E 0000 0001
003 00 0000 0000
010 01 00FF 00F0
011 0F 0000 0000
Write Value to RegisterFZ / 0x10
Modify the value in the specified register.
000 10 001C 03E8
001 00 0000 0000
002 13 001C 0000
003 0F 0000 0000
Register CopyRFZ / 0x11
Copy value of one register to another.
000 10 001C 03E8
001 11 001D 001C
002 13 001D 0000
003 0F 0000 0000
Increment/Decrement RegisterZJ / 0x12
Increment or decrement register value, with optional overflow control.
000 10 001C FF00
001 12 001C 03E8
002 13 001C 0000
003 02 0005 0001
004 12 011C 03E8
005 13 001C 0000
006 0F 0000 0000
Register Value to Digital OutputSS / 0x13
Use the least 8 bits of a register as digital output value.
000 10 001C 03E8
001 11 001D 001C
002 13 001D 0000
003 0F 0000 0000
Digital Input Value to RegisterQS / 0x14
Capture digital input values and save to a register.
000 10 0025 00FF
001 14 001C 0000
002 00 0000 0000
003 0E 0000 0001
Bit ShiftXHYW / 0x15
Shift bits in a register left or right, with optional circular mode.
000 10 0001 0001
001 13 0001 0000
002 02 0001 0001
003 15 1101 0001
004 0E 0000 0001
Bitwise XORWYH / 0x19
Bitwise XOR of two registers, result stored in first register.
000 10 0025 000F
001 10 0007 8009
002 10 0009 FF00
003 0B FF0E 0010
004 0B FF0D 0020
005 0B FF0B 0030
006 0B FF07 0040
007 0E 0000 0000
010 16 0007 0000
011 0E 0000 0000
020 17 0007 0009
021 0E 0000 0000
030 18 0007 0009
031 0E 0000 0000
040 19 0007 0009
041 0E 0000 0000
DivisionRCHU / 0x1D
Divide two registers, result stored in first register.
000 10 0025 000F
001 10 0006 0020
002 10 0008 1234
003 0B FF0E 0010
004 0B FF0D 0020
005 0B FF0B 0030
006 0B FF07 0040
007 0E 0000 0000
010 1A 0008 0006
011 0E 0000 0000
020 1B 0008 0006
021 0E 0000 0000
030 1C 0008 0006
031 0E 0000 0000
040 1D 0008 0006
041 0E 0000 0000
ModuloRQY / 0x1E
Calculate remainder of two registers, result stored in first register.
000 10 0006 0020
001 10 0008 1234
002 02 0001 0001
003 1E 0008 0006
004 0F 0000 0000
Random NumberSJS / 0x1F
Generate a random number and store it in the specified register.
000 1F 0005 0000
001 02 0001 0001
002 0E 0000 0000
Byte SwapGDJH / 0x21
Swap higher and lower bytes of a register.
000 10 0025 000F
001 10 0005 2450
002 10 0006 FF00
003 0B FF0E 0010
004 0B FF0D 0020
005 0E 0000 0000
010 20 0005 0006
011 02 0001 0001
012 0E 0000 0000
020 21 0005 0000
021 02 0001 0001
022 0E 0000 0000
Division with LiteralCHU / 0x2D
Divide a register by a literal value, result stored in register.
000 10 0025 000F
001 10 0008 1234
002 0B FF0E 0010
003 0B FF0D 0020
004 0B FF0B 0030
005 0B FF07 0040
006 0E 0000 0000
010 2A 0008 0020
011 0E 0000 0000
020 2B 0008 0020
021 0E 0000 0000
030 2C 0008 0020
031 0E 0000 0000
040 2D 0008 0020
041 0E 0000 0000
Modulo with LiteralQY / 0x2E
Calculate remainder of a register divided by a literal value, result stored in register.
000 00 0000 0000
001 10 0008 1234
002 02 0001 0001
003 2E 0008 0020
004 0F 0000 0000
Convert Register to BCD CodeBMQD / 0x30
Convert the lower 8 bits of a register value to seven-segment display BCD code.
000 C5 0001 0000
001 C6 0001 0000
002 30 3E00 0000
003 EA 0000 0190
004 16 0000 0000
005 EA 0000 00C8
006 0E 0000 0002
Advanced Register OperationsTJYS / 0x32
Perform various operations on register pairs.
000 10 0001 73E8
001 10 0002 1024
002 10 0003 0000
003 32 0300 0102
004 32 0301 0102
005 32 0302 0102
006 32 0303 0102
007 32 0304 0102
008 32 0305 0102
009 32 0306 0102
00A 32 0307 0102
00B 32 0008 0102
00C 32 030B 0102
00D 32 000C 0100
00E 32 030D 0102
00F 0F 0000 0000
Formatted Text OutputSC / 0x55
Output values in a specified format to the screen at designated location.
000 C3 0001 0000
001 11 0001 002E
002 10 0028 FFFF
003 55 0000 0122
004 02 03E8 0000
005 10 0028 0210
006 5A 0000 FFFF
007 0E 0000 0000
Display StringWZ / 0x56
Display characters from consecutive registers in specified format.
000 C3 0001 0000
001 10 0004 5465
002 10 0005 6D70
003 10 0006 6572
004 10 0007 6174
005 10 0008 7572
006 10 0009 653A
007 10 0028 FFFF
008 56 2020 040C
009 02 03E8 0000
00A 10 0028 0210
00B 5A 0000 FFFF
00C 0E 0000 0000
Draw LineHX / 0x5B
Draw a straight line between two specified points.
000 10 0028 001F
001 57 2020 2000
002 10 0028 07E0
003 58 7070 1000
004 10 0028 F100
005 59 3030 5580
006 10 0028 07FF
007 5A 1010 2020
008 10 0028 FFFF
009 5B 6060 2020
00A 0E 0000 0000
Drawing Shapes (Comprehensive)AD / 0xAD
Comprehensive drawing program demonstrating various shapes.
000 10 0028 001F
001 57 2020 2000
002 10 0028 07E0
003 58 7070 1000
004 10 0028 F100
005 59 3030 5580
006 10 0028 07FF
007 5A 1010 2020
008 10 0028 FFFF
009 5B 6060 2020
00A 0E 0000 0000
Activation Switches: Peripheral ModulesMKPZ / 0xC0
Enable/Disable peripherals in bitwise mode.
000 C0 0000 085F
001 0F 0000 0000
Activation Switch: ADC Module / 0xC1
Enable or disable analog-to-digital conversion.
000 C1 0001 0000
001 AD 0001 0005
002 01 00FF 0000
003 02 0005 FF00
004 01 00FF 0000
005 02 0005 FF00
006 0E 0000 0001
Activation Switch: Temperature and Humidity Sensor / 0xC3
Enable temperature and humidity sensor and display readings.
000 C3 0001 0000
001 11 0001 002E
002 10 0028 FFFF
003 55 0000 0122
004 10 0028 0210
005 5A 0000 FFFF
006 0E 0000 0000
Activation Switch: Colour Sensor / 0xC4
Enable colour detection sensor and read RGB values.
000 C4 0001 0000
001 E5 3101 0001
002 0E 0000 0001
Activation Switch: External PWM Generator / 0xC5
Enable external PWM generator and control PWM channels.
000 C5 0001 0000
001 C1 0001 0000
002 10 0000 0003
003 10 0001 0019
004 AD 0000 0002
005 1D 0002 0001
006 12 0002 00C8
007 00 0000 0000
008 EA 0000 0002
009 0E 0000 0002
Activation Switch: RTC Clock Module / 0xC6
Enable DS1307 RTC clock module and display time.
000 C6 0001 0000
001 13 003E 0000
002 0E 0000 0001
Set Onboard PWM Channel Duty Cycle / 0xC8
Enable built-in PWM and set duty cycle.
000 C0 0000 0000
001 C8 0001 03E8
002 0E 0000 0001
Set Colour of an LEDCD / 0xE4
Set colour of one WS2812B LED with RGB values.
000 E4 00FF 8000
001 02 0001 0001
002 E4 00FF 0000
003 02 0001 0001
004 E4 0000 FF00
005 02 0001 0001
006 E4 0000 00FF
007 0F 0000 0000
Read Colour SensorRCD / 0xE5
Read RGB values from colour sensor.
000 C4 0001 0000
001 E5 3101 0001
002 0E 0000 0001
Play a ToneFY / 0xE8
Play a tone from preset three octaves.
000 C0 0000 0800
001 E8 000F 0001
002 E8 0000 0001
003 E8 000F 0001
004 E8 0011 0001
005 E8 0013 0001
006 0F 0000 0000
PCA9685 Register Channel and Value / 0xEA
Write value to selected PCA9685 PWM channel.
000 C5 0001 0000
001 C1 0001 0000
002 10 0000 0003
003 10 0001 0019
004 AD 0000 0002
005 1D 0002 0001
006 12 0002 00C8
007 00 0000 0000
008 EA 0000 0002
009 0E 0000 0002