Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

download Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

of 39

Transcript of Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    1/109

     

    Firmware Developer Kit

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques de commerce

    de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    2/109

     

    Table of Contents

    1  Hardware specifications for MINDSTORMS EV3 Programmable brick .................................................................. 3 

    2  Firmware architecture used within MINDSTORMS EV3 ............ ............. ............. ............ ............. ............. ............. ............4 

    2.1 

    Kernel modules ................................................................................................................................................................................4 

    2.2  Operating system (OS) ................................................................................................................................................................4 

    2.3  Shared libraries ................................................................................................................................................................................5 

    2.4  Virtual machine ................................................................................................................................................................................5 

    3  Program structure ............ ............ ............. ............. ............. ............. ............ ............. ............. ............. ............. ............. ............ ............. .. 7 

    3.1  Image header ................................................................................................................................................................................... 7 

    3.2  Object header ...................................................................................................................................................................................8 

    3.3  Bytecodes ...........................................................................................................................................................................................8 

    3.4 

    Parameter encoding .................................................................................................................................................................... 9 

    4  Byte code definition and functionality ....................................................................................................................................... 10 

    4.1  General operations ......................................................................................................................................................................10 

    4.2  Math instructions .......................................................................................................................................................................... 21 

    4.3  Logic operations ........... ............. ............. ............. ............. ............ ............. ............. ............. ............. ............ ............. ............. ..... 28 

    4.4  Memory move operations ....................................................................................................................................................... 31 

    4.5  Program branch operations .................................................................................................................................................. 35 

    4.6  Comparison operation .............................................................................................................................................................40 

    4.7 

    Program select operations .................................................................................................................................................... 45 

    4.8  Input port operations ................................................................................................................................................................ 46 

    4.9  Output port operations ............................................................................................................................................................ 53 

    4.10  Sound operations ........... ............. ............. ............. ............. ............ ............. ............. ............. ............. ............. ............ ............. ... 59 

    4.11  Timer operations ..........................................................................................................................................................................60 

    4.13  Communication operations ............ ............. ............. ............. ............. ............. ............ ............. ............. ............. ............. ....... 61 

    4.14  Memory operations .................................................................................................................................................................... 70 

    4.15  User interface operations ....................................................................................................................................................... 83 

    Device type list ..................................................................................................................................................................................... 100 

    6  Folder structure within firmware ................................................................................................................................................ 102 

    7  Program examples ............................................................................................................................................................................. 103 

    7.1  Line follower.................................................................................................................................................................................. 103 

    7.2  Scheduling blocks .................................................................................................................................................................... 104 

    7.3  Parallel loops ............. ............ ............. ............. ............. ............. ............ ............. ............. ............. ............. ............. ............ .......... 106 

    7.4  Calling subroutines with parameters ............................................................................................................................. 107 

    7.5  String parameter passing ..................................................................................................................................................... 108

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 2 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    3/109

     

    1  Hardware specifications for MINDSTORMS EV3 Programmable brick

    LEGO MINDSTORMS EV3 programmable brick is the central processing unit within the new LEGO

    MINDSTORMS platform. The programmable brick consists of various advanced electronics to enable its

    wide range of functionalities.

    Below list is a summary of the hardware specifications for the EV3 Programmable brick.

    Main processor: 32-bit ARM9 processor, Texas Instrument AM1808

    -  300 MHz

    -  OS: LINUX

    Memory: 64 MB DDR RAM

    16 MB FLASH

    256 KB EEPROM

    Micro SD-Card interface SDHC standard, 2 – 32 GB

    Bluetooth wireless communication Bluetooth V2.1 EDR, Panasonic PAN1325 module

    -  Texas Instrument CC2550 chip

    BlueZ Bluetooth stack

    -  Primary usage, Serial Port Profile (SPP)

    USB 2.0 Communication, Client interface High speed port (480 MBit/s)

    USB 1.1 Communication, Host interface Full speed port (12 MBit/s)

    4 input ports 6 wire interface supporting both digital and analog interface

    -  Analog input 0 – 5 volt

    -  Support Auto-ID for external devices

    -  UART communication

    o  Up to 460 Kbit/s (Port 1 and 2)

    o  Up to 230 Kbit/s (Port 3 and 4)

    4 output ports 6 wire interface supporting input from motor encoders

    Display 178x128 pixel black & white dot-matrix display

    Viewing area: 29.9 x 41.1 mm

    Loudspeaker Diameter, 23 mm

    6 Buttons User interface Surrounding UI light

    Power source 6 AA batteries

    -  Alkaline batteries are recommended

    -  Rechargeable Lithium Ion battery, 2000 mAH

    Connector 6-wire industry-standard connector, RJ-12 Right side adjustment

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 3 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    4/109

     

    2  Firmware architecture used within MINDSTORMS EV3

    The firmware architecture within LEGO MINDSTORMS EV3 is build around a LINUX operating system.

    Multiple shared libraries are developed each enabling various functionality which are utilized by the

    LEGO application (Virtual machine), which again are controlled through various system programs and

    user programs (Byte-code programs).Figure 1 below provides a graphical representation of the firmware architecture from a high level

    perspective.

    Figure 1 : Graphical representation of the firmware architecture

    2.1  Kernel modules

    The kernel modules handles all initialization and control of hardware components both internal within

    the ARM9 controller and towards external hardware components. Most of these drivers will be interrupt

    driven. The kernel modules are represented as the black layer within  Figure 1. 

    2.2  Operating system (OS) 

    MINDSTORMS EV3 is build around linux platform support packages (PSP) for AM1808 ARM9 controller.

    The specific packages used DaVinci-PSP-SDK-03.20.00.13 utilizes a LINUX kernel version 2.6.33 RC4.

    The actual used operating system is compiled using “GNU + CodeSourcery_G++ lite” compilers with

    various special settings.

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 4 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    5/109

     

    2.3 

    Shared libraries

    The system will consist of multiple shared libraries which individually handle various specific

    functionalities. The shared libraries are represented as the green layer within Figure 1. 

    These shared libraries are implemented as “Asynchronous driver model” which mean that polling or

    direct signalling are needed between the shared library and virtual machine.

    The functionality implemented within the shared libraries will be accessed from the virtual machine

    through system calls from the virtual machine into the shared libraries. All system commands are

    implemented in a way that is none blocking.

    The shared libraries are implemented in C and compiled into native code to enable the optimal

    performance. New functionality can be added to the firmware through either improving existing shared

    libraries or developing new shared libraries to the system.

    Initially the firmware includes the following shared libraries:

    Shared libraries within LEGO MINDSTORMS EV3 Firmware

    Input library Handle all functionality around input portsOutput library Handle all functionality around output portsSound library Handle all functionality around playing soundsUser interface library Handle all functionality around user interfaceCommunication library Handle all communication with EV3 P-brick (USB, Bluetooth, WiFi)Memory library Handle all functionality around memory management

    2.4  Virtual machine

    The virtual machine should be thought of as the actual application running on the EV3 P-brick. Thevirtual machine handles the actual program execution and calls into the shared libraries (Functionality

    device drivers). The virtual machine is represented as the blue layer within Figure 1. 

    Program execution is done through byte-code which represents an abstraction of various functionalities

    within the shared libraries. These byte-codes will be documented in more detailed within section 4. 

    The virtual machine is implemented using a memory based architecture in order to match the output

    from the compiler most optimal.

    New functionality can be achieved through implementation of sub-routines within programs. This

    approach enables for example 3rd  party developers to implement new functionality without having to

    develop new shared libraries and build new firmware versions.All user functionality needed when the products launched is implemented within shared libraries, with

    the exception of the user interface which is launched when the LEGO MINDSTORMS EV3 P-brick starts.

    This interface is implemented using byte-codes as this enables updating the user interface without

    having to rebuild the entire firmware.

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 5 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    6/109

     

    A few main characteristic for the virtual machine:

    -  The following data-types are supported:

    o  8-bit integer

    o  16-bit integer

    32-bit integero  Float (IEEE 754 single precision – 32 bits)

    o  Strings

    o  Arrays (Implemented as shared library functionality)

    -  There is no support for polymorphism (Data types should be defined at compile time)

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 6 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    7/109

     

    3  Program structure

    This section will outline the structure required within user programs which the virtual machine is able to

    execute. Basically a program consists of the following three different components in the mentioned

    fixed order:

    Image header-  Object headers

    -  Byte-codes

    Little Endian (addresses and data are represented with LSB on lowest address and MSB on highest

    address) is expected throughout the entire program. Referencing offset to instructions is number of

    bytes from start of image to start of object instructions. Index to global variables are byte based and

    counted from start of globals (zero based) while index to local variables are byte based and counted

    from start of object locals (zero based). Object ID's is not zero based - First object (VMTHEAD) is named

    1.

    3.1 

    Image headerThe image header documents image version, filesize, no of objectheaders (objects) and no of global

    variable bytes.

    Image header

    Sign 4 bytesImage size 4 bytesVersion info 2 bytesNumber of objects 2 bytesNumber of global bytes 4 bytes

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 7 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    8/109

     

    3.2 

    Object header

    Objectheaders contains different informations depending on the nature of the object:

    • 

    The VMTHREAD object (former TBC_TOPVI)

    OffsetToInstructions tells were to find the corresponding byte codes (offset from imagestart)

    o  OwnerObjectId must be zeroo  TriggerCount is used but must be zeroo  LocalBytes describes the number of bytes for local variables

    • 

    The SUBCALL object (former TBC_VI and TBC_VI_ALIAS)o  OffsetToInstructions tells were to find the corresponding byte codes (if alias this is equal

    to mother object)o  OwnerObjectId must be zeroo  TriggerCount is used and must be oneo  LocalBytes describes the number of bytes for local variables

    •  The BLOCK object (former CLUMP)

    o  OffsetToInstructions tells were to find the corresponding byte codes (offset from imagestart)

    o  OwnerObjectId is equal to object id it belongs to (not equal to zero)o  TriggerCount is used to determine how many triggers needed before the BLOCK object

    is activatedo  LocalBytes must be zero (locals are defined in the owner object)

    Object header

    Offset to instructions 4 bytesOwner object id 2 bytes

    Trigger count 2 bytesLocal bytes 4 bytes

    3.3  Bytecodes

    The individual byte codes will be documented in details within section  0.  Below are some general

    guidelines for how the byte codes are implemented.

    • 

    Little Endian is used

    o  Addresses and data are represented with LSB on lowest address and MSB on highest

    address

    • 

    Offset to instructions is number of bytes from start of image to start of object instructions•  Index to global variables is byte based and counted from start of globals (zero based)

    •  Index to local variables is byte based and counted from start of object locals (zero based)

    •  Object ID's is not zero based - First object (VMTHEAD) is named 1

    •  FILE layout needs to be aligned

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 8 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    9/109

     

    3.4 

    Parameter encoding

    Parameter types and values for primitives, system calls and subroutine calls are encoded in the callers

    byte code stream as follows:

    opAdd8 (ParCode1, ParCode2, ParCodeN)

    Bits 70 x x x x x x x

    6 5 4 3 2 1 0

    Short format

    0

    10

    1

    Constant

    Positive valueNegative value

    Variable

    Local indexGlobal index

    Long format

    Constant

    ValueLabel

    Variable

    LocalGlobal

    ValueHandle

    Zero terminated string1 byte to follow2 bytes to follow4 bytes to followZero terminated string

    01

    V VV VVVV

    VVV

    i

    t

    ii i ii

    i i ii

    tt b b b

    0

    0

    0

    00

    0

    0

    0

    00

    0

    00

    0

    1

    1

    1

    1

    1

    1

    111

    -

    1

     For subroutine parameters additional information about number of parameters, direction and size are

    needed and placed in front of the called code.

    Parameters MUST be sorted as follows: Largest (4 Bytes) parameters is first and smallets (1 Byte) is last

    in the list.

    OffsetToInstructions => NoOfPars, ParType1, ParType2, ParTypeN

    Bits 7 6 5 4 3 2 1 0Long format

    X Parameter in

    i o - - - bb b

    1

    X1 Parameter out

    32 bitsFloat

    000 0

    00

    001

    111

    Zero terminated string (Next byte tells allocated size)0 01

    16 bits8 bits

     

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 9 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    10/109

     

    4  Byte code definition and functionality

    This section will document the individual up-codes which the virtual machine is able to execute.

    4.1  General operations

    Instruction OpError

    Opcode 0x00

    Arguments

    Dispatch status Changed to INSTRBREAK

    Description Instruction can be used to indicate error. This code is not normally used in programs.

    Instruction OpNop

    Opcode 0x01

    Arguments

    Dispatch status Unchanged

    Description Instruction will do nothing. 

    Instruction OpProgram_Stop PRGID)

    Opcode 0x02

    Arguments (Data16) Program ID slot

    Dispatch status Changed to PRGBREAK

    Description Stop specific program ID slot

    The following program ID definition can be referenced:

    0 Program slot served for executing the user interface

    1 Program slot used for executing user programs

    2 Program slot used for direct commands received from external

    3 Program slot used for direct commands coming from the user interface

    4 Program slot used for debug user interface

    -1 Current slot

    Instruction OpProgram_Start PRGID, SIZE, *IP, DEBUG)

    Opcode 0x03

    Arguments (Data16) Program ID slot

    (Data32) Size of image

    (Data32) Address of image (Value obtained from opFILE(LOAD_Image,..))

    (Data8) Debug mode

    Dispatch status UnchangedDescription This function is to be used for starting an existing user program on the EV3 P-brick.

    The debug mode parameter can take the following values:

    0 Normal mode

    1 Debug mode, Requires debugging tools to be installed and running

    2 Do not execute the program

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 10 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    11/109

     

    Instruction OpObject_Stop OBJID)

    Opcode 0x04

    Arguments (Data16) OBJID

    Dispatch status Changed to STOPBREAK

    Description This function can be used for stopping a specific object in further execution.

    Instruction opObject_Start OBJID) 

    Opcode 0x05

    Arguments (Data16) OBJID

    Dispatch status Unchanged

    Description This function can be used for starting a specific object to execute

    Instruction opObject_Trig OBJID) 

    Opcode 0x06

    Arguments (Data16) OBJID

    Dispatch status UnchangedDescription This function trigger the specific object and initaite execution if alle trigger require-

    ments are active.

    Instruction opObject_Wait OBJID) 

    Opcode 0x07

    Arguments (Data16) OBJID

    Dispatch status Status can change to BUSYBREAK if object is not finalized

    Description This function will make the specific execution wait until the specific object have

    finalized

    Instruction opReturn 

    Opcode 0x08

    Arguments

    Dispatch status Status changed to STOPBREAK

    Description This function enables returning from subroutine

    Instruction opCall OBJID, PARAMETERS) 

    Opcode 0x09

    Arguments (Data16) OBJID

    (Data8) PARAMETERS, please reference parameter encoding section 0

    Dispatch status Status changed to STOPBREAK or BUSYBREAKDescription This function can be used for calling sub-routines

    Instruction opObject_End

    Opcode 0x0A

    Arguments

    Dispatch status Status changed to STOPBREAK

    Description This function should be used in the end of object to indicated the end of the object

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 11 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    12/109

     

    Instruction opSleep 

    Opcode 0x0B

    Arguments

    Dispatch status Status changed to INSTRBREAK

    Description This function will break current VM-thread execution

    Instruction opProgram_Info CMD, PRGID, DATA) 

    Opcode 0x0C

    Arguments (Data8) CMD => Specific command parameter documented below

    Dispatch status Status changed to FAILBREAK

    Description Depending on selected command type

    MD

    OBJ_STOP = 0x00

    Arguments

    (Data16) PRGID – Program slot number

    (Data16) OBJID – Object id

    MD OBJ_START = 0x04

    Arguments

    (Data16) PRGID – Program slot number

    (Data16) OBJID – Object id

    MD GET_STATUS = 0x16

    Arguments

    (Data16) PRGID – Program slot number

    Returns

    (Data8) Data – Program status

    MD GET_ SPEED = 0x17

    Arguments

    (Data16) PRGID – Program slot number

    Returns

    (Data32) Data – Program speed [instr/S]

    MD

    GET_ PRGRESULT = 0x18

    Arguments

    (Data16) PRGID – Program slot numberReturns

    (Data8) Data – Program result [OK, BUSY, FAIL]

    Instruction opLabel NO) 

    Opcode 0x0D

    Arguments (Data8) NO – Label number

    Dispatch status Unchanged

    Description This function enables marking an address with a label

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 12 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    13/109

     

    Instruction opProbe PRGID, OBJID, OFFSET, SIZE) 

    Opcode 0x0E

    Arguments (Data16) PRGID – Program slot number

    (Data16) OBJID – Object id (Zero means globals)

    (Data32) OFFSET – Offset (Start from…)(Data32) SIZE – Size (length of dump) zero means all (max 1024)

    Dispatch status Unchanged

    Description This function enables displaying global’s or object locals on the terminal

    Instruction opDo PRGID, IMAGE) 

    Opcode 0x0F

    Arguments (Data16) PRGID – Program slot number

    (Data32) *IMAGE – Address of image

    (Data32) *GLOBAL – Address of global variables

    Displatch status Status changed to BUSYBREAK

    Description This function enables activating a small byte code snippet

    Instruction opBP0

    Opcode 0x88

    Arguments

    Dispatch status Unchanged

    Description This function enables displaying global or objects locals on terminal when debug is

    enabled. Removes itself when done.

    Instruction opBP1

    Opcode 0x89

    Arguments

    Dispatch status Unchanged

    Description This function enables displaying global or objects locals on terminal when debug is

    enabled. Removes itself when done.

    Instruction opBP2

    Opcode 0x8A

    Arguments

    Dispatch status Unchanged

    Description This function enables displaying global or objects locals on terminal when debug is

    enabled. Removes itself when done.

    Instruction opBP3

    Opcode 0x8B

    Arguments

    Dispatch status Unchanged

    Description This function enables displaying global or objects locals on terminal when debug is

    enabled. Removes itself when done.

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 13 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    14/109

     

    Instruction opPB_Set PRGID, NO, ADDRESS) 

    Opcode 0x8C

    Arguments (Data16) PRGID – Program slot number

    (Data8) NO – Breakpoint number [0-3]

    (Data32) ADDRESS – Address (Offset from start of image) (0 = Remove breakpoint)Dispatch status Unchanged

    Description This function enables setting a breakpoint within byte code program

    Instruction opRandom MIN, MAX, VALUE) 

    Opcode 0x8E

    Arguments (Data16) MIN – Minimum value

    (Data16) MAX – Maximum value

    Returns

    (Data16) VALUE – Random value within the min and max range

    Dispatch status Unchanged

    Description This function enables getting a random value within the specified range

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 14 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    15/109

     

    Instruction opInfo CMD, …) 

    Opcode 0x7C

    Arguments (Data8) CMD => Specific command parameter documented below

    Dispatch status Unchanged

    Description Information on functions entry

    MD SET_ERROR = 0x01

    Arguments

    (Data8) NUMBER – Error number

    MD GET_ERROR = 0x02

    Arguments

    (Data8) NUMBER – Error number

    MD

    ERRORTEXT = 0x03

    Arguments(Data8) NUMBER – Error number

    (Data8) LENGTH – Maximum length of string returned (-1 = No check)

    Returns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Convert error number to text string

    MD

    GET_VOLUME = 0x04

    Returns

    (Data8) VALUE – Volume [0-100%]

    MD SET_VOLUME = 0x05

    Arguments

    (Data8) VALUE – Volume [0-100%]

    MD GET_MINUTES = 0x06

    Returns

    (Data8) VALUE – Minutes to sleep [0-120 min]

    MD SET_MINUTES = 0x07

    Arguments(Data8) VALUE – Minutes to sleep [0-120 min]

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 15 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    16/109

     

    Instruction opString CMD, …) 

    Opcode 0x7D

    Arguments (Data8) CMD => Specific command parameter documented below

    Dispatch status Unchanged

    Description String function entry

    MD GET_SIZE = 0x01

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    Returns

    (Data16) SIZE – Size of string

    Description

    Get size of string, not including zero termination

    MD

    ADD = 0x02

    Arguments(Data8) SOURCE1 – String variable or handle to string

    (Data8) SOURCE2 – String variable or handle to string

    Returns

    (Data8) DESTINATION – String variable or handle to string

    MD

    COMPARE = 0x03

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    (Data8) SOURCE2 – String variable or handle to string

    Returns

    (Data8) RESULT – Result (0 = Not equal, 1 = equal)

    MD DUPLICATE = 0x05

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    Returns

    (Data8) DESTINATION – String variable or handle to string

    MD

    VALUE_TO_STRING = 0x06

    Arguments

    (DataF) VALUE – Value which are to be converted(Data8) FIGURES – Total number of figures inclusive decimal point

    (Data8) DECIMALS – Number og decimals

    Returns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Convert floating point value to a string

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 16 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    17/109

     

    MD

    STRING_TO_VALUE = 0x07

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    Returns

    (DataF) Value – Floating point valueDescription

    Convert string to floating point value

    MD STRIP = 0x08

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    Returns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Strip a string for spaces

    MD

    NUMBER_TO_STRING = 0x09

    Arguments

    (Data16) VALUE – Value which are to be converted

    (Data8) FIGURES – Total number of figures inclusive decimal point

    Returns

    (Data8) DESTINATION – String variable or handle to string

    MD

    SUB = 0x0A

    Arguments

    (Data8) SOURCE1 – String variable or handle to string

    (Data8) SOURCE2 – String variable or handle to string

    Returns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Returns a substring from source 1 that starts were source 2 ends

    MD

    VALUE_FORMATTED = 0x0B

    Arguments

    (DataF) VALUE – Value which are to be converted

    (Data8) FORMAT – Format string variable or handle to string

    (Data8) SIZE – Total size of destination stringReturns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Convert floating point value to formatted string

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 17 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    18/109

     

    MD

    NUMBER_FORMATTED = 0x0C

    Arguments

    (Data32) NUMBER – Value which are to be converted

    (Data8) FORMAT – Format string variable or handle to string

    (Data8) SIZE – Total size of destination stringReturns

    (Data8) DESTINATION – String variable or handle to string

    Description

    Convert integer value to formatted string

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 18 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    19/109

     

    Instruction opMemory_Write PRGID, OBJID, OFFSET, SIZE, ARRAY) 

    Opcode 0x7E

    Arguments (Data16) PRGID – Program slot number

    (Data16) OBJID – Object id (Zero means globals)

    (Data32) OFFSET – Offset (Start from…)(Data32) SIZE – Length of array to write

    (Data8) ARRAY – First element of data8 array to write

    Dispatch status Unchanged

    Description This function enables writting directly into program memory

    Instruction opMemory_Read PRGID, OBJID, OFFSET, SIZE, ARRAY) 

    Opcode 0x7F

    Arguments (Data16) PRGID – Program slot number

    (Data16) OBJID – Object id (Zero means globals)

    (Data32) OFFSET – Offset (Start from…)

    (Data32) SIZE – Length of array to readReturns

    (Data8) ARRAY – First element of data8 array to receive

    Dispatch status Unchanged

    Description This function enables writting directly into program memory

    Instruction opPort_Cnv_Output PortIn, Layer, Bitfield, Inverted) 

    Opcode 0x61

    Arguments (Data32) PortIn – Encoded port number

    Returns (Data8) Layer – Value indicating layer number

    (Data8) Bitfield – Bitfield indicating specific port(s)

    (Data8) Inverted – True if left/right motor are inverted

    Dispatch status Unchanged

    Description This function enables converter port to layer and bitfield used on output ports

    Instruction opPort_Cnv_Input PortIn, Layer, PortOut) 

    Opcode 0x61

    Arguments (Data32) PortIn – Encoded port number

    Returns (Data8) Layer – Value indicating layer number

    (Data8) PortOut – Indicated the relevant port to use (Zero adjusted)

    Dispatch status Unchanged

    Description This function enables converter port to layer and bitfield used on input ports

    Instruction opNote_To_Freq NOTE, FREQ) 

    Opcode 0x63

    Arguments (Data8) NOTE – Note string (HND) (E.C. ”C#4”)

    Return (Data16) FREQ – Frequency [Hz]

    Dispatch status Unchanged

    Description This function enables converting note to a tone

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 19 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    20/109

     

    Instruction opSystem COMMAND, STATUS) 

    Opcode 0x60

    Arguments (Data8) COMMAND – Command string (HND)

    Return (Data32) STATUS – Status of command

    Dispatch status UnchangedDescription This function enables executing a system command string (HND)

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 20 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    21/109

     

    4.2  Math instructions 

    Instruction opAdd8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x10

    Arguments (Data8) SOURCE1 – Value 1

    (Data8) SOURCE2 – Value 2Return (Data8) DESTINATION – Value = Value 1 + Value 2

    Dispatch status Unchanged

    Description This function enables adding two 8-bit values together

    Instruction opAdd16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x11

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Return (Data16) DESTINATION – Value = Value 1 + Value 2

    Dispatch status Unchanged

    Description This function enables adding two 16-bit values together

    Instruction opAdd32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x12

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Return (Data32) DESTINATION – Value = Value 1 + Value 2

    Dispatch status Unchanged

    Description This function enables adding two 32-bit values together

    Instruction opAddF SOURCE1, SOURCE2, DESTINATION) Opcode 0x13

    Arguments (DataF) SOURCE1 – Source 1 value / index

    (DataF) SOURCE2 – Source 2 value / index

    Return (DataF) DESTINATION – Value = Value 1 + Value 2

    Dispatch status Unchanged

    Description This function enables adding two floating point values together

    Instruction opSub8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x14

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / indexReturn (Data8) DESTINATION – Value = Value 1 - Value 2

    Dispatch status Unchanged

    Description This function enables subtracting one 8-bit value from another 8-bit value

    Instruction opSub16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x15

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Return (Data16) DESTINATION – Value = Value 1 - Value 2

    Dispatch status Unchanged

    Description This function enables subtracting one 16-bit value from another 16-bit value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 21 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    22/109

     

    Instruction opSub32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x16

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / indexReturn (Data32) DESTINATION – Value = Value 1 - Value 2

    Dispatch status Unchanged

    Description This function enables subtracting one 32-bit value from another 32-bit value

    Instruction opSubF SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x17

    Arguments (DataF) SOURCE1 – Source 1 value / index

    (DataF) SOURCE2 – Source 2 value / index

    Return (DataF) DESTINATION – Value = Value 1 - Value 2

    Dispatch status Unchanged

    Description This function enables subtracting one floating point value from another floating point

    value

    Instruction opMul8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x18

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Return (Data8) DESTINATION – Value = Value 1 * Value 2

    Dispatch status Unchanged

    Description This function enables multiplying two 8-bit values together

    Instruction opMul16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x19

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Return (Data16) DESTINATION – Value = Value 1 * Value 2

    Dispatch status Unchanged

    Description This function enables multiplying two 16-bit values together

    Instruction opMul32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1A

    Arguments (Data32) SOURCE1 – Source 1 value / index(Data32) SOURCE2 – Source 2 value / index

    Return (Data32) DESTINATION – Value = Value 1 * Value 2

    Dispatch status Unchanged

    Description This function enables multiplying two 32-bit values together

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 22 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    23/109

     

    Instruction opMulF SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1B

    Arguments (DataF) SOURCE1 – Source 1 value / index

    (DataF) SOURCE2 – Source 2 value / index

    Return (DataF) DESTINATION – Value = Value 1 * Value 2Dispatch status Unchanged

    Description This function enables multiplying two floating points together

    Instruction opDiv8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1C

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Return (Data8) DESTINATION – Value = Value 1 / Value 2

    Dispatch status Unchanged

    Description This function enables diving one 8 bit value with another 8 bit value

    Instruction opDiv16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1D

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Return (Data16) DESTINATION – Value = Value 1 / Value 2

    Dispatch status Unchanged

    Description This function enables diving one 16 bit value with another 16 bit value

    Instruction opDiv32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1E

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Return (Data32) DESTINATION – Value = Value 1 / Value 2

    Dispatch status Unchanged

    Description This function enables diving one 32 bit value with another 32 bit value

    Instruction opDivF SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x1F

    Arguments (DataF) SOURCE1 – Source 1 value / index

    (DataF) SOURCE2 – Source 2 value / index

    Return (DataF) DESTINATION – Value = Value 1 / Value 2Dispatch status Unchanged

    Description This function enables diving one floating point value with another floating point value

    Instruction opMath CMD, …) 

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 23 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    24/109

     

    Opcode 0x8D

    Arguments (Data8) CMD => Specific command parameter documented below

    Dispatch status Unchanged

    Description Math function entry

    MD

    EXP = 0x01

    Arguments

    (DataF) DATA X – Exponent value

    Returns

    (DataF) RESULT – Calculated value

    Description

    eX, Result = expf(X)

    MD MOD = 0x02

    Arguments

    (DataF) DATA X – Division numerator(DataF) DATA Y – Division denominator

    Returns

    (DataF) RESULT – String variable or handle to string

    Description

    Modulo, Result = fmod(x,y)

    MD

    FLOOR = 0x03

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Largest real number not greater than X

    Description

    Result = floor(x)

    MD CEIL = 0x04

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Smallest real number not less than X

    DescriptionResult = ceil(x)

    MD

    ROUND = 0x05

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Rounded real value

    Description

    Result = round(x)

    MD ABS = 0x06

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 24 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    25/109

     

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Absolute value

    DescriptionResult = fabs(x)

    MD

    NEGATE = 0x07

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Input value negated

    Description

    Result = 0.0 - x

    MD SQRT = 0x08Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Square root of input value

    Description

    Square root, Result = sqrt(x)

    MD

    LOG = 0x09

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – 10 logarithm of input value

    Description

    Result = log10(x)

    MD Ln = 0x0A

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Logarithm of input value

    DescriptionResult = log(x)

    MD SIN = 0x0B

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return sinus geometry value

    MD COS = 0x0C

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 25 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    26/109

     

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return cosine geometry value

    MD

    TAN = 0x0D

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return tangent geometry value

    MD ASIN = 0x0E

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return arc sinus geometry value

    MD ACOS = 0x0F

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return arc cosine geometry value

    MD

    ATAN = 0x10

    Arguments

    (DataF) DATA X – Floating point input number

    Returns

    (DataF) RESULT – Return arc tangent geometry value

    MD MOD8 = 0x11

    Arguments

    (Data8) DATA X – Division numerator

    (Data8) DATA Y – Division denominator

    Returns

    (Data8) RESULT – Result of modulo operation

    Description

    Modulo Data8, fmod(x,y)

    MD MOD16 = 0x12

    Arguments

    (Data16) DATA X – Division numerator

    (Data16) DATA Y – Division denominator

    Returns

    (Data16) RESULT – Result of modulo operation

    Description

    Modulo Data16, fmod(x,y)

    CMD: MOD32 = 0x13

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 26 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    27/109

     

    Arguments

    (Data32) DATA X – Division numerator

    (Data32) DATA Y – Division denominator

    Returns

    (Data32) RESULT – Result of modulo operationDescription

    Modulo Data32, fmod(x,y)

    MD POW = 0x14

    Arguments

    (DataF) DATA X – Value which is lifted to the power of Y

    (DataF) DATA Y – Power numerator

    Returns

    (DataF) RESULT – Result of power operation

    Description

    Exponent, R = powf(x,y)

    MD TRUNC = 0x15

    Arguments

    (DataF) DATA X – Value which are to be truncated

    (Data8) DATA P – Precision [0-9]

    Returns

    (DataF) RESULT – Truncated value

    Description

    Truncate, R = (float)((int)(x*pow(y)))/ pow(Y)

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 27 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    28/109

     

    4.3 

    Logic operations

    Instruction opOr8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x20

    Arguments (Data8) SOURCE1 – Source 1 value / index(Data8) SOURCE2 – Source 2 value / index

    Result (Data8) DESTINATION – Result value = Value 1 | Value 2

    Dispatch status Unchanged

    Description This function enables a program to or two 8 bit values together

    Instruction opOr16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x21

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Result (Data16) DESTINATION – Result value = Value 1 | Value 2

    Dispatch status Unchanged

    Description This function enables a program to or two 16 bit values together

    Instruction opOr32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x22

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Result (Data32) DESTINATION – Result value = Value 1 | Value 2

    Dispatch status Unchanged

    Description This function enables a program to or two 32 bit values together

    Instruction opAnd8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x24

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Result (Data8) DESTINATION – Result value = Value 1 & Value 2

    Dispatch status Unchanged

    Description This function enables a program to and two 8 bit values together

    Instruction opAnd16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x25

    Arguments (Data16) SOURCE1 – Source 1 value / index(Data16) SOURCE2 – Source 2 value / index

    Result (Data16) DESTINATION – Result value = Value 1 & Value 2

    Dispatch status Unchanged

    Description This function enables a program to and two 16 bit values together

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 28 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    29/109

     

    Instruction opAnd32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x26

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Result (Data32) DESTINATION – Result value = Value 1 & Value 2Dispatch status Unchanged

    Description This function enables a program to and two 32 bit values together

    Instruction opXor8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x28

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Result (Data8) DESTINATION – Result value = Value 1 ^ Value 2

    Dispatch status Unchanged

    Description This function enables a program to xor two 8 bit values together

    Instruction opXor16 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x29

    Arguments (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Result (Data16) DESTINATION – Result value = Value 1 ^ Value 2

    Dispatch status Unchanged

    Description This function enables a program to xor two 16 bit values together

    Instruction opXor32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x2A

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Result (Data32) DESTINATION – Result value = Value 1 ^ Value 2

    Dispatch status Unchanged

    Description This function enables a program to xor two 32 bit values together

    Instruction opRl8 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x2C

    Arguments (Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Result (Data8) DESTINATION – Result value = Value 1

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    30/109

     

    Instruction opRl32 SOURCE1, SOURCE2, DESTINATION) 

    Opcode 0x2E

    Arguments (Data32) SOURCE1 – Source 1 value / index

    (Data32) SOURCE2 – Source 2 value / index

    Result (Data32) DESTINATION – Result value = Value 1

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    31/109

     

    4.4 

    Memory move operations

    Instruction opInit_Bytes DESTINATION, LENGTH, SOURCE) 

    Opcode 0x2F

    Arguments (Data32) LENGTH – Number of elements to initiate(Data8) SOURCE – First element to initiate data8 array with

    Return (Data8) DESTINATION – First element in data8 array to be initiated

    Dispatch status Unchanged

    Description This function enables moving a number of data8 from BYTE STREAM to memory

    DESTINATION START.

    Instruction opMove8_8 SOURCE, DESTINATION) 

    Opcode 0x30

    Arguments (Data8) SOURCE – Source value / index

    Return (Data8) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from 8 bit source to 8 bit destination

    Instruction opMove8_16 SOURCE, DESTINATION) 

    Opcode 0x31

    Arguments (Data8) SOURCE – Source value / index

    Return (Data16) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from 8 bit source to 16 bit destination

    Instruction opMove8_32 SOURCE, DESTINATION) Opcode 0x32

    Arguments (Data8) SOURCE – Source value / index 

    Return (Data32) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from 8 bit source to 32 bit destination

    Instruction opMove8_F SOURCE, DESTINATION) 

    Opcode 0x33

    Arguments (Data8) Source – Source value / index 

    Return (DataF) DESTINATION – Destination value / index

    Dispatch status UnchangedDescription Move value from 8 bit source to floating point destination

    Instruction opMove16_8 SOURCE, DESTINATION) 

    Opcode 0x34

    Arguments (Data16) SOURCE – Source value / index

    Return (Data8) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from 16 bit source to 8 bit destination

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 31 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    32/109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    33/109

     

    Instruction opMoveF_8 SOURCE, DESTINATION) 

    Opcode 0x3C

    Arguments (DataF) SOURCE – Source value / index

    Return (Data8) DESTINATION – Destination value / index

    Dispatch status UnchangedDescription Move value from floating point source to 8 bit destination

    Instruction opMoveF_16 SOURCE, DESTINATION) 

    Opcode 0x3D

    Arguments (DataF) SOURCE – Source value / index

    Return (Data16) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from floating point source to 16 bit destination

    Instruction opMoveF_32 SOURCE, DESTINATION) 

    Opcode 0x3EArguments (DataF) SOURCE – Source value / index

    Return (Data32) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from floating point source to 32 bit destination

    Instruction opMoveF_F SOURCE, DESTINATION) 

    Opcode 0x3F

    Arguments (DataF) SOURCE – Source value / index

    Return (DataF) DESTINATION – Destination value / index

    Dispatch status Unchanged

    Description Move value from floating point source to floating point destination

    Instruction opRead8 SOURCE, INDEX, DESTINATION) 

    Opcode 0xC8

    Arguments (Data8) SOURCE – First value in array of values

    (Data8) INDEX – Index into array which are to be read

    Return (Data8) DESTINATION – Destination value / index to receive read data

    Dispatch status Unchanged

    Description Read 8 bit value from source array and store within destination

    Instruction opRead16 SOURCE, INDEX, DESTINATION) 

    Opcode 0xC9

    Arguments (Data16) SOURCE – First value in array of values

    (Data8) INDEX – Index into array which are to be read

    Return (Data16) DESTINATION – Destination value / index to receive read data

    Dispatch status Unchanged

    Description Read 16 bit value from source array and store within destination

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 33 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    34/109

     

    Instruction opRead32 SOURCE, INDEX, DESTINATION) 

    Opcode 0xCA

    Arguments (Data32) SOURCE – First value in array of values

    (Data8) INDEX – Index into array which are to be read

    Return (Data32) DESTINATION – Destination value / index to receive read dataDispatch status Unchanged

    Description Read 32 bit value from source array and store within destination

    Instruction opReadF SOURCE, INDEX, DESTINATION) 

    Opcode 0xCB

    Arguments (DataF) SOURCE – First value in array of values

    (Data8) INDEX – Index into array which are to be read

    Return (DataF) DESTINATION – Destination value / index to receive read data

    Dispatch status Unchanged

    Description Read floating point value from source array and store within destination

    Instruction opWrite8 SOURCE, INDEX, DESTINATION) 

    Opcode 0xCC

    Arguments (Data8) SOURCE – Variable to write

    (Data8) INDEX – Index into array were data are to be written

    (Data8) DESTINATION – Array to receive data

    Dispatch status Unchanged

    Description Write 8 bit value from source into destination array and index

    Instruction opWrite16 SOURCE, INDEX, DESTINATION) 

    Opcode 0xCD

    Arguments (Data16) SOURCE – Variable to write(Data8) INDEX – Index into array were data are to be written

    (Data16) DESTINATION – Array to receive data

    Dispatch status Unchanged

    Description Write 16 bit value from source into destination array and index

    Instruction opWrite32 SOURCE, INDEX, DESTINATION) 

    Opcode 0xCE

    Arguments (Data32) SOURCE – Variable to write

    (Data8) INDEX – Index into array were data are to be written

    (Data32) DESTINATION – Array to receive data

    Dispatch status UnchangedDescription Write 32 bit value from source into destination array and index

    Instruction opWriteF SOURCE, INDEX, DESTINATION) 

    Opcode 0xCF

    Arguments (DataF) SOURCE – Variable to write

    (Data8) INDEX – Index into array were data are to be written

    (DataF) DESTINATION – Array to receive data

    Dispatch status Unchanged

    Description Write floating point value from source into destination array and index

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 34 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    35/109

     

    4.5 

    Program branch operations

    Instruction opJr OFFSET) 

    Opcode 0x40

    Arguments (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch unconditionally relative to current position

    Instruction opJr_False FLAG, OFFSET) 

    Opcode 0x41

    Arguments (Data8) FLAG

    (Data32) OFFSET – Number of bytes to branch

    Dispatch status Unchanged

    Description Program branch relative given that flag is FALSE (Zero)

    Instruction opJr_True OFFSET) 

    Opcode 0x42

    Arguments (Data32) OFFSET – Number of bytes to branch

    Dispatch status Unchanged

    Description Program branch relative given that flag is TRUE (None zero)

    Instruction opJr_Nan VALUE, OFFSET) 

    Opcode 0x43

    Arguments (DataF) VALUE

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status UnchangedDescription Program branch relative if value is NAN (Not a number)

    Instruction opJr_Lt8 LEFT, RIGHT, OFFSET) 

    Opcode 0x64

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than RIGHT value

    Instruction opJr_Lt16 LEFT, RIGHT, OFFSET) Opcode 0x65

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than RIGHT value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 35 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    36/109

     

    Instruction opJr_Lt32 LEFT, RIGHT, OFFSET) 

    Opcode 0x66

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than RIGHT value

    Instruction opJr_LtF LEFT, RIGHT, OFFSET) 

    Opcode 0x67

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than RIGHT value

    Instruction opJr_Gt8 LEFT, RIGHT, OFFSET) 

    Opcode 0x68

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than RIGHT value

    Instruction opJr_Gt16 LEFT, RIGHT, OFFSET) 

    Opcode 0x69

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than RIGHT value

    Instruction opJr_Gt32 LEFT, RIGHT, OFFSET) 

    Opcode 0x6A

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than RIGHT value

    Instruction opJr_GtF LEFT, RIGHT, OFFSET) 

    Opcode 0x6B

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than RIGHT value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 36 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    37/109

     

    Instruction opJr_Eq8 LEFT, RIGHT, OFFSET) 

    Opcode 0x6C

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic(Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is equal to RIGHT value

    Instruction opJr_Eq16 LEFT, RIGHT, OFFSET) 

    Opcode 0x6D

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is equal to RIGHT value

    Instruction opJr_Eq32 LEFT, RIGHT, OFFSET) 

    Opcode 0x6E

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is equal to RIGHT value

    Instruction opJr_EqF LEFT, RIGHT, OFFSET) 

    Opcode 0x6F

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is equal to RIGHT value

    Instruction opJr_Neq8 LEFT, RIGHT, OFFSET) 

    Opcode 0x70

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic(Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is not equal to RIGHT value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 37 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    38/109

     

    Instruction opJr_Neq16 LEFT, RIGHT, OFFSET) 

    Opcode 0x71

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is not equal to RIGHT value

    Instruction opJr_Neq32 LEFT, RIGHT, OFFSET) 

    Opcode 0x72

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is not equal to RIGHT value

    Instruction opJr_NeqF LEFT, RIGHT, OFFSET) 

    Opcode 0x73

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is not equal to RIGHT value

    Instruction opJr_Lteq8 LEFT, RIGHT, OFFSET) 

    Opcode 0x74

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than or equal to RIGHT value

    Instruction opJr_Lteq16 LEFT, RIGHT, OFFSET) 

    Opcode 0x75

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than or equal to RIGHT value

    Instruction opJr_Lteq32 LEFT, RIGHT, OFFSET) 

    Opcode 0x76

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than or equal to RIGHT value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 38 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    39/109

     

    Instruction opJr_LteqF LEFT, RIGHT, OFFSET) 

    Opcode 0x77

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is less than or equal to RIGHT value

    Instruction opJr_Gteq8 LEFT, RIGHT, OFFSET) 

    Opcode 0x78

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than or equal to RIGHT value

    Instruction opJr_Gteq16 LEFT, RIGHT, OFFSET) 

    Opcode 0x79

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than or equal to RIGHT value

    Instruction opJr_Gteq32 LEFT, RIGHT, OFFSET) 

    Opcode 0x7A

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch 

    Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than or equal to RIGHT value

    Instruction opJr_GteqF LEFT, RIGHT, OFFSET) 

    Opcode 0x7B

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    (Data32) OFFSET – Number of bytes to branch Dispatch status Unchanged

    Description Program branch relative if LEFT value is greater than or equal to RIGHT value

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 39 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    40/109

     

    4.6 

    Comparison operation

    Instruction opCp_Lt8 LEFT, RIGHT, FLAG) 

    Opcode 0x44

    Arguments (Data8) LEFT – Left value within comparison logic(Data8) RIGHT – Right value within comparison logic

    Result (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than RIGHT and set flag accordingly

    Instruction opCp_Lt16 LEFT, RIGHT, FLAG) 

    Opcode 0x45

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    Result (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than RIGHT and set flag accordingly

    Instruction opCp_Lt32 LEFT, RIGHT, FLAG) 

    Opcode 0x46

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    Result (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than RIGHT and set flag accordingly

    Instruction opCp_LtF LEFT, RIGHT, FLAG) 

    Opcode 0x47

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Result (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than RIGHT and set flag accordingly

    Instruction opCp_Gt8 LEFT, RIGHT, FLAG) 

    Opcode 0x48

    Arguments (Data8) LEFT – Left value within comparison logic(Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than RIGHT and set flag accordingly

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 40 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    41/109

     

    Instruction opCp_Gt16 LEFT, RIGHT, FLAG) 

    Opcode 0x49

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than RIGHT and set flag accordingly

    Instruction opCp_Gt32 LEFT, RIGHT, FLAG) 

    Opcode 0x4A

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than RIGHT and set flag accordingly

    Instruction opCp_GtF LEFT, RIGHT, FLAG) 

    Opcode 0x4B

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than RIGHT and set flag accordingly

    Instruction opCp_Eq8 LEFT, RIGHT, FLAG) 

    Opcode 0x4C

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is equal to RIGHT and set flag accordingly

    Instruction opCp_Eq16 LEFT, RIGHT, FLAG) 

    Opcode 0x4D

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) Dispatch status Unchanged

    Description Enables a program to identify if LEFT is equal to RIGHT and set flag accordingly

    Instruction opCp_Eq32 LEFT, RIGHT, FLAG) 

    Opcode 0x4E

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is equal to RIGHT and set flag accordingly

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 41 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    42/109

     

    Instruction opCp_EqF LEFT, RIGHT, FLAG) 

    Opcode 0x4F

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) Dispatch status Unchanged

    Description Enables a program to identify if LEFT is equal to RIGHT and set flag accordingly

    Instruction opCp_Neq8 LEFT, RIGHT, FLAG) 

    Opcode 0x50

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is not equal to RIGHT and set flag accordingly

    Instruction opCp_Neq16 LEFT, RIGHT, FLAG) 

    Opcode 0x51

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is not equal to RIGHT and set flag accordingly

    Instruction opCp_Neq32 LEFT, RIGHT, FLAG) 

    Opcode 0x52

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is not equal to RIGHT and set flag accordingly

    Instruction opCp_NeqF LEFT, RIGHT, FLAG) 

    Opcode 0x53

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) Dispatch status Unchanged

    Description Enables a program to identify if LEFT is not equal to RIGHT and set flag accordingly

    Instruction opCp_Lteq8 LEFT, RIGHT, FLAG) 

    Opcode 0x54

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than or equal to RIGHT and set flag

    accordingly

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 42 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    43/109

     

    Instruction opCp_Lteq16 LEFT, RIGHT, FLAG) 

    Opcode 0x55

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logicReturn (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than or equal to RIGHT and set flag

    accordingly

    Instruction opCp_Lteq32 LEFT, RIGHT, FLAG) 

    Opcode 0x56

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status UnchangedDescription Enables a program to identify if LEFT is less than or equal to RIGHT and set flag

    accordingly

    Instruction opCp_LteqF LEFT, RIGHT, FLAG) 

    Opcode 0x57

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is less than or equal to RIGHT and set flag

    accordingly

    Instruction opCp_Gteq8 LEFT, RIGHT, FLAG) 

    Opcode 0x58

    Arguments (Data8) LEFT – Left value within comparison logic

    (Data8) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than or equal to RIGHT and set flag

    accordingly

    Instruction opCp_Gteq16 LEFT, RIGHT, FLAG) 

    Opcode 0x59

    Arguments (Data16) LEFT – Left value within comparison logic

    (Data16) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than or equal to RIGHT and set flag

    accordingly

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 43 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    44/109

     

    Instruction opCp_Gteq32 LEFT, RIGHT, FLAG) 

    Opcode 0x5A

    Arguments (Data32) LEFT – Left value within comparison logic

    (Data32) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than or equal to RIGHT and set flag

    accordingly

    Instruction opCp_GteqF LEFT, RIGHT, FLAG) 

    Opcode 0x5B

    Arguments (DataF) LEFT – Left value within comparison logic

    (DataF) RIGHT – Right value within comparison logic

    Return (Data8) FLAG – Result of comparison (None zero if true) 

    Dispatch status Unchanged

    Description Enables a program to identify if LEFT is greater than or equal to RIGHT and set flagaccordingly

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 44 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    45/109

     

    4.7 

    Program select operations

    Instruction opSelect8 FLAG, SOURCE1, SOURCE2, *RESULT) 

    Opcode 0x5C

    Arguments (Data8) FLAG – Function as determined for operation(Data8) SOURCE1 – Source 1 value / index

    (Data8) SOURCE2 – Source 2 value / index

    Return (Data8) *RESULT – Destination for value

    Dispatch status Unchanged

    Description Enables a program to move value based on flag. If FLAG is set source 1 will be moved

    to result. If FLAG is not set, source 2 will be moved to result.

    Instruction opSelect16 FLAG, SOURCE1, SOURCE2, *RESULT) 

    Opcode 0x5D

    Arguments (Data8) FLAG – Function as determined for operation

    (Data16) SOURCE1 – Source 1 value / index

    (Data16) SOURCE2 – Source 2 value / index

    Return (Data16) *RESULT – Destination for value

    Dispatch status Unchanged

    Description Enables a program to move value based on flag. If FLAG is set source 1 will be moved

    to result. If FLAG is not set, source 2 will be moved to result.

    Instruction opSelect32 FLAG, SOURCE1, SOURCE2, *RESULT) 

    Opcode 0x5E

    Arguments (Data8) FLAG – Function as determined for operation

    (Data32) SOURCE1 – Source 1 value / index(Data32) SOURCE2 – Source 2 value / index

    Return (Data32) *RESULT – Destination for value

    Dispatch status Unchanged

    Description Enables a program to move value based on flag. If FLAG is set source 1 will be moved

    to result. If FLAG is not set, source 2 will be moved to result.

    Instruction opSelectF FLAG, SOURCE1, SOURCE2, *RESULT) 

    Opcode 0x5F

    Arguments (Data8) FLAG – Function as determined for operation

    (DataF) SOURCE1 – Source 1 value / index

    (DataF) SOURCE2 – Source 2 value / indexReturn (DataF) *RESULT – Destination for value

    Dispatch status Unchanged

    Description Enables a program to move value based on flag. If FLAG is set source 1 will be moved

    to result. If FLAG is not set, source 2 will be moved to result.

    LEGO® MINDSTORMS® EV3 Firmware Developer Kit

    LEGO, the LEGO logo and MINDSTORMS are trademarks of the/sont des marques decommerce de/son marcas registradas de LEGO Group. ©2013 The LEGO Group. 

    Page 45 of 109

  • 8/19/2019 Lego Mindstorms Ev3 Firmware Developer Kit-7be073548547d99f7df59ddfd57c0088

    46/109

     

    4.8 

    Input port operations

    Instruction opInput_Device_List LENGTH, ARRAY, CHANGED) 

    Opcode 0x98

    Arguments (Data8) LENGTH – Maximum number of devices types (Normally 32)Return (Data8) ARRAY – First element of data8 array of types (Normally 32)

    (Data8) CHANGED – Changed status

    Dispatch status Unchanged

    Description Enables a program to read all available devices on input chain

    Instruction opInput_Device CMD, …) 

    Opcode 0x99