Skip to content

gmplOpcodesStatement

Opcodes is a nonterminal, metalanguage statement that initiates the definition of the operation codes in the intermediate language. A language specification may have only one Opcodes statement which must precede any of the statements that reference the operation codes. The actual numeric values of the operation codes and their associated subcodes are defined within gmBasic and must not the changed. The actual identifiers are used in the other statements in the language definition to refer to the operation codes, and could be changed assuming that all references to them are changed as well.

The Opcodes statement has no attributes.

The substatements of the Opcodes statement are as follows:

SubstatementDescription
OpcodeThis substatement defines an individual operation code in the intermediate language.


Opcode is a nonterminal, metalanguage substatement that occurs within the Opcodes statement. This substatement defines an individual operation code in the intermediate language.

The attributes of the Opcode substatement are as follows:

AttributeDescription
IdThis attribute is the identifier of an operation code, It must be 3-characters and it
must be unique.
OpcThis attribute is the binary value, referred to as the “emission code”, to be used when
entering the operation into intermediate code storage. Each emission code must be unique
and must be a value between 0 and 250. The operations should be numbered sequentially
with as few holes in the numbering as possible.
TypeThis is an enumerated entry from the opcTypes enumeration which describes the type
of the operation code.
RoleThis is an enumerated entry from the opcRoles enumeration which describes the
general role the operation performs in the intermediate language.
SubcodesThis integer value specifies the number of suboperations associated with the operation.
A value of 0 indicates that the operation has no suboperations. The number of
suboperations must be less the 256. If suboperations are specified, the opcode
statement must be followed by that number of subcode statements.

The opcTypes enumeration has the following entries:

EntryDescription
ArithmeticThe arithmetic operators perform calculations, which may be actual arithmetic but might well
be any other type of calculation like masking or concatenation or comparison. They typically
have suboperations for the different binary types that may be involved.
SingleByteThe single byte operators have simple generic roles within the intermediate language like
introducing a new code sequence or marking the end of some sequence.
DoubleByteThe double byte operators have generic roles within the intermediate language. Their emission
consists of the operation emission code followed by the suboperation emission code. Within
other statements they are referenced as OPC.Subcode.
ShortValueThe short value operator emission is followed by a two-byte integer value used to specify a
simple integer constant or number.
SymbolAddrThe symbol address operators are followed by a four-byte integer value that specifies the root
offset in the current storage area of a symbol defined within the source code.
StringAddrThe string address operators are followed by a four-byte integer value the specifies the offset
in current storage of a character string. This string might be an actual string or it might
be a value constant of some sort.
OpcodeAddrThe opcode address operators are followed by a four-byte integer value that marks the offset of
the start of an intermediate language code sequence.
BinaryTypeThe binary type operators, not to be confused with Arithmetic binary operators, have
a suboperation code that defines a binary type. They are used extensively in the intermediate
code to specify the binary result-type of a sequence of operations.
LibraryAdrThe library address operators are followed by a four-byte integer value that specifies the root
in either current storage or language storage of an external symbol in use by the source code.
Positive roots are to current storage; while negative roots are to language storage.
LibPatternThe library pattern operators are followed by the offset of a surface pattern description either
in the current storage area or in language storage.
ObjectTypeThe object type operators have a suboperation code that specifies the type of object that the
some sequence of operations pertain to.

The opcRoles enumeration adds details to the type specification above. It has the following entries:

EntryDescription
NewLevThere are many nested sequences of operators. This role starts a new nesting level.
EndLevThere are many nested sequences of operators. This role ends a nesting level.
LoadSymThis role loads a source code symbol.
LoadLibThis role loads a library symbol.
LoadIntThis role loads a short integer value.
LoadStrThis role loads a character string.
LoadLngThis role loads a string representation of a long integer constant.
LoadDblThis role loads a string representation of a real constant.
LoadLogThis role loads a binary representation of a logical (boolean) constant.
LoadDatThis role loads a string representation of a date constant.
LoadSpvThis role loads a subcode that defines some source language particular special value like Me.
LoadTypThis role loads an enumeration entry value.
UnaryThis role defines a unary operator.
BinaryThis role defines a non-relational binary operator.
RelateThis role defines a relational binary operator.
MemberThis role asserts the membership of a code sequence in the preceding code sequence.
ClsrefThis role asserts that the subcode refers to a class component
ConvertThis role performs a type-conversion of some sort.
CommentThis role introduces a non-executable comment.

The substatements of the Opcode statement are as follows:

SubstatementDescription
SubcodeThis substatement specifies a suboperation of the operation code.

The attributes of the subcode statement are as follows:

AttributeDescription
IdThis attribute is the identifier of the suboperation. It must be unique within the parent
operation. There is no restriction on the length of suboperation identifiers.
ValueThis is the suboperation emission value. It must be unique within the parent operation.
It must between 0 and one minus the number of subcodes defined for the operation.