gmplOpcodesStatement

Opcodes Statement Summary

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:

Substatement Description
Opcode This substatement defines an individual operation code in the intermediate language.


Opcode Substatement Summary

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:

Attribute Description
Id This attribute is the identifier of an operation code, It must be 3-characters and it must be unique.
Opc This 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.
Type This is an enumerated entry from the opcTypes enumeration which describes the type of the operation code.
Role This is an enumerated entry from the opcRoles enumeration which describes the general role the operation performs in the intermediate language.
Subcodes This 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:

Entry Description
Arithmetic The 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.
SingleByte The single byte operators have simple generic roles within the intermediate language like introducing a new code sequence or marking the end of some sequence.
DoubleByte The 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.
ShortValue The short value operator emission is followed by a two-byte integer value used to specify a simple integer constant or number.
SymbolAddr The 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.
StringAddr The 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.
OpcodeAddr The opcode address operators are followed by a four-byte integer value that marks the offset of the start of an intermediate language code sequence.
BinaryType The 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.
LibraryAdr The 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.
LibPattern The library pattern operators are followed by the offset of a surface pattern description either in the current storage area or in language storage.
ObjectType The 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:

Entry Description
NewLev There are many nested sequences of operators. This role starts a new nesting level.
EndLev There are many nested sequences of operators. This role ends a nesting level.
LoadSym This role loads a source code symbol.
LoadLib This role loads a library symbol.
LoadInt This role loads a short integer value.
LoadStr This role loads a character string.
LoadLng This role loads a string representation of a long integer constant.
LoadDbl This role loads a string representation of a real constant.
LoadLog This role loads a binary representation of a logical (boolean) constant.
LoadDat This role loads a string representation of a date constant.
LoadSpv This role loads a subcode that defines some source language particular special value like Me.
LoadTyp This role loads an enumeration entry value.
Unary This role defines a unary operator.
Binary This role defines a non-relational binary operator.
Relate This role defines a relational binary operator.
Member This role asserts the membership of a code sequence in the preceding code sequence.
Clsref This role asserts that the subcode refers to a class component
Convert This role performs a type-conversion of some sort.
Comment This role introduces a non-executable comment.

The substatements of the Opcode statement are as follows:

Substatement Description
Subcode This substatement specifies a suboperation of the operation code.

The attributes of the subcode statement are as follows:

Attribute Description
Id This 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.
Value This 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.


Table of Contents