Skip to content

Important Notice:

This is a Working Draft of the DATEX Specification. This is document is work in progress and may change at any time. It is not intended to be used for production purposes.

6 Binary Instruction Codes

The following section contains a list of all DXB binary instruction codes.

6.1 Remarks

Instruction codes have a size of 1 byte. The codes from 0x60 to 0x9f are reserved for later use.

Number types:

  • Uint8: Unsigned Integer, 8 Bits = 1 Byte
  • Uint32: Unsigned Integer, 32 Bits = 4 Bytes
  • Int8: Signed Integer, 8 Bits = 1 Byte, -2_147_483_648 to 2_147_483_647
  • Int16: Signed Integer, 16 Bits = 2 Bytes, -2_147_483_648 to 2_147_483_647
  • Int32: Signed Integer, 32 Bits = 4 Bytes, -2_147_483_648 to 2_147_483_647
  • Int64: Signed Integer, 64 Bits = 8 Bytes, -9223372036854775808 to 9223372036854775807
  • Float64: IEEE 754, Double-precision floating-point format, 64 Bits = 8 Bytes, 2.2e-308 to 1.7e+308

DATEX uses the little endian format for all numbers.

6.2 Stand-alone codes

NameHex CodeDX equivalentDescription
CLOSE_AND_STOREa0;Close current statement and store result in the #scope_result variable. A DATEX Script must always end with CLOSE_AND_STORE.
SUBSCOPE_STARTa1(Subscope starts, executed independently from parent scope
SUBSCOPE_ENDa2)Subscope closed, #scope_result passed on to parent
END00endThe scope execution is immediately stopped. The #scope_result is returned as normal
RETURNa4returnReturns the current #scope_result, scope continues afterwards

6.3 Runtime Commands

Runtime commands can be standalone commands or commands with parameters. A command is normally expected to be followed by a specfic amount of values (parameters). Runtime commands are equivalent to operators (e.g. comparators) in DXB, but are viewed as a seperate group because they correspond to a string in DATEX Script (semantics similar to applying a value to a function).
Other operators always have a shorthand symbol in DATEX Script (e.g. !, ==).

NameHex CodeStructureExpected ParametersReturn value typeDX equivalentDescription
JMPa5[INDEX]: Uint32-<Void>jmp 42Changes scope index to 'INDEX' and continues execution from there
JTRa6[INDEX]: Uint32<boolean><Void>jtr 42 ev1Jumps if the parameter value is true-ish
JFA66[INDEX]: Uint32<boolean><Void>jfa 42 ev1Jumps if the parameter value is false-ish
COUNTadstandaloneany<integer>count ev1Counts the number of elements of the ev
ABOUTaestandaloneany<Markdown>about ev1Returns a <Markdown> value describing the value
GET_TYPEf5standaloneany<Type>type ev1Returns the <Type> of a value
RESOLVE_URL52standalone<text><Url>url "https://..."Converts the string to a <Url>. The url is resolved to its content
TEMPLATE53standalone<Type> <Object><Void>template <Type> {}Defines the template for a type
EXTENDS54standaloneany<boolean>av extends yReturns true if the current active value (av) extends y
IMPLEMENTS55standalone<Type><boolean>av implements <Type>Returns true if the current active value (av) extends the template of the type
DELETE_POINTERbastandaloneany (pointer)<Void>delete pointerPermanently deletes the pointer on the current endpoint
SUBSCRIBEbbstandaloneany (pointer)anysubscribe pointerGet future updates for this pointer. The current value of the pointer is returned
UNSUBSCRIBEbcstandaloneany (pointer)<Void>unsubscribe pointerStop getting future updates for this pointer.
VALUEbdstandaloneany (pointer)anyvalue pointerGet the value of a pointer
ORIGINbestandaloneany (pointer)<Endpoint>origin pointerGet the origin endpoint of a pointer.
SUBSCRIBERSbfstandaloneany (pointer)<Filter>subscribers pointerGet all current subscribers for a pointer.

6.4 Operators

6.4.1 Comparators

A comparator operator compares the current active value with an effective value that follows after the comparator.

NameHex CodeDX equivalentDescription
EQUALa7av == ev1Active value is set to true if current active value is the same as ev1
NOT_EQUALa8av ~= ev1Active value is set to true if current active value is not the same as ev1
GREATERa9av > ev1Active value is set to true if current active value is greater ev1
LESSaaav < ev1Active value is set to true if current active value is less than ev1
GREATER_EQUALabav >= ev1Active value is set to true if current active value is greater or equal to ev1
LESS_EQUALacav <= ev1Active value is set to true if current active value is less or equal to ev1

6.4.2 Combinators

Combination operators combine two values and can be used as mathematical or logical operators, but can also have custom functions for different value types. For mathematical operations, Floats and Ints can be combined.

NameHex CodeDX equivalentDescription
ADDf81 + 2, 1.0 + 2, "a" + "b", [1,2] + [3,4] (whitespaces required)Adds the active value to the next value
SUBTRACTfa10 - 2 (whitespaces required)Subtracts next value from the active value
MULTIPLYfb10 * 2, 10 * 'a', (void * 4, 1, (1,2,3) * 2) (whitespaces required)Multiplies the active value with the next value
DIVIDEfb22.22 / 2Divides the active value from the next value
ANDeatrue & b, @user1 & #allowedLogical AND
ORebfalse | b, @user1 | @user2Logical OR
RANGEfda..bAccepts only <integer> values, returns <Tuple> with ascending integers starting with a and excluding b

6.4.3 Other operators

NameHex CodeDX equivalentDescription
STREAMedx << 'streamed data' 'more data'Accepts an arbitrary number of immediately followed <text>, <Buffer>, and <Stream> values. x must be a <StreamSink>

6.5 Shortcuts for Standard Library types

The <Type> values for all standard library types are represented with a single byte:

NameHex CodeDX equivalent
STD_TYPE_STRING10<text>
STD_TYPE_INT11<integer>
STD_TYPE_FLOAT12<decimal>
STD_TYPE_BOOLEAN13<boolean>
STD_TYPE_NULL14<Null>
STD_TYPE_VOID15<Void>
STD_TYPE_BUFFER16<Buffer>
STD_TYPE_CODE_BLOCK17<DATEX>
STD_TYPE_UNIT18<Unit>
STD_TYPE_FILTER19<Filter>
STD_TYPE_ARRAY1a<Array>
STD_TYPE_OBJECT1b<Object>
STD_TYPE_SET1c<Set>
STD_TYPE_MAP1d<Map>
STD_TYPE_TUPLE1e<Tuple>
STD_TYPE_RECORD1f<Tuple>
STD_TYPE_FUNCTION20<Function>
STD_TYPE_STREAM21<Stream>

6.6 Values

Values instructions parse a value and then insert it into the scope.

6.6.1 Standalone values

NameHex CodeDX equivalent
TRUEc4true
FALSEc5false
NULLc6null
VOIDc7void

6.6.2 Other primitive values

NameHex CodeStructureDX exampleDescription
STRINGc0
LENGTH: Uint32
VALUE: Uint8[LENGTH]
"A String"Maximum size 4.29 GB. DATEX Strings are not null-terminated, their length is stored
SHORT_STRINGce
LENGTH: Uint8
VALUE: Uint8[LENGTH]
"A Short String"Maximum size 255 bytes
INT_8c1
VALUE: Int8
127Range -128 -> 127
INT_16c2
VALUE: Int16
32767Range –32768 -> 32767
INT_32c3
VALUE: Int32
127Range –2147483648 -> 2147483647
INT_64c4
VALUE: Int64
<integer>9e18Range -9223372036854775808 -> 9223372036854775807
FLOAT_64c5
VALUE: Float64
-12.34, infinity, nanRange 2.2e-308 -> 1.7e+308
BUFFERca
LENGTH: Uint32
VALUE: Uint8[LENGTH]
`fafe334feaefe3`A raw binary data buffer, maximum size 4.29 GB

6.6.3 Array, Objects, Tuples and Records

NameHex CodeDX equivalentDescription
ARRAY_STARTe0[<Array> declaration start
ARRAY_ENDe1]<Array> declaration end
OBJECT_STARTe2{<Object> declaration start
OBJECT_ENDe3}<Object> declaration end
TUPLE_STARTe4(<Tuple> declaration start
TUPLE_ENDe5)<Tuple> declaration end

Tuple, Record, and Subscope share the same symbol in DATEX Script.

6.7 Pointers and Variables

DATEX distinguishes between normal Variables, Internal Variables for specific purposes, and Pointers/Labels for persistant values.

NameHex CodeDX equivalentDescription
VARb0myVarInserts the value of 'myVar' into the scope
SET_VARb1myVar = xSets the value of 'myVar' to 'x'
VAR_ACTIONb2myVar += x, myVar -= x, myVar &= xApplies 'x' with the operator to 'myVar' internally (The value of 'myVar' is updated, but the variable is not overwritten)