UCL Virtual Stack Machine and I–Code
Transcription
UCL Virtual Stack Machine and I–Code
Dok.-Nr/Doc. No.: CGS–RIBRE–STD–0003 Ausgabe/Issue: Überarbtg./Rev.: Dokument Typ: 3 – Datum/Date : Datum/Date: 2003–03–04 2005–12–01 STANDARD Document Type: Titel: UCL Virtual Stack Machine and I–Code Reference Manual Title: Lieferbedingungs–Nr.: Klassifikations Nr.: DRL/DRD No.: Classification No.: Produktgruppe: Konfigurationsteil–Nr.: Product Group: Configuration Item No.: Schlagwörter: Headings: I–Code Virtual Stack Machine Interpreter Parameter Encoding Symbol Table Debug Table Porduktklassifizierungs–Nr.: Classifying Product Code: Freigabe Ordnungs–Nr.: Release Orde No.: Vorherige Dok.–Nr.: Previous Doc. No.: Bearbeitet: Franz Kruse Prepared by: Geprüft: Stephan Marz Agreed by: Genehmigt: Org. Einh.: TE 55 Orgin. Unit: Org. Einh.: TE 55 Orgin. Unit: Jürgen Frank Org. Einh.: Unternehmen: EADS ST Bremen Company: Unternehmen: EADS ST Bremen Company: TE 55 Unternehmen: Approved by: Orgin. Unit: Genehmigt: Org. Einh.: Unternehmen: Approved by: Orgin. Unit: Company: EADS ST Bremen Company: Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: I Datum/Date : Datum/Date: von/of III DOCUMENT CHANGE RECORD ISSUE/REV. 1/– 1/A 1/B 1/C 2/– 2/A 3/– DATE Affected Paragraph/Page 2002–02–01 2002–06–03 2003–03–04 2003–03–26 5.1 2004–05–24 6 7 8 9 2004–09–01 8 2005–12–01 5.2.3, 5.2.4.16 9 DESCRIPTION OF CHANGE First version STR + VAL instructions changed for string conversion STR instruction changed: push address + sizr Version table defined (previously conversion table) Runtime errors Extended parameter encoding Symbol table + debug table Ada interface Extended/modified symbol table I–Code instructions changed: –deleted: INC_I, INC_U, DEC_I, DEC_U – separated: TRUNC_I, TRUNC_U, REAL_I, REAL_U – new: ROUND_I, ROUND_U Ada interface: package specification listings removed Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: II Datum/Date : Datum/Date: von/of III Table of Contents 1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1 Identification and Scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.2 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1 2 Applicable and reference documents . . . . . . . . . . . . . . . . . . . . . . . 2 2.1 Applicable Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.2 Reference Documents . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 3 Virtual Stack Machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 4 UCL Type Representation in Memory . . . . . . . . . . . . . . . . . . . . . . . . 6 5 I–Code definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.1 I–Code Record Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2 I–Code Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.1 Instruction Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.2 Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.3 Instruction Short Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4 I–Code Instruction Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.1 Instructions with implied parameter . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.2 Load Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.3 Load Address Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.4 Store Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.5 MOVE and CAT Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.6 Stack Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.7 Numerical Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.8 Comparison Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.9 BOOLEAN negation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.10 Allocation Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.11 Jump Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.12 Special Jump Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.13 Iterative Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.14 Switch Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.15 Procedure/Function Call Instructions . . . . . . . . . . . . . . . . . . . . 5.2.4.16 Conversion Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.17 System Instructions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.2.4.18 No–operation Instruction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.3 Sample AP and Corresponding I–Code . . . . . . . . . . . . . . . . . . . . . . . . . . 9 11 11 13 16 21 21 24 27 28 30 31 32 39 46 46 47 48 49 50 52 54 58 60 61 6 Runtime Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 7 Parameter Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 7.1 Minimal and Extended Parameter Encoding . . . . . . . . . . . . . . . . . . . . . . 7.2 Type References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3 Minimal Encoding Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 67 68 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: III Datum/Date : Datum/Date: von/of III 7.3.1 Parameter Modes and Type Classes . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.2 Value Encoding Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.2.1 External Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.3.2.2 Internal Scheme . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4 Extension Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.1 String Encoding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.2 Parameter Definition Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.4.3 Type Definition Part . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7.5 Example (call of a libr. procedure, minimal external scheme) . . . . . . 7.6 Stack Machine Representation of AP Parameters . . . . . . . . . . . . . . . . . 68 69 69 70 71 71 71 72 74 75 8 Symbol Table and Debug Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 8.1 Functional Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.2 Structure of the Symbol / Debug Table . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.3 Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.4 Table Framework . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.5 Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.6 Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.7 Type References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.8 Units of Measure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.9 Names, Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8.10 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 77 78 79 80 85 90 90 91 93 9 Ada Programming Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 1 Datum/Date : Datum/Date: von/of 95 1 Introduction 1.1 Identification and Scope This is Document No.: CGS–RIBRE–STD–0003. 1.2 Purpose This document provides the definition of the UCL Virtual Stack Machine and I–Code. It is intended both as a basis for compiler development and for the design and development of I–Code interpreters in different runtime environments. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 2 Datum/Date : Datum/Date: von/of 95 2 Applicable and reference documents 2.1 Applicable Documents The following documents form a part of this specificaiton to the extent specified here. In case of conflict this specification shall be superseding. The exact actual status of the documents listed below is to be obtained from the contractual baseline status list. 2.1.1 User Control Language (UCL) Reference Manual CGS–RIBRE–STD–0001, Issue 3/–, 2005–12–01 2.2 Reference Documents None Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 3 Datum/Date : Datum/Date: von/of 95 3 Virtual Stack Machine The Virtual Stack Machine is a non–physical machine, implemented by interpreters, with a strongly stack oriented architecture. It consists of the following components: Module Base Table A table of all modules (AP + libraries) linked together to an executable unit. Each entry points to the relative address 0 in the data frame of the corresponding module in memory. Entry 0 points to the data frame of the main program (the AP), entries 1 – n point to the data frames of user libraries. Note that system libraries have no data frame in memory. In all instructions that reference user libraries, the library number corresponds to an entry in the Module Base Table. Code Buffer A byte structured data area that contains the I–Code of the program to be executed. The main procedure and each imported (user) library have a separate frame in the Code Buffer, with the main procedure as frame 0 and the library frames numbered by the order of imports. The Module Base Table contains a pointer to each global data frame, which contains a pointer to the corresponding frame in the Code Buffer. Each frame is headed by an Entry Table whose 2–byte entries contain the relative start addresses of the procedures and functions of that frame, with the main program as procedure 0. Memory (Data Stack) The memory of the Stack Machine that stores all data processed by the machine. The memory is word structured, data contained in the memory is represented as stated in chapter 4. The memory is organized as a Data Stack holding “frames” of data. • A global data frame for the main procedure (frame 0). • A global data frame for each imported library (frames 1 .. n, numbered by the order of imports). • A procedure frame for each active procedure/function. Each procedure call pushes a procedure frame on the Data Stack, and each return from a procedure pops its frame from the stack. The Module Base Table contains a pointer to each of the global data frames. Expression Stack A word structured stack that contains operands of I–Code operations. All arithmetic is performed on the Expression Stack: operands are popped from the stack, and the result is pushed on the stack again. The expression stack is organized in 32–bit words. Values on the stack are represented as described in chapter 4. • For one–word scalar values the value itself is pushed on the stack, occupying one word. • For two–word scalar values the value itself is pushed on the stack, occupying two words. • For fixed structured values an address pointing to the start of the value in memory is pushed on the stack, occupying one word. • For open array parameters and open string parameters first an address pointing to the data in memory and then the upper bound are pushed on the stack, each occupying one word. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 4 Datum/Date : Datum/Date: von/of 95 Registers The registers contain pointers to locations in the above–mentioned data areas. They are implicitly manipulated by I–Code instructions. SP “Stack Pointer” –> Expression Stack points to the value on top of the stack. MP “Memory Pointer” –> Data Stack (Memory) points to the first free position in the Data Stack. GP “Global Data Pointer” –> Data Stack (Memory) points to the start of the current global data frame. FP “Frame pointer” –> Data Stack (Memory) points to the procedure frame of the currently executed procedure/function. CP “Code pointer” –> Code Buffer points to the start of the current code frame. PC “Program Counter” –> Code Buffer points to the I–Code instruction currently executed. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Datum/Date : Datum/Date: von/of 95 5 BASE MEMORY CODE Module 0: Main procedure Global data frame 0 Code frame 0 Module 1: library 1 Global data frame 1 Code frame 1 Module 2: library 2 Global data frame 2 Code frame 2 –3 0 Initialization flag Pointer to global data frame Entry list: CP Offsets to start of procedures –2 Pointer to code frame –1 Pointer to constant area Procedure 1 0 AP parameters (1 or 2 words per parameter) Scalar: the value Structured: the address Procedure 2 GP Global variables (1 or 2 words for each variable) Scalar: the value Structured: a pointer to the allocated data structure n Constant area (Contents addressed via pointer to constant area) PC ... Procedure n Procedure 0 (global code) Global data structures (referenced by pointers in the global data frames) Procedure frame Procedure frame –3 FP Global link (missing for local calls) –2 Dynamic link –1 Return address 0 Parameters (1 or 2 words per parameter) Scalar: value or addr. (VAR parameter) Structured: always the address Local variables (1 or 2 words for each variable) Scalar: the value Structured: a pointer to the allocated data structure Allocated data structures (referenced by pointers in the current procedure frame) n Temporarily allocated data MP LEGEND: General items are marked grey Detailed views are outlined In a row of items of the same kind, the last item is always shown in detailed view FP Stack Machine registers are shown using inverse boxes free memory Figure 3–1. Stack Machine Runtime Layout Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 6 Datum/Date : Datum/Date: von/of 95 4 UCL Type Representation in Memory All scalar types are represented as one or two 4–byte data words, resp., independently of the range of values covered by the type. Structured types are represented by a sequence of as many data words as needed to cover the complete structure. Any UCL object is allocated as a multiple of full data words, even if it occupies only part of the last data word. All values are stored in network format (i. e. big endian). Here is a description of the type classes in detail: INTEGER 1–word scalar type. Values are represented as signed numbers in 2’s complement. UNSIGNED_INTEGER 1–word scalar type. Values are represented as unsigned integers. enumeration types 1–word scalar type. Values are represented as contiguous unsigned integers in the order of their declaration, the first enumeration value starting at 0. BOOLEAN 1–word scalar type, represented as an enumeration type: FALSE = 0, TRUE = 1. COMPLETION_CODE 1–word scalar type, represented as an enumeration type: SUCCESS = 0, FAILURE = 1. CHARACTER 1–word scalar type. Values are represented by unsigned integers in the range 0 .. 255, where the subrange 0 .. 127 is the ASCII character set. Within strings, 4 characters are packed in one 32–bit word. REAL 1–word scalar type. Values are represented in IEEE single floating point format. LONG_REAL 2–word sclar type. Values are represented in IEEE double floating point format. DURATION 2–word scalar type, represented like LONG_REAL. TIME 2–word scalar type. Values are internally represented using two 32–bit words. They contain the following time components in packed format in this order: year – 1900 (8–bit integer), month (4–bit integer), day (5–bit integer), seconds since midnight (47–bit fixed point value with 17 bits before and 30 bits after the decimal point). Times without a date are represented with the year, month and day fields = 0. The constant ~:~ (no time) is represented with all bits in both words set to 1. statecode types 2–word scalar types. A statecode value is represented by two 32–bit words containing the corresponding statecode literal as an ASCII character sequence (up to 8 characters) in all upper–case, left–justified and padded with spaces. The literal $$ is represented as 8 spaces. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 7 Datum/Date : Datum/Date: von/of 95 pathname types Pathname types fall in two classes: • Non–parameterized pathnames are 1–word scalar values represented by the SID of the corresponding database item. It is represented in UNSIGNED_INTEGER format. The constant \\ (no pathname) is represented by SID 0. • Parameterized pathnames are structured values. Their representation is defined by the internal encoding scheme described in chapter 7.3.2.2. subitem pathname types Subitem pathname values are represented as two 32–bit words: the first contains the short identifier (SID) of the database item, the second the subitem identifier, both as unsigned integers. set types Structured types. A set is represented by a number of bits packed in one or more 32–bit words, one bit for each possible member of the set. A member is present in the set, if its bit is set, it is absent otherwise. The first member is expressed by bit 0, the last member by bit n–1. Bits in a word are numbered 0 .. 31 with bit 0 as the first bit. The bit number represents the significance when the word is read as an unsigned integer, e. g. { 0, 1, 2 } corresponds to the integer 7 (= 20 + 21 + 22). BITSET 1–word scalar type. A bitset is represented like a set with elements 0 – 31 in one 32–bit word. string types Structured types. A string is represented as one word holding the actual length of the string as an unsigned integer, followed by zero or more words holding a byte array with 4 bytes or characters packed in one word. The number of bytes covers the maximum length of the string, filled up to a multiple of four. array types Structured types. An array is represented as a sequence of its elements in their respective representation. Arrays with more than one dimension store their elements in an order that for all index positions i and i+1 indices on position i+1 vary faster than on position i. record types Structured types. A record is represented as the sequence of its fields in their respective representation. All variants of the same variant part are mapped to the same location in memory. The size of a variant part is determined by its longest variant. BYTE 1–word scalar type, represented as one 32–bit word without any interpretation of the bits. Values are restricted to the range 0 – 255. Within strings, four byte values are packed in one 32 bit word. WORD 1–word scalar type, represented as one 32–bit word without any interpretation of the bits. LONG_WORD 2–word scalar type, represented as two consecutive 32–bit words without any interpretation of the bits. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 8 Datum/Date : Datum/Date: von/of 95 5 I–Code definition I–Code (for “Intermediate Code”) is the object code produced by the UCL compiler. It has binary format and is directly executable by the I–Code interpreters, on–board (in DMS) as well as on ground (in VICOS and CSS). The I–Code has identical format and is interchangeable between ground and on–board. Each I–Code instruction is an unsigned byte, possibly followed by one or two instruction specific parameters. I–Code can be regarded as the instruction set of a Virtual Stack Machine which is implemented by the I–Code interpreters. A stack machine is characterized by the fact that instructions do not address their operands directly but access them via the Expression Stack. Prior to instruction execution, all operands needed must be explicitly loaded from their memory locations onto the stack. Each instruction pops its input operands from the stack and pushes its result operands back onto the stack where they are available as input to subsequent instructions. Dedicated Load and Store instructions move data items from memory onto the stack and from the stack into memory, respectively. The architecture of the stack machine and the I–Code instructions with their parameters and semantics are described in detail in the following sections. The Ada package I_Code_Definition (given in chapter 9) defines the I–Code in terms of Ada types. The I–Code is essentially given as an enumeration type, together with functions converting between the enmeration values and their textual and machine representation. This package shall be used by all software operating on I–Code. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 9 Datum/Date : Datum/Date: von/of 95 5.1 I–Code Record Layout Figure 5–1. Import list size WORD Code size WORD Global data size WORD Constant area size WORD Relocation table size WORD Version table size WORD Source ref. table size WORD Import list WORDS Code BYTES Constant area WORDS Relocation table WORDS Version table WORDS Source reference table WORDS I–Code Record The I–Code record is generated by the UCL compiler and kept in the database. On the other hand, small (pseudo–)APs may be generated by the HLCL interpreters in the HCI and directly sent via message over the network. The I–Code record, when retrieved from the database or received via message, is decomposed by the interpreter into global data and code parts. Actual parameters delivered with an activation request are copied into the first few global data words before start of the I–Code interpretation. The I–Code record format shown above is mapped into a byte array. The size indications in the header, however, count actual items, i.e. bytes in the code part, words in the other parts. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 10 Datum/Date : Datum/Date: von/of 95 Header The header consists of the following 7 items. Each item is stored in one word (4 bytes). The header size is thus 7 words: • The size of the import list in words • The size of the code in bytes • The size of the global data area in words • The size of the constant area in words • The size of the relocation table in words • The size of the version table in words • The size of the source reference table in words Import list The import list lists the SIDs of all imported user libraries. The user library with the external reference number 1 (i.e. the first library in the source module’s import list) is the first entry in this import list, the library 2 the second, and so on. Each library SID occupies one word of storage. Code The code area is a byte–oriented stream of the I–code. It is copied into the stack machine’s code buffer at program load time (see also code buffer description later in this document). After copying the code area into the code buffer, all external library calls have to be relocated. Constant area The constant area holds long constants referenced in the I–code, e.g. strings or state codes. It may also contain integer or real values, e.g. to reduce the storage required by often used values. Each constant will be word–aligned. Relocation table The relocation table is used to relocate the references to external (i.e. imported) libraries. Each instruction referencing user libraries references the called library using a number, the library’s SID is then found via the import list. Different modules may use different numbers in referencing the same library, depending on the order (and/or number) of imported libraries. The relocation step assigns then the same number for the same library to each “external” instruction. Each entry in the relocation table is one word long and points into the code buffer, giving the address of the library number to be relocated. Version table The version table contains I–Code version information. Each entry is a 32–bit word whose four bytes are read as characters in the form nn/x where nn is the version number (the first n possibly being a space character), and x is either a hyphen (’–’) for the first issue, or a capital letter A, B, C, ... for later issues. The first version table entry refers to an issue of this Reference Manual. It identifies an I–Code version. Further entries are TBD. Source reference table The source reference table maps code positions (PCs) on source line numbers. It is a list of pairs (PC, line number), where the PC defines the start of the source line. The end of the source line is given by the PC of the next pair minus one, or by the end of the list, respectively. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 11 Datum/Date : Datum/Date: von/of 95 5.2 I–Code Instructions 5.2.1 Instruction Format Each I–Code instruction is one byte, possibly followed by one or two parameters. The instruction currently executed is pointed to by the program counter register (PC). Each instruction moves the PC to the instruction that is to be executed next, this is normally the following instruction, unless the control flow is to be explicitly altered (jumps, procedure calls etc.). All instructions access their input and output operands (if any) via the expression stack: operands read by the instruction are popped off the stack, results produced by the instruction are pushed on the stack. For some very frequent Load, Store and Call instructions with a parameter in the range 0 .. 15 additional short forms have been introduced to avoid the explicit parameter and thus to obtain more compact code: e.g. the 1–byte (parameterless) instructions LOAD_C.0, LOAD_C.1, LOAD_C.2 etc. have the same meaning as the 2–byte (parameterized) instructions LOAD_C.b 0, LOAD_C.b 1, LOAD_C.b 2 etc. The following table contains a detailed description of all I–Code instructions. For each instruction the following details are given: • the binary code: a value in the range 00 .. FF. • the mnemonic: a suggestive symbolic name indicating the function performed by the instruction. Variations of a function are denoted by different suffixes to the basic name, separated by an underscore. If different instructions perform the same function with a difference only in the in the size of the operands, their names consist of the basic name plus a suffix separated by a dot (”.b” for byte operands, ”.h” for halfword operands and ”.w” for word operands). The suffix will be, by convention, written in lower case. For instructions with implied operands, the suffix denotes the implied value, e.g. ”.0”, ”.1”, etc. • the parameters of the instruction. Parameters may be one to four bytes long, the length is indicated with each parameter. The parameters are interpreted signed or unsigned, depending on the instruction. • the modes in which the instruction might be executed. The Stack Machine distinguishes between three instruction modes: “normal” This is the normal mode of the Stack Machine. After each instruction the Stack Machine is reset into this mode. “double” This mode is used to switch from single word to double word operation of the Stack Machine. Double word I–code operations are currently supported only for 64 bit reals.The Stack Machine is switched into this mode by prefixing the next I–code instruction with a DOUBLE instruction. “multi” This mode is used for multiple word operations. The Stack Machine is switched into this mode by prefixing the next I–code instruction with a MULTI instruction. • If an instruction is not allowed to be executed in a particular mode, then no explanation is given in the following instruction table, as a result the instruction causes a run–time trap. • the instruction title (a short informal description). Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 12 Datum/Date : Datum/Date: von/of 95 • the effect on the expression stack (given in brackets after the title): the “=>” sign separates input items popped off the stack (left) and output items pushed onto the stack (right): [ x, y => z ] states that the instruction pops x and y from the stack and, as a result, pushes z on the stack. Optional items are enclosed in parentheses. • a semantics specification given as a piece of Ada–like pseudo–code. These pieces of pseudo–code are not to be understood as optimized algorithms, but rather as an easy–to–understand semantics description. Note that a different semantic is associated with each instruction mode. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 13 Datum/Date : Datum/Date: von/of 95 5.2.2 Conventions The following conventions are applied in the I–Code description: • Data representation of UCL runtime values is according to the conventions stated in chapter 4. • The term “halfword” and “word” denote 2–byte and 4–byte values, respectively. The term “double word” denotes an 8–byte value. • The parameters are interpreted signed or unsigned, depending on the instruction. • The PC is assumed to point to the code byte of the instruction currently executed. It is not explicitly shown that each instruction implicitly advances the PC to the next instruction (PC := PC + 1 + parameter length), if it does not explicitly alter the control flow. • Distances used to calculate a new PC value are offsets to the current PC. • The registers of the stack machine (SP, MP, FP, GP, PC) are used as variables. • Auxiliary variables are used in a suggestive manner: A denotes an address, B denotes a boolean value, D denotes a duration, T denotes a time, I, L, N stand for integer numbers, X, Y denote arithmetic operands of the type imposed by the instruction, sets are regarded as boolean arrays of 32 bits packed in a word • The Module Base Table is regarded as an array of words, named BASE, pointing to the start of the global data frame of a module. • The Code Buffer is regarded as an array of bytes, named CODE. • The Memory is regarded as an array of words, named MEMORY. • The expression stack is regarded as an array of words, named STACK, where the SP points to the element on top of the stack. Stack manipulations are indicated with calls to the procedures PUSH and POP for words and PUSHD and POPD for double words defined as: PUSH (X) => SP := SP + 1; STACK(SP) := X; PUSHD (X) => SP := SP + 2; STACK(SP–1 .. SP) := X; POP (X) => X := STACK(SP); SP := SP – 1; POPD (X) => X := STACK(SP–1 .. SP); SP := SP – 2; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 14 Datum/Date : Datum/Date: von/of 95 • The following functions are used to obtain control information from the Memory and the Code Buffer: CONST_ADR (A) address of constant at offset A in constant area of current global data frame => return MEMORY(GP–1) + A; PROC (N) entry point of procedure N in current code frame => return CP + VALUE (CODE(CP+N*2 .. CP+N*2 + 1)); SIZE (SID) size (in words) of data value associated with database object designated by SID. • The following procedures and functions are used to denote Stack Machine system services: SET_BYTE (i, W, X) set i–th byte in word W to value X BYTE (i, W) extract i–th byte from word W VALUE (bytes) compute numerical value from byte array STRING (A) return the string stored under address A SYSTEM (L, P) call system service P in system library L READ (SID, TYPE, X) read end item value for SID of SW type TYPE into variable X READD (SID, TYPE, X) read end item value for SID of SW type TYPE into double word variable X, if TYPE = STATECODE_TYPE: convert to upper case READM (SID, TYPE, A) read multiple–word value for SID of SW type TYPE to address A, if TYPE = STATECODE_TYPE: convert components to upper case WRITE (SID, TYPE, X) write end item value for SID of SW type TYPE from variable X WRITED (SID, TYPE, X) write end item value for SID of SW type TYPE from double word variable X WRITEM (SID, TYPE, A) write multiple–word value for SID of SW type TYPE from address A ERROR (E) abort with runtime error E TRAP (T) abort with runtime error trap T HALT (S) stop execution and return success code S (0 = success, 1 = failure) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 15 Datum/Date : Datum/Date: von/of 95 IMAGE (X, TYPE, WIDTH, AFT, EXP) return the textual representation of value X of SW type TYPE. IMAGED (X, TYPE, WIDTH, AFT, EXP) return the textual representation of double–word value X of SW type TYPE. IMAGEM (A, TYPE, WIDTH, AFT, EXP) return the textual representation of structured value at address A of SW type TYPE. for all IMAGE functions: WIDTH = minimum text width AFT = number of digits after the decimal point (real + time types) EXP = min. width of exponent, 0 = no exponent (real types) WIDTH = AFT = EXP = 0 means standard UCL/HLCL format. VALID (S, TYPE) Return TRUE if string S is a valid textual representation for a value of SW type TYPE, FALSE otherwise. VALUE (S, TYPE) return the value of SW type TYPE whose textual representation is in string S. VALUED (S, TYPE) return the double–word value of SW type TYPE whose textual representation is in string S. VALUEM (S, TYPE) return the structured value of SW type TYPE whose textual representation is in string S. • Integer/real conversion functions (actual source and target types depend on context): TRUNC (R) return the truncated (unsigned) integer value of real value R. ROUND (R) return the rounded (unsigned) integer value of real value R. FLOAT (I) return the real value of (unsigned) integer value I. LONG (R) return the long real value for real value R. SHORT (R) return the real value for long real value R. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 16 Datum/Date : Datum/Date: von/of 95 5.2.3 Instruction Short Reference This table lists all I–Code instructions in alphabetical order. For a detailed description see the next chapter. The columns have the following meaning: code (hex), additional supported formats (D = double, M = multi), instruction with parameters, meaning, stack operation (items left of => are popped off the stack, items right of => are pushed on the stack). A7 B4 D B5 A0 AE D B8 M ABS_I ABS_R ADD_D ADD_I ADD_R ADD_S Absolute integer value Absolute real value Add time and duration Add integers Add reals Set union A8 D8 71 ... 7F E5 E6 9C FA F9 FC D FB 9D D A3 AB B1 D BB M ADD_U ALLOC CALL.1 ... CALL.15 CALL.b proc CALL_E lib, proc CAT CHECK_0 CHECK_I CHECK_R CHECK_U COPY DIV_I DIV_U DIV_R DIV_S Add unsigned Allocate space in memory Call procedure/function 1 – 15 F5 DOUBLE E8 ENTER par, dat BE D M EQU FD BD A4 B2 D AC D9 D6 C3 ERROR err EXCL EXP_I EXP_R EXP_U FREE GEQ_A GEQ_I Call procedure/function Call external procedure/function String concatenation Check range 0 .. m Check integer range n .. m Check real range n .. m Check unsigned range n .. m Copy top of stack Divide integers Divide unsigned Divide reals Symmetric set difference Next instruction is double Enter procedure/funct. Test equal Runtime error trap Exclude element from set Exponentiate integer Exponentiate real Exponentiate unsigned Free allocated space in memory Test great/equ. (ASCII) Test greater/equ. (int) [ val => val ] [ val => val ] [ val, val => val ] [ val, val => val ] [ val, val => val ] [ set, set => set ] M: [ adr, adr, size => adr ] [ val, val => val ] [ size => adr ] [] [] [] [ adr, adr, size => adr ] [ val, max => val ] [ val, min, max => val ] [ val, min, max => val ] [ val, min, max => val ] [ val => val, val ] [ val, val => val ] [ val, val => val ] [ val, val => val ] [ set, set => set ] M: [ adr, adr, size => adr ] [] [ val, ..., val => ] [ val, val => bool ] M: [ adr, adr, size => bool ] [] [ adr, num => ] [ val, val => val ] [ val, val => val ] [ val, val => val ] [ size => ] [ adr, adr => bool ] [ val, val => bool ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: CB D GEQ_R D1 M GEQ_S Test great./equ. (real) Test set inclusion CF C7 D4 C1 C9 D CD C5 FE BC E7 E0 GEQ_T GEQ_U GRT_A GRT_I GRT_R GRT_T GRT_U HALT INCL INIT ITER dist Test grt./equ. (time) Test grt./equ. (unsig) Test greater (ASCII) Test greater (int) Test greater (real) Test greater (time) Test greater (unsig) Stop program and return Include element in set Enter library initialization part Iterative loop prolog DA DB DC DD DF DE E4 D5 C2 CA D D0 M JUMP.b dist JUMP.h dist JUMP_C.b dist JUMP_C.h dist JUMP_F.b dist JUMP_T.b dist LEAVE LEQ_A LEQ_I LEQ_R LEQ_S Jump (short distance) Jump (long distance) Conditional jump (short dist.) Conditional jump (long distance) Jump if false (AND) Jump if true (OR) Exit from SWITCH Test less/equal (ASCII) Test less/equal (int) Test less/equal (real) Test set inclusion CE C6 D3 C0 C8 D CC C4 91 8F 90 8E 8D 92 93 LEQ_T LEQ_U LES_A LES_I LES_R LES_T LES_U LOAD_A_E lib, adr LOAD_A_F.b offs LOAD_A_F.h offs LOAD_A_G.b adr LOAD_A_L.b adr LOAD_A_T.b offs LOAD_A_T.h offs Test less/equal (time) Test less/equal (unsig) Test less (ASCII) Test less (int) Test less (real) Test less (time) Test less (unsig) Load external address Load offsetted address Load offsetted address Load global address Load local address Load address of constant in Load address of constant in 17 Datum/Date : Datum/Date: von/of 95 [ val, val => bool ] [ set, set => bool ] M: [ adr, adr, size => bool ] [ val, val => bool ] [ val, val => bool ] [ adr, adr => bool ] [ val, val => bool ] [ val, val => bool ] [ val, val => bool ] [ val, val => bool ] [ code => ] [ adr, num => ] [] [ adr, first, last, step => (adr, first, last, step, label) ] [] [] [ bool => ] [ bool => ] [ bool => (bool) ] [ bool => (bool) ] [ label => ] [ adr, adr => bool ] [ val, val => bool ] [ val, val => bool ] [ set, set => bool ] M: [ adr, adr, size => bool ] [ val, val => bool ] [ val, val => bool ] [ adr, adr => bool ] [ val, val => bool ] [ val, val => bool ] [ val, val => bool ] [ val, val => bool ] [ => adr ] [ adr => adr ] [ adr => adr ] [ => adr ] [ => adr ] [ => adr ] [ => adr ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 00 ... 0F 82 83 84 89 30 ... 3F 87 88 20 ... 2F 86 10 ... 1F 85 80 81 8A 8B F1 A5 AD 9B A2 B0 BA D D D D D D D D D D D D D D D D LOAD_C.0 ... LOAD_C.15 LOAD_C.b val LOAD_C.h val LOAD_C.w val LOAD_E lib, adr LOAD_F.0 ... LOAD_F.15 LOAD_F.b offs LOAD_F.h offs LOAD_G.0 ... LOAD_G.15 LOAD_G.b adr LOAD_L.0 ... LOAD_L.15 LOAD_L.b adr LOAD_T.b offs LOAD_T.h offs LOAD_X_C LOAD_X_V LONG_R MOD_I MOD_U MOVE MUL_I MUL_R M MUL_S Load constant 0 – 15 [ => val ] Load byte constant Load halfword (2–byte) constant Load word (4–byte) constant Load external variable Load offsetted variable from address 0 – 15 [ => val ] Load offsetted variable Load offsetted variable Load global variable from address 0 – 15 [ adr => val ] Load global variable Load local variable from address 0 – 15 [ => val ] Load local variable Load constant from table Load constant with halfword Load indexed character Load indexed variable Convert real to long real Modulus Unsigned modulus Move block of data Multiply integers Multiply reals Set intersection [ => val ] AA F6 D7 A6 B3 D BF D M MUL_U MULTI NEG NEG_I NEG_R NEQ Multiply unsigned Next instruction is multiple Boolean NOT Negate integer Negate real Test not equal E1 NEXT Iterative loop epilog FF D M NOP 9E D POP n 18 Datum/Date : Datum/Date: von/of 95 No operation Remove items from top of stack [ => val ] [ => val ] [ => val ] [ adr => val ] [ adr => val ] [ => val ] [ => val ] [ => val ] [ => val ] [ adr, inx => val ] [ adr, inx => val ] [ val => val ] [ val, val => val ] [ val, val => val ] [ adr, adr, len ] [ val, val => val ] [ val, val => val ] [ set, set => set ] M: [ adr, adr, size => adr ] [ val, val => val ] [] [ bool => bool ] [ val => val ] [ val => val ] [ val, val => bool ] M: [ adr, adr, size => bool ] [ adr, first, last, step, label => (adr, first, last, step, label) ] [] [ val (,...) => ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 19 F7 D M READ type Read DB end item value EE EF EC ED E9 F0 98 60 ... 6F 96 97 50 ... 5F 95 40 ... 4F 94 99 9A F2 REAL_I REAL_U ROUND_I ROUND_U RTN SHORT_R STOR_E lib, adr STOR_F.0 ... STOR_F.15 STOR_F.b offs STOR_F.h offs STOR_G.0 ... STOR_G.15 STOR_G.b adr STOR_L.0 ... STOR_L.15 STOR_L.b adr STOR_X_C STOR_X_V STR type Convert integer to real Convert unsigned integer to real Round real to integer Round real to unsigned integer Return from procedure/function Convert long real to real Store external variable Store offsetted variable at address 0 – 15 B6 A1 AF D B9 M SUB_D SUB_I SUB_R SUB_S Subtract duration Subtract integers Subtract reals Set difference B7 A9 9F D E2 E3 F4 D2 M SUB_T SUB_U SWAP SWITCH n SWITCH_X n SYS lib, proc TEST Subtract times Subtract unsigned Swap data on top of stack Switch to CASE branch Switch to CASE branch System call Test set membership EA D EB D TRUNC_I TRUNC_U Truncate real to integer Truncate real to unsigned integer [ val => val ] D D D D D D D D D D D D D Datum/Date : Datum/Date: von/of 95 [ sid => val ] M: [ sid, size => adr ] [ val => val ] [ val => val ] [ val => val ] [ val => val ] [] [ val => val ] [ val => ] [ adr, val => ] Store offsetted variable Store offsetted variable Store global variable at address 0 – 15 [ adr, val => ] Store global variable Store local variable at address 0 – 15 [ val => ] Store local variable Store indexed character Store indexed variable Convert value to string [ val => ] [ adr, val => ] [ val => ] [ val => ] [ adr, inx, val => ] [ adr, inx, val => ] [ val, width, aft, exp=> adr, size ] M: [ adr, width, aft, exp=> adr, size ] [ val, val => val ] [ val, val => val ] [ val, val => val ] [ set, set => set ] M: [ adr, adr, size => adr ] [ val, val => val ] [ val, val => val ] [ val, val => val, val ] [ val => label ] [ val => label ] [] [ num, set => bool ] M: [ num, adr, len => bool ] [ val => val ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: F3 VAL type F8 D M WRITE type Convert string to value Write DB end item value 20 Datum/Date : Datum/Date: von/of 95 N: [ adr, check => val] D: [ adr => val ] M: [ adr => adr ] [ sid, val => ] M: [ sid, adr, size => ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 21 Datum/Date : Datum/Date: von/of 95 5.2.4 I–Code Instruction Description This table lists all I–Code instructions, ordered by their code, together with a detailed description. 5.2.4.1 Instructions with implied parameter These instructions are special cases of the corresponding instructions with explicit parameter. They have been introduced for optimization, since these instructions (particularly with small range parameters) cover a great percentage of every program. LOAD_L.0 LOAD_L.1 LOAD L 2 LOAD_L.2 LOAD_L.3 LOAD_L.4 LOAD_L.5 LOAD_L.6 LOAD_L.7 LOAD_L.8 LOAD L 9 LOAD_L.9 LOAD_L.10 LOAD_L.11 LOAD_L.12 LOAD_L.13 LOAD_L.14 LOAD_L.15 Normal 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F Load constant 0 .. 15 PUSH (n); –– n = 0 .. 15 Double LOAD_C.0 LOAD_C.1 LOAD C 2 LOAD_C.2 LOAD_C.3 LOAD_C.4 LOAD_C.5 LOAD_C.6 LOAD_C.7 LOAD_C.8 LOAD C 9 LOAD_C.9 LOAD_C.10 LOAD_C.11 LOAD_C.12 LOAD_C.13 LOAD_C.14 LOAD_C.15 Semantics PUSHD (n); –– n = 0 .. 15 Load local variable from address 0 .. 15 Normal 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F Param. PUSH (MEMORY(FP + n)); Double Hex Mnemonic PUSHD (MEMORY(FP + n .. FP + n + 1)); [ => val ] [ => val ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: STOR_L.0 STOR_L.1 STOR L 2 STOR_L.2 STOR_L.3 STOR_L.4 STOR_L.5 STOR_L.6 STOR_L.7 STOR_L.8 STOR L 9 STOR_L.9 STOR_L.10 STOR_L.11 STOR_L.12 STOR_L.13 STOR_L.14 STOR_L.15 Normal 40 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F Double LOAD_F.0 LOAD_F.1 LOAD F 2 LOAD_F.2 LOAD_F.3 LOAD_F.4 LOAD_F.5 LOAD_F.6 LOAD_F.7 LOAD_F.8 LOAD F 9 LOAD_F.9 LOAD_F.10 LOAD_F.11 LOAD_F.12 LOAD_F.13 LOAD_F.14 LOAD_F.15 PUSH (MEMORY(GP + n)); PUSHD (MEMORY(GP + n .. GP + n + 1)); Load offsetted variable from address 0 .. 15 Normal 30 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F Load global variable from address 0 .. 15 POP (A); PUSH (MEMORY(A + n)); Double LOAD_G.0 LOAD_G.1 LOAD G 2 LOAD_G.2 LOAD_G.3 LOAD_G.4 LOAD_G.5 LOAD_G.6 LOAD_G.7 LOAD_G.8 LOAD G 9 LOAD_G.9 LOAD_G.10 LOAD_G.11 LOAD_G.12 LOAD_G.13 LOAD_G.14 LOAD_G.15 Semantics POP (A); PUSHD (MEMORY(A + n .. A + n + 1)); Store local variable at address 0 .. 15 Normal 20 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F Param. POP (X); MEMORY(FP + n) := X; Double Hex Mnemonic 22 Datum/Date : Datum/Date: von/of 95 POPD (X); MEMORY(FP + n .. FP + n + 1) := X; [ => val ] [ adr => val ] [ val => ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 70 71 72 73 74 75 76 77 78 79 7A 7B 7C 7D 7E 7F ––– CALL.1 CALL.2 CALL.3 CALL.4 CALL.5 CALL.6 CALL.7 CALL.8 CALL.9 CALL.10 CALL.11 CALL.12 CALL.13 CALL.14 CALL.15 Normal STOR_F.0 STOR_F.1 STOR_F.2 STOR_F.3 STOR_F.4 STOR_F.5 STOR_F.6 STOR_F.7 STOR_F.8 STOR_F.9 STOR_F.10 STOR_F.11 STOR_F.12 STOR_F.13 STOR_F.14 STOR_F.15 POP (X); MEMORY(GP + n) := X; Double 60 61 62 63 64 65 66 67 68 69 6A 6B 6C 6D 6E 6F Store global variable at address 0 .. 15 POPD (X); MEMORY(GP + n .. GP + n + 1) := X; Store offsetted variable at address 0 .. 15 [ val => ] [ adr, val => ] Normal STOR_G.0 STOR_G.1 STOR G 2 STOR_G.2 STOR_G.3 STOR_G.4 STOR_G.5 STOR_G.6 STOR_G.7 STOR_G.8 STOR G 9 STOR_G.9 STOR_G.10 STOR_G.11 STOR_G.12 STOR_G.13 STOR_G.14 STOR_G.15 Semantics POP (X); POP (A); MEMORY(A + n) := X; Double 50 51 52 53 54 55 56 57 58 59 5A 5B 5C 5D 5E 5F Param. POPD (X); POP (A); MEMORY(A + n .. A + n + 1) := X; Call procedure/function 1 .. 15 MEMORY (MP) := FP; MEMORY (MP+1) := PC+1; Normal Hex Mnemonic 23 Datum/Date : Datum/Date: von/of 95 MP := MP + 2; FP := MP; PC := PROC (n); [] –– save dynamic link –– save return addr. –– mark stack frame –– jump –– n = 1 .. 15 Note: There is no CALL.0 instruction. A main program cannot call itself. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 24 Datum/Date : Datum/Date: von/of 95 5.2.4.2 Load Instructions These instructions push data from the Memory onto the Expression Stack. Hex Mnemonic LOAD_T.b offs 1 unsigned Semantics Load constant from table Double Normal 80 Param. LOAD_T.h offs 2 unsigned Double 84 LOAD_C.w val 4 signed Normal PUSH (val); Double Load byte constant PUSHD (val); Load halfword (2–byte) constant Normal val 2 signed PUSHD (MEMORY(CONST_ADR(offs) .. CONST_ADR(offs) + 1)); PUSH (val); Double LOAD_C.h val 1 signed [ => val ] PUSH (MEMORY(CONST_ADR(offs))); PUSHD (val); Load word (4–byte) constant Normal 83 LOAD_C.b PUSHD (MEMORY(CONST_ADR(offs) .. CONST_ADR(offs) + 1)); PUSH (val); Double 82 PUSH (MEMORY(CONST_ADR(offs))); Load constant with halfword offset from table Normal 81 [ => val ] PUSHD (val); [ => val ] [ => val ] [ => val ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 88 89 LOAD_F.h LOAD_E offs 2 unsigned lib 1 unsigned adr 1 unsigned Normal PUSH (MEMORY(FP + adr)); Double PUSHD (MEMORY(FP + adr .. FP + adr + 1)); Normal [ => val ] PUSH (MEMORY(GP + adr)); Double Load global variable PUSHD (MEMORY(GP + adr .. GP + adr + 1)); Load offsetted variable [ adr => val ] Normal offs 1 unsigned [ => val ] POP (A); PUSH (MEMORY(A + offs)); Double LOAD_F.b adr 1 unsigned Load local variable POP (A); PUSHD (MEMORY(A + offs .. A + offs + 1)); Load offsetted variable with halfword offset [ adr => val ] Normal 87 LOAD_G.b adr 1 unsigned POP (A); PUSH (MEMORY(A + offs)); Double 86 LOAD_L.b Semantics POP (A); PUSHD (MEMORY(A + offs .. A + offs + 1)); Load external variable Normal 85 Param. Double Hex Mnemonic 25 Datum/Date : Datum/Date: von/of 95 [ => val ] PUSH (MEMORY(BASE(lib) + adr)); PUSHD (MEMORY(BASE(lib) + adr .. BASE(lib) + adr + 1)); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Hex Mnemonic 8A LOAD_X_C Param. 26 Datum/Date : Datum/Date: von/of 95 Semantics Load indexed character [ adr, inx => val ] Normal POP (I); POP (A); I := I – 1; 8C Load indexed variable Normal LOAD_X_V POP (I); POP (A); PUSH (MEMORY(A + I)); Double 8B if I < 0 or I >= MEMORY(A) then TRAP (range_error); else PUSH (BYTE(I mod 4, MEMORY(A + 1 + I/4))); end if; POP (I); POP (A); PUSHD (MEMORY(A + I * 2) .. MEMORY(A + I * 2 + 1)); [ adr, inx => val ] –––– Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 27 Datum/Date : Datum/Date: von/of 95 5.2.4.3 Load Address Instructions These instructions push the Memory address of data on the Expression Stack. Hex Mnemonic LOAD_A_L.b adr 1 unsigned Semantics Load local address Normal 8D Param. LOAD_A_G.b adr 1 unsigned LOAD_A_F.b offs 1 unsigned LOAD_A_F.h offs 2 unsigned LOAD_A_E lib 1 unsigned adr 1 unsigned LOAD_A_T.b offs 1 unsigned LOAD_A_T.h offs 2 unsigned [ => adr ] PUSH (CONST_ADR(offs)); Load address of constant in constant table with halfword offset Normal 93 [ => adr ] PUSH (BASE(lib) + adr); Load address of constant in constant table Normal 92 [ adr => adr ] POP (A); PUSH (A + offs); Load external address Normal 91 [ adr => adr ] POP (A); PUSH (A + offs); Load offsetted address with halfword offset Normal 90 [ => adr ] PUSH (GP + adr); Load offsetted address Normal 8F PUSH (FP + adr); Load global address Normal 8E [ => adr ] [ => adr ] PUSH (CONST_ADR(offs)); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 28 Datum/Date : Datum/Date: von/of 95 5.2.4.4 Store Instructions Theses instructions pop data from the Expression Stack into the Memory. 97 STOR_F.b STOR_F.h offs 1 unsigned offs 2 unsigned Normal POP (X); MEMORY(FP + adr) := X; Double [ val => ] POPD (X); MEMORY(FP + adr .. FP + adr + 1) := X; [ val => ] Normal Store global variable POP (X); MEMORY(GP + adr) := X; Double adr 1 unsigned Store local variable POPD (X); MEMORY(GP + adr .. GP + adr + 1) := X; Store offsetted variable [ adr, val => ] Normal 96 STOR_G.b adr 1 unsigned POP (X); POP (A); MEMORY(A + offs) := X; Double 95 STOR_L.b Semantics POPD (X); POP (A); MEMORY(A + offs .. A + offs + 1) := X; Store offsetted variable with halfword offset [ adr, val => ] Normal 94 Param. POP (X); POP (A); MEMORY(A + offs) := X; Double Hex Mnemonic POPD (X); POP (A); MEMORY(A + offs .. A + offs + 1) := X; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: STOR_E lib 1 unsigned adr 1 unsigned STOR_X_C Store external variable POP (X); MEMORY(BASE(lib) + adr) := X; POPD (X); MEMORY(BASE(lib) + adr .. BASE(lib) + adr + 1) := X; Store indexed character Normal 99 Semantics Normal 98 Param. Double Hex Mnemonic [ adr, inx, val => ] POP (X); POP (I); POP (A); I := I – 1; if I < 0 or I >= MEMORY(A) then TRAP (range_error); else SET_BYTE (I mod 4, MEMORY(A + 1 + I/4), X); end if; Store indexed variable [ adr, inx, val => ] Normal STOR_X_V [ val => ] POP (X); POP (I); POP (A); MEMORY(A + I) := X; Double 9A 29 Datum/Date : Datum/Date: von/of 95 POPD (X); POP (I); POP (A); MEMORY(A + I * 2 .. A + I * 2 + 1) := X; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 30 Datum/Date : Datum/Date: von/of 95 5.2.4.5 MOVE and CAT Instructions The MOVE instruction copies multiple–word data between Memory locations. Hex Mnemonic Semantics Move block of data MOVE Normal 9B Param. [ adr, adr, len => ] POP (L); POP (A2); POP (A1); MEMORY(A1 .. A1+L–1) := MEMORY(A2 .. A2+L–1); The CAT instruction concatenates two strings. 9C CAT Param. Semantics String concatenation [ adr, adr, size => adr ] POP (L); POP (A2); POP (A1); PUSH (MP); Normal Hex Mnemonic L1 := MEMORY(A1); –– length of first string L2 := MEMORY(A2); –– length of second string MEMORY (MP) := L1 + L2; –– resultant length MEMORY (MP + 1 .. MP + L – 1) := STRING (A1) & STRING (A2); –– concatenation MP := MP + L; –– This instruction implicitly allocates –– space in memory Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 31 Datum/Date : Datum/Date: von/of 95 5.2.4.6 Stack Instructions These instructions manipulate the Expression Stack only. 9F SWAP n 1 unsigned Normal POP (X); PUSH (X); PUSH (X); POPD (X); PUSHD (X); PUSHD (X); Remove n items from top of stack Normal POP [ val => val, val ] Double Copy top of stack COPY SP := SP – n; Double 9E Semantics SP := SP – 2 * n; Swap data on top of stack Normal 9D Param. POP (X); POP (Y); PUSH (X); PUSH (Y); Double Hex Mnemonic POPD (X); POPD (Y); PUSHD (X); PUSHD (Y); [ val (,...) => ] [ val, val => val, val ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 32 Datum/Date : Datum/Date: von/of 95 5.2.4.7 Numerical Instructions These instructions perform different numerical operations, they usually pop their operands from the Expression Stack and push their result back on the Expression Stack. a) INTEGER operations Hex Mnemonic ADD_I Semantics Add integers Normal A0 Param. SUB_I MUL_I DIV_I EXP_I MOD_I NEG_I [ val, val => val ] POP (Y); POP (X); PUSH (X ** Y); [ val, val => val ] POP (Y); POP (X); PUSH (X ** Y); [ val, val => val ] POP (Y); POP (X); PUSH (X mod Y); Negate integer Normal A6 POP (Y); POP (X); PUSH (X / Y); Modulus integer Normal A5 [ val, val => val ] Exponentiate integer Normal A4 POP (Y); POP (X); PUSH (X – Y); Divide integers Normal A3 [ val, val => val ] Multiply integers Normal A2 POP (Y); POP (X); PUSH (X + Y); Subtract integers Normal A1 [ val, val => val ] [ val => val ] POP (X); PUSH (–X); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: A7 ABS_I Param. Semantics Absolute integer value Normal Hex Mnemonic 33 Datum/Date : Datum/Date: von/of 95 [ val => val ] POP (X); PUSH (abs X); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 34 Datum/Date : Datum/Date: von/of 95 b) UNSIGNED_INTEGER operations Hex Mnemonic ADD_U Semantics Add unsigned Normal A8 Param. SUB_U MUL_U DIV_U EXP_U MOD_U POP (Y); POP (X); PUSH (X * Y); [ val, val => val ] POP (Y); POP (X); PUSH (X / Y); [ val, val => val ] POP (Y); POP (X); PUSH (X ** Y); Modulus unsigned Normal AD [ val, val => val ] Exponentiate unsigned Normal AC POP (Y); POP (X); PUSH (X * Y); Divide unsigned Normal AB [ val, val => val ] Multiply unsigned Normal AA POP (Y); POP (X); PUSH (X + Y); Subtract unsigned Normal A9 [ val, val => val ] [ val, val => val ] POP (Y); POP (X); PUSH (X mod Y); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 35 Datum/Date : Datum/Date: von/of 95 c) REAL operations B1 B2 DIV_R EXP_R Normal POP (Y); POP (X); PUSH (X + Y); Double POPD (Y); POPD (X); PUSHD (X + Y); Normal [ val, val => val ] POP (Y); POP (X); PUSH (X – Y); Double Subtract reals POPD (Y); POPD (X); PUSHD (X – Y) [ val, val => val ] Normal Multiply reals POP (Y); POP (X); PUSH (X * Y); Double MUL_R [ val, val => val ] POPD (Y); POPD (X); PUSHD (X * Y); Divide reals [ val, val => val ] Normal B0 SUB_R Add reals POP (Y); POP (X); PUSH (X / Y); Double AF ADD_R Semantics POPD (Y); POPD (X); PUSHD (X / Y) Exponentiate real [ val, val => val ] Normal AE Param. POP (Y); POP (X); PUSH (X ** Y); Double Hex Mnemonic POP (Y); POPD (X); PUSHD (X ** Y); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: B4 Semantics Normal POP (X); PUSH (–X); Double Negate real NEG_R POPD (X); PUSHD (–X); [ val => val ] Absolute real value ABS_R Normal B3 Param. POP (X); PUSH (abs X); Double Hex Mnemonic 36 Datum/Date : Datum/Date: von/of 95 POPD (X); PUSHD (abs X); [ val => val ] d) TIME and DURATION operations Hex Mnemonic ADD_D Semantics Add time and duration Normal B5 Param. SUB_D SUB_T [ val, val => val ] POPD (D); POPD (T); PUSHD (T – D); Subtract times Normal B7 POPD (D); POPD (T); PUSHD (T + D); Subtract duration from time Normal B6 [ val, val => val ] [ val, val => val ] POPD (T2); POPD (T1); PUSHD (T1 – T2); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 37 Datum/Date : Datum/Date: von/of 95 e) SET operations These instructions perform operations on sets. A set is regarded as a packed array of bits (BOOLEAN). A distinction is made between 1–word and multiple–word sets: For 1–word sets the set value is directly manipulated via the Expression Stack like any numeric value. Multiple–word sets are manipulated via their addresses on the Expression Stack. Note that instructions that generate a multiple–word stack result implicitly allocate memory for the result and push the address of the result on the Expression Stack. Hex Mnemonic ADD_S Semantics Set union Multi Normal B8 Param. [ set, set => set ] POP (Y); POP (X); PUSH (X or Y); [ adr, adr, size => adr ] POP (L); POP (A2); POP (A1); PUSH (MP); MEMORY (MP..MP+L–1) := MEMORY(A1..A1+L–1) or MEMORY(A2..A2+L–1); MP := MP + L; –– This instruction implicitly allocates –– space in memory Set difference Normal SUB_S Multi B9 [ set, set => set ] POP (Y); POP (X); PUSH (X and not Y); [ adr, adr, size => adr ] POP (L); POP (A2); POP (A1); PUSH (MP); MEMORY (MP..MP+L–1) := MEMORY(A1..A1+L–1) and not MEMORY(A2..A2+L–1); MP := MP + L; –– This instruction implicitly allocates –– space in memory Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Hex Mnemonic MUL_S Semantics Set intersection Multi Normal BA Param. 38 Datum/Date : Datum/Date: von/of 95 [ set, set => set ] POP (Y); POP (Y); PUSH (X and Y); [ adr, adr, size => adr ] POP (L); POP (A2); POP (A1); PUSH (MP); MEMORY (MP..MP+L–1) := MEMORY(A1..A1+L–1) and MEMORY(A2..A2+L–1); MP := MP + L; –– This instruction implicitly allocates –– space in memory DIV_S Symmetric set difference Multi Normal BB [ set, set => set ] POP (Y); POP (X); PUSH (X xor Y); [ adr, adr, size => adr ] POP (L); POP (A2); POP (A1); PUSH (MP); MEMORY (MP..MP+L–1) := MEMORY(A1..A1+L–1) xor MEMORY(A2..A2+L–1); MP := MP + L; –– This instruction implicitly allocates –– space in memory INCL Include element in set Normal BC EXCL POP (N); POP (A); MEMORY(A + N/32)(N mod 32) := TRUE; Exclude element from set Normal BD [ adr, num => ] [ adr, num => ] POP (N); POP (A); MEMORY(A + N/32)(N mod 32) := FALSE; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 39 Datum/Date : Datum/Date: von/of 95 5.2.4.8 Comparison Instructions These instructions perform comparisons on operands on the Expression Stack. They push a boolean value as a result back on the Expression Stack. The multiple–word comparison instructions operate on data in the Memory pointed by addresses on the Expression Stack. a) general comparisons EQU Semantics Test equal [ val, val => bool ] Normal BE Param. POP (Y); POP (X); PUSH (X = Y); Double Hex Mnemonic POPD (Y); POPD (Y); PUSH (X = Y); [ val, val => bool ] Multi [ adr, adr, size => bool ] Test not equal Normal v [ a v , l a = l> b o o ] l POP (Y); POP (X); PUSH (X /= Y); Double NEQ POPD (Y); POPD (X); PUSH (X /= Y); [ val, val => bool ] [ adr, adr, size => bool ] Multi BF POP (L); POP (A2); POP (A1); PUSH (MEMORY(A1..A1+L–1) = MEMORY(A2..A2+L–1)); POP (L); POP (A2); POP (A1); PUSH (MEMORY(A1..A1+L–1) /= MEMORY(A2..A2+L–1)); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 40 Datum/Date : Datum/Date: von/of 95 b) INTEGER comparisons Hex Mnemonic LES_I Semantics Test less (integer) Normal C0 Param. GRT_I LEQ_I GEQ_I [ val, val => bool ] POP (Y); POP (X); PUSH (X <= Y); Test greater/equal (integer) Normal C3 [ val, val => bool ] POP (Y); POP (X); PUSH (X > Y); Test less/equal (integer) Normal C2 POP (Y); POP (X); PUSH (X < Y); Test greater (integer) Normal C1 [ val, val => bool ] [ val, val => bool ] POP (Y); POP (X); PUSH (X >= Y); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 41 Datum/Date : Datum/Date: von/of 95 c) UNSIGNED_INTEGER comparisons Hex Mnemonic LES_U Semantics Test less (unsigned) Normal C4 Param. GRT_U LEQ_U GEQ_U [ val, val => bool ] POP (Y); POP (X); PUSH (X <= Y); Test greater/equal (unsigned) Normal C7 [ val, val => bool ] POP (Y); POP (X); PUSH (X <= Y); Test less/equal (unsigned) Normal C6 POP (Y); POP (X); PUSH (X < Y); Test greater (unsigned) Normal C5 [ val, val => bool ] [ val, val => bool ] POP (Y); POP (X); PUSH (X >= Y); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 42 Datum/Date : Datum/Date: von/of 95 d) REAL comparisons CB LEQ_R GEQ_R Normal POP (Y); POP (X); PUSH (X < Y); Double [ val, val => bool ] POPD (Y); POPD (X); PUSH (X < Y); Normal [ val, val => bool ] POP (Y); POP (X); PUSH (X > Y); Double Test greater (real) POPD (Y); POPD (X); PUSH (X > Y); Test less/equal (real) Normal CA GRT_R Test less (real) POP (Y); POP (X); PUSH (X <= Y); Double C9 LES_R Semantics POPD (Y); POPD (X); PUSH (X <= Y); Test great./equ. (real) Normal C8 Param. POP (Y); POP (X); PUSH (X >= Y); Double Hex Mnemonic POPD (Y); POPD (X); PUSH (X >= Y); [ val, val => bool ] [ val, val => bool ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 43 Datum/Date : Datum/Date: von/of 95 e) TIME comparisons Hex Mnemonic LES_T Semantics Test less (time) Normal CC Param. GRT_T LEQ_T GEQ_T POPD (T2); POPD (T1); PUSH (T1 > T2); [ val, val => bool ] POPD (T2); POPD (T1); PUSH (T1 <= T2); Test greater/equal (time) Normal CF [ val, val => bool ] Test less/equal (time) Normal CE POPD (T2); POPD (T1); PUSH (T1 < T2); Test greater (time) Normal CD [ val, val => bool ] [ val, val => bool ] POPD (T2); POPD (T1); PUSH (T1 >= T2); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 44 Datum/Date : Datum/Date: von/of 95 f) SET comparisons These instructions perform comparisons on sets. 1–Word sets are manipulated directly via the Expression stack, multiple–word sets are manipulated indirectly via addresses on the Expression Stack. D2 TEST Normal [ set, set => bool ] POP (Y); POP (X); PUSH ((X and not Y) = (others => FALSE)); Multi [ adr, adr, size => bool ] POP (L); POP (A2); POP (A1); PUSH ((MEMORY(A1..A1+L–1) and not MEMORY(A2..A2+L–1)) = (others => FALSE)); Test set inclusion (right in left) Normal GEQ_S Test set inclusion (left in right) [ set, set => bool ] POP (Y); POP (X); PUSH ((Y and not X) = (others => FALSE)); Multi D1 LEQ_S Semantics [ adr, adr, size => bool ] POP (L); POP (X); PUSH ((MEMORY(A2..A2+L–1) and not MEMORY(A1..A1+L–1)) = (others => FALSE)); Test set membership [ num, set => bool ] POP (S); POP (N); Normal D0 Param. if N < 0 or N >= 32 then PUSH (FALSE); else PUSH (S(N)); end if; [ num, adr, len => bool ] POP (L); POP (A); POP (N); Multi Hex Mnemonic if N < 0 or N >= L * 32 then PUSH (FALSE); else PUSH (MEMORY(A + N/32)(N mod 32)); end if; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 45 Datum/Date : Datum/Date: von/of 95 g) STRING comparisons Hex Mnemonic LES_A Semantics Test less (ASCII) Normal D3 Param. GRT_A LEQ_A GEQ_A [ adr, adr => bool ] POP (A2); POP (A1); PUSH (STRING(A1) <= STRING(A2)); Test greater/equal (ASCII) Normal D6 [ adr, adr => bool ] POP (A2); POP (A1); PUSH (STRING(A1) > STRING(A2)); Test less/equal (ASCII) Normal D5 POP (A2); POP (A1); PUSH (STRING(A1) < STRING(A2)); Test greater (ASCII) Normal D4 [ adr, adr => bool ] [ adr, adr => bool ] POP (A2); POP (A1); PUSH (STRING(A1) >= STRING(A2)); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 46 Datum/Date : Datum/Date: von/of 95 5.2.4.9 BOOLEAN negation Hex Mnemonic Semantics Boolean NOT NEG Normal D7 Param. [ bool => bool ] POP (B); PUSH (not B); 5.2.4.10 Allocation Instructions These instructions allocate space in memory and free allocated space. Note that allocation and deallocation follow strict stack semantics. Hex Mnemonic ALLOC Semantics Allocate space in memory Normal D8 Param. FREE POP (L); PUSH (MP); MP := MP + L; Free allocated space in memory Normal D9 [ size => adr ] [ size => ] POP (L); MP := MP – L; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 47 Datum/Date : Datum/Date: von/of 95 5.2.4.11 Jump Instructions These instructions perform jumps to locations in the code frame. The target location is indicated relatively as a distance from the current PC. Conditional jumps test a condition (a boolean value) on the Expression Stack, the jump is performed if the condition is FALSE. Hex Mnemonic JUMP.b dist 1 signed Semantics Jump (short distance) Normal DA Param. JUMP.h dist 2 signed DC JUMP_C.b dist 1 signed PC := PC + dist; Jump (long distance) Normal DB [] [] PC := PC + dist; Conditional jump (short distance) [ bool => ] Normal POP (B); JUMP_C.h dist 2 signed Conditional jump (long distance) [ bool => ] POP (B); Normal DD if not B then PC := PC + dist; else PC := PC + 2; end if; if not B then PC := PC + dist; else PC := PC + 3; end if; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 48 Datum/Date : Datum/Date: von/of 95 5.2.4.12 Special Jump Instructions These instructions implement the UCL short–circuit OR (”|”) and AND (”&”) operations. Hex Mnemonic DE JUMP_T.b Param. dist 1 unsigned Semantics Jump if true (OR) [ bool => (bool) ] Normal POP (B); JUMP_F.b dist 1 unsigned Jump if false (AND) [ bool => (bool) ] POP (B); Normal DF if B then PUSH (B); PC := PC + dist; else PC := PC + 2; end if; if not B then PUSH (B); PC := PC + dist; else PC := PC + 2; end if; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 49 Datum/Date : Datum/Date: von/of 95 5.2.4.13 Iterative Instructions These instructions implement the UCL FOR loop. A FOR loop is bracketed by an ITER/NEXT instruction pair that communicate via the Expression Stack. Hex Mnemonic E0 ITER Param. dist 2 unsigned Semantics Iterative loop prolog [ adr, first, last, step => (adr, first, last, step, label) ] Normal S L F A NEXT STACK(SP); STACK(SP–1); STACK(SP–2); STACK(SP–3); –– –– –– –– step last loop value first loop value addr. of loop variable if (S > 0 and then F > L) or (S < 0 and then F < L) then SP := SP – 4; –– pop 4 stack items PC := PC + dist; –– exit from loop else MEMORY(A) := F; –– init. loop variable PC := PC + 3; PUSH (PC); –– loop entry label end if; Iterative loop epilog [ adr, first, last, step, label => (adr, first, last, step, label) ] S := STACK(SP–1); L := STACK(SP–2); A := STACK(SP–4); –– step –– last loop value –– addr. of loop variable MEMORY(A) := MEMORY(A) + S; –– inc. loop var Normal E1 := := := := if (S > (S < SP := PC := else PC := end if; 0 and MEMORY(A) 0 and MEMORY(A) SP – 5; –– PC + 1; –– STACK(SP); > L) or < L) then pop 5 stack items leave loop –– next loop cycle Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 50 Datum/Date : Datum/Date: von/of 95 5.2.4.14 Switch Instructions These instructions implement the UCL CASE statement. Two alternative instructions perform the jump to the according case branch via a jump table and a search table, respectively. Hex Mnemonic E2 SWITCH Param. n 2 unsigned Semantics Switch to CASE branch via jump table [ val => label ] Z := VALUE (CODE(PC+3..PC+4));–– exit label E := VALUE (CODE(PC+5..PC+6));–– ELSE branch T := PC + 7; –– Pointer to jump table Normal POP (X); PUSH (PC + Z); if X < 0 or X > n then PC := PC + E; –– jump to ELSE else I := T + 2*X; –– jump tab. index PC := PC + VALUE (CODE(I..I+1)); –– jump end if; –– –– –– –– –– –– SWITCH_X n 2 unsigned SWITCH is followed by a jump table: halfword 1: halfword 2: distance to end of case distance to ELSE part halfwords 3 .. 3+n: distances to the branches Switch to CASE branch via search table [ val => label ] Z := VALUE (CODE(PC+3..PC+4));–– exit label E := VALUE (CODE(PC+5..PC+6));–– ELSE branch POP (X); PUSH (PC + Z); –– case selector –– push exit label D := {distance to branch searched in table} Normal E3 –– case selector –– push exit label if D = 0 then PC := PC + E; else PC := PC + D; end if; –– –– –– –– –– –– –– –– –– –– –– –– not found –– jump to ELSE –– jump to branch SWITCH_X is followed by a search table: halfword: distance to end of case halfword: distance to ELSE part range 1 .. range n (Each ”range” consists of: o lower bound of the range (word) o upper bound of the range (word) o distance to branch (halfword) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: E4 LEAVE Param. Semantics Exit from SWITCH Normal Hex Mnemonic 51 Datum/Date : Datum/Date: von/of 95 POP (PC); [ label => ] –– jump to end of case statement Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 52 Datum/Date : Datum/Date: von/of 95 5.2.4.15 Procedure/Function Call Instructions These instructions perform procedure/function calls, entry and return operations. Note that the ENTER instruction unstacks the actual parameters and moves them to locations in the Memory. Hex Mnemonic CALL.b proc 1 unsigned Semantics Call procedure/function Normal E5 Param. CALL_E lib 1 unsigned proc 1 unsigned ENTER par 1 unsigned [] MEMORY(MP) := GP; –– MEMORY(MP+1) := FP; –– MEMORY(MP+2) := –(PC+3);–– MP := MP + 3; FP := MP; –– GP := BASE (lib); –– CP := MEMORY(GP–2); –– PC := PROC (proc); –– save global link save dynamic link save return addr. mark stack frame new global frame new code frame jump dat 1 unsigned if not MEMORY(GP–3) then MEMORY(GP–3) := TRUE; else PC := – MEMORY (FP–1); MP := FP – 3; GP := MEMORY (MP); FP := MEMORY (MP+1); CP := MEMORY (GP–2); end if; [] –– if not yet init. –– mark as init. –– –– return from external call Enter procedure/function Normal E8 –– mark stack frame –– jump Enter library initialization part INIT Normal E7 –– save dynamic link –– save return addr. Call external procedure/function Normal E6 MEMORY (MP) := FP; MEMORY (MP+1) := PC+2; MP := MP + 2; FP := MP; PC := PROC (proc); [] [ val, ..., val => ] –– unstack parameters: MEMORY(MP..MP+par–1) := STACK(SP–par+1..SP); SP := SP – par; –– allocate space for local data: MP := MP + par + dat; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: E9 RTN Param. Semantics Return from procedure/function [] PC := MEMORY (FP–1); Normal Hex Mnemonic 53 Datum/Date : Datum/Date: von/of 95 if PC > MP := FP := else MP := GP := FP := CP := PC := end if; 0 THEN FP – 2; MEMORY(MP); –– local call –– external call FP – 3; MEMORY(MP); MEMORY(MP+1); MEMORY(GP–2); –PC; Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 54 Datum/Date : Datum/Date: von/of 95 5.2.4.16 Conversion Instructions ED ROUND_I ROUND_U Normal POP (X); PUSH (TRUNC(X)); Double POPD (X); PUSH (TRUNC(X)); Normal POP (X); PUSH (TRUNC(X)); Double Truncate real to unsigned integer POPD (X); PUSH (TRUNC(X)); Round real to integer Normal EC TRUNC_U Truncate real to integer POP (X); PUSH (ROUND(X)); Double EB TRUNC_I Semantics POPD (X); PUSH (ROUND(X)); Round real to unsigned integer Normal EA Param. POP (X); PUSH (ROUND(X)); Double Hex Mnemonic POPD (X); PUSH (ROUND(X)); [ val => val ] [ val => val ] [ val => val ] [ val => val ] Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: EF REAL_U SHORT_R Normal POP (X); PUSH (FLOAT(X)); Double Convert integer to real POP (X); PUSHD (FLOAT(X)); Convert unsigend integer to real POP (X); PUSH (FLOAT(X)); POP (X); PUSHD (FLOAT(X)); Convert long real to real Normal F0 REAL_I Semantics Normal EE Param. Double Hex Mnemonic LONG_R [ val => val ] [ val => val ] [ val => val ] POPD (X); PUSH (SHORT(X)); Convert real to long real Normal F1 55 Datum/Date : Datum/Date: von/of 95 [ val => val ] POP (X); PUSHD (LONG(X)); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: type 1 unsigned Convert value to string [ val, width, aft, exp => adr, size ] POP POP POP POP Normal STR Semantics (EXP); (AFT); (WIDTH); (X); declare S : constant STRING := IMAGE (X, type, WIDTH, AFT, EXP); L : constant NATURAL := (S’LENGTH + 3) / 4; begin PUSH (MP); MEMORY (MP) := S’LENGTH; MEMORY (MP+1 .. MP+L) := S; MP := MP + 1 + L; PUSH (L + 1); end; [ val, width, aft, exp => adr, size ] POP POP POP POPD Double F2 Param. (EXP); (AFT); (WIDTH); (X); declare S : constant STRING := IMAGED (X, type, WIDTH, AFT, EXP); L : constant NATURAL := (S’LENGTH + 3) / 4; begin PUSH (MP); MEMORY (MP) := S’LENGTH; MEMORY (MP+1 .. MP+L) := S; MP := MP + 1 + L; PUSH (L + 1); end; [ adr, width, aft, exp => adr, size ] POP POP POP POP Multi Hex Mnemonic 56 Datum/Date : Datum/Date: von/of 95 (EXP); (AFT); (WIDTH); (A); declare S : constant STRING := IMAGEM (A, type, WIDTH, AFT, EXP); L : constant NATURAL := (S’LENGTH + 3) / 4; begin PUSH (MP); MEMORY (MP) := S’LENGTH; MEMORY (MP+1 .. MP+L) := S; MP := MP + 1 + L; PUSH (L + 1); end; Note: This instruction implicitly allocates space in memory. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: type 1 unsigned Convert string to value, or check string against type [ adr, check => val ] POP (C); POP (A); Normal VAL Semantics Double F3 Param. if C then PUSH (VALID (STRING (A), type)); else PUSH (VALUE (STRING (A), type)); end if; [ adr => val ] POP (A); PUSHD (VALUED (STRING (A), type)); [ adr => adr ] POP (A); Multi Hex Mnemonic 57 Datum/Date : Datum/Date: von/of 95 declare V : constant WORD_ARRAY := VALUEM (STRING (A), type); begin PUSH (MP); MEMORY (MP) := S’LENGTH; MEMORY (MP+1 .. MP+V’LENGTH) := V; MP := MP + V’LENGTH; end; –– This instruction implicitly allocates –– space in memory. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 58 Datum/Date : Datum/Date: von/of 95 5.2.4.17 System Instructions These instructions perform different system specific operations. F4 SYS Param. lib 1 unsigned proc 1 unsigned Semantics System call Normal Hex Mnemonic [] SYSTEM (lib, proc); F5 DOUBLE Interpret next instruction as double word instruction [] F6 MULTI Interpret next instruction as multiple word instruction [] F7 READ Read DB end item value Normal Double [ sid => val ] POP (SID); READ (SID, type, X); PUSH (X); POP (SID); READD (SID, type, X); PUSHD (X); Multi type 1 unsigned POP (L) POP (SID); PUSH (MP); READM (SID, type, MP); MP := MP + L; [ sid => val ] [ sid, size => adr ] –– This instruction implicitly allocates –– space in memory Write DB end item value [ sid, val => ] Normal type 1 unsigned POP (X); POP (SID); WRITE (SID, type, X); Double WRITE POPD (X); POP (SID); WRITED (SID, type, X); [ sid, val => ] [ sid, adr, size => ] Multi F8 POP (L); POP (A); POP (SID); WRITEM (SID, type, A); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Hex Mnemonic Semantics Check integer range n .. m CHECK_I Normal F9 Param. FA 59 Datum/Date : Datum/Date: von/of 95 [ val, min, max => val ] POP (Y); POP (X); if STACK(SP) < X or STACK(SP) > Y then TRAP (range_error); end if; Check range 0 .. m CHECK_0 [ val, max => val ] Normal POP (X); Check unsigned range n .. m CHECK_U Normal FB [ val, min, max => val ] POP (Y); POP (X); if STACK(SP) < X or STACK(SP) > Y then TRAP (range_error); end if; Check real range n .. m CHECK_R Normal FC if STACK(SP) < 0 or STACK(SP) > X then TRAP (range_error); end if; [ val, min, max => val ] POP (Y); POP (X); if STACK(SP) < X or STACK(SP) > Y then TRAP (range_error); end if; Double POPD (Y); POPD (X); ERROR err 1 unsigned Runtime error trap Normal FD HALT [] ERROR (err); Stop program and return completion code Normal FE if STACK(SP–1..SP) < X or STACK(SP–1..SP) > Y then TRAP (range_error); end if; [ code => ] POP (X); HALT (X); Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 60 Datum/Date : Datum/Date: von/of 95 5.2.4.18 No–operation Instruction This instruction does not perform any operation. FF NOP Param. Semantics No operation all modes Hex Mnemonic –– no operation Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 61 Datum/Date : Datum/Date: von/of 95 5.3 Sample AP and Corresponding I–Code This example shows the translation of the following AP into I–code. For an example of the generated Debug Table, see 8. Source code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 procedure Example; import \SYSTEM\IO_Library; –– system library (Get/Put procedures) variable Sum: INTEGER; variable N: INTEGER; –– global address 0 –– global address 1 procedure Add (X: INTEGER); begin Sum := Sum + X; INC (N); end Add; –– subprogram 1 function Mean: INTEGER; begin if N = 0 then return 0; else return Sum / N; end if; end Mean; –– subprogram 2 begin Sum := 0; N := 0; for I := 1 to 10 do Add (I); end for; Put_String (”Mean value = ”); Put_Integer (Mean); New_Line; end Example; –– initialize counters –– I implicitly on global address 2 –– local procedure call –– subprogram 6 from system library –– subprogram 7 from system library –– subprogram 9 from system library Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 62 Datum/Date : Datum/Date: von/of 95 I–code in assembly language: This is the generated I–Code in symbolic (assembly) form. The binary code is given as comments in hexadecimal form (on the right side after the semicolon). .PROCEDURE EXAMPLE .IMPORT .DATA ; Size: 0 6 .CODE .ENTRY .LINE .LINE .LINE .LINE .ENTRY .LINE .LINE .LINE L1: .LINE ; Size: 65 P1 10 ENTER 11 LOAD_G.0 LOAD_L.0 ADD_I STOR_G.0 12 LOAD_G.1 LOAD_C.1 ADD_I STOR_G.1 13 RTN 21 LOAD_G.0 LOAD_G.1 DIV_I RTN PC Code dump ; 6 1, 3 ; 6: E8 01 03 ; ; ; ; 9: 10: 11: 12: 20 10 A0 50 ; ; ; ; 13: 14: 15: 16: 21 01 A0 51 ; 17: E9 0, 2 ; 18: E8 00 02 L1 ; ; ; ; 21: 22: 23: 24: ; ; 27: 00 28: E9 ; ; ; ; 29: 30: 31: 32: P2 17 ENTER 18 LOAD_G.1 LOAD_C.0 EQU JUMP_C.h 19 LOAD_C.0 RTN ; ; 18 ; 5 21 00 BE DD 00 05 20 21 A3 E9 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: .MAIN .LINE .LINE .LINE .LINE L2: .LINE .LINE .LINE .LINE ; 33 27 LOAD_C.0 STOR_G.0 28 LOAD_C.0 STOR_G.1 30 LOAD_A_G.b LOAD_C.1 LOAD_C.10 LOAD_C.1 ITER 31 LOAD_G.2 CALL.1 NEXT 34 LOAD_A_T.b LOAD_C.13 LOAD_C.0 SYS 35 CALL.2 LOAD_C.1 SYS 36 SYS 37 LOAD_C.0 HALT ; ; 33: 00 34: 50 ; ; 35: 00 36: 51 ; ; ; ; ; 37: 39: 40: 41: 42: ; ; ; 45: 22 46: 71 47: E1 255, 6 ; ; ; ; 48: 50: 51: 52: 255, 7 ; ; ; 55: 72 56: 01 57: F4 FF 07 255, 9 ; 60: F4 FF 09 ; ; 63: 00 64: FE 2 L2 ; 6 D1 ; 0 .CONSTANT D1: 63 Datum/Date : Datum/Date: von/of 95 13, 1298489710, 544629100, 1969561661, 538976288 92 00 0D 00 F4 FF 06 ; Size: 5 ; ; ; ; ; ; Library relocation list: .VERSION ” 3/–” 8E 02 01 0A 01 E0 00 06 0000000D 4D65616E 2076616C 7565203D 20202020 |....| |Mean| | val| |ue =| | | Size: 0 ; Size: 1 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: ; Source reference list: ; PC LINE ; 6 10 ; 9 11 ; 13 12 ; 17 13 ; 18 17 ; 21 18 ; 27 19 ; 29 21 ; 33 27 ; 35 28 ; 37 30 ; 45 31 ; 48 34 ; 55 35 ; 60 36 ; 63 37 64 Datum/Date : Datum/Date: von/of 95 Size: 16 .END Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 65 Datum/Date : Datum/Date: von/of 95 6 Runtime Errors The runtime errors that may occur in an I–Code interpreter are defined by the Ada package Runtime_Errors (see chapter 9) in terms of an Ada enumeration type, together with functions converting between the enmeration values and their textual and machine representation. This package shall be used by all software implementing I–Code runtime functionality. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Datum/Date : Datum/Date: von/of 95 66 7 Parameter Encoding When parameter lists are to be transferred via the network (e.g. for activation of an AP, or remote invocation of a library procedure/function) they must be encoded in a serial stream of words. This is referred to as external encoding. When parameter lists of parameterized pathnames are kept in the memory of the stack machine, they are encoded in an analogous form. This is referred to as internal encoding. Both external and internal encoding are based on the same encoding scheme. Encoded parameter lists are in network (i. e. big endian) format. 7.1 Minimal and Extended Parameter Encoding There are two forms of parameter encoding: • Minimal encoding encodes the parameter values enhanced with rudimentary type class information. This is sufficient to decode the list and treat parameter values as uninterpreted word streams, e. g. in an I–Code interpreter. For the internal encoding scheme there is only a minimal form. • Extended encoding adds name and type information to the encoded list and, in addition to minimal encoding, allows to extract parameter names and values in readable form. The extension part is an optional addition to the minimal encoding part. The two forms are depicted below. Each of the single parts is enclosed by a header word containing the number of following words and an end marker word containing 0. The header word is an offset to the end marker. Minimal encoding: encoded values + type class information for each parameter Size in words par. 1 ... par. 3 par. 2 par. n 0 Extended encoding: Size in words values + type classes 0 Size in words name + type associations minimal encoding part Figure 7.1–1. 0 Size in words type definitions 0 extension parts Minimal and extended encoding Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 67 Datum/Date : Datum/Date: von/of 95 7.2 Type References Whenever concrete UCL/HLCL types are referenced within an encoded parameter list, this reference is a number encoded in one word. Predefined types are numbered 1 – 31, as shown in the picture. User–defined types may be defined within the encoded parameter list, they are numbered starting at 32. Type references to predefined types 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 undefined type string of Character statecode Integer Real Boolean Bitset Character Word pathname Time Duration Completion_Code pathname.* Pulse Burst_Pulse Unsigned_Integer Long_Real Byte Long_Word string of Byte (subitem pathname, CSS specific type) (CSS specific type) (CSS specific type) reserved pathname() (parameterized pathname) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 68 Datum/Date : Datum/Date: von/of 95 7.3 Minimal Encoding Part 7.3.1 Parameter Modes and Type Classes Parameters are classified by mode and type. This classification is coded in the parameter class word, with the mode in the upper halfword and the type in the lower halfword. Mode 2 type 1 IN A value is passed into the called module. type 0 OUT A value is passed out of the called module. type The parameter mode defines the passing and access mechanism. IN OUT A value is passed into and out of the called module. Type class mode 1 1–word scalar type (INTEGER, REAL, BOOLEAN, BITSET, WORD, ...) Item is exactly one 32–bit word. Sets that occupy one word or less are classified here, too. mode 2 2–word scalar type (LONG_REAL, TIME, STATECODE, ...) Item is exactly two 32–bit words. mode 3 fixed–size string type Item is one component consisting of one or more words representing a string. mode 4 fixed–size structured type (array, record, set) Item is one component consisting of zero or more words representing an array, record or set. mode 5 open string type (open string parameter) Item is one component consisting of 1 or more words representing a string. mode 6 open structured type (open array parameter) Item is one component consisting of zero, one or more words representing an array. mode Parameters may belong to the following type classes. 7 parameterized pathname (pathname( )) Item is a database end item with parameters (AP, stimulus, ...). Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 69 Datum/Date : Datum/Date: von/of 95 7.3.2 Value Encoding Part 7.3.2.1 External Scheme The following defines the external parameter encoding scheme. The parameter stream is prefixed with the size of the stream in words, then follow the single parameters, each encoded as shown in the picture, and a null word terminating the stream. The No. of words indication counts the number of data words only. The Upper bound indication for open strings and structures is the upper bound according to the UCL view. The Type indication is a reference to a predefined type (see 7.2). 1–word scalar mode 2–word scalar SID Word 1 Word 2 Word 3 ... Word n mode fixed string No. of words 6 No. of words Upper bound Word 1 Word 2 Word 3 ... Word n mode fixed structure 7 5 No. of words Upper bound Word 1 Word 2 Word 3 ... Word n mode open string Parameter n 4 No. of words Word 1 Word 2 Word 3 ... Word n mode open structure ... Parameter 2 3 No. of words Word 1 Word 2 Word 3 ... Word n mode parmeterized pathname Parameter 1 2 Type Word 1 Word 2 mode Size in words 1 Type Word 1 Parameter type class 0 Words 1 .. n are the parameter list of the pathname, encoded according to these rules. data words Figure 7.3.2.1–1. External Parameter Encoding Scheme Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 70 Datum/Date : Datum/Date: von/of 95 7.3.2.2 Internal Scheme The following defines the representation of a parameterized pathname item in the memory of the stack machine, including its actual parameter list. On the expression stack a parameterized item is represented by an address pointing to the following data structure in memory. The item is represented by its SID, the size of its actual parameter list, and the parameter list itself, which is encoded in the internal encoding scheme. The internal encoding scheme is essentially identical to the external scheme, with the only difference that for non–scalar parameters the actual data words are replaced by an address pointing to the location in memory where the data words are stored. Note that the Size of list in this case denotes the true size of the encoded parameter list with addresses to structures instead of the actual structured values while the Size in words, nevertheless, counts the data words (and not the addresses) for the size of its following list, like in the external encoding. pathname SID Encoded list ... mode 7 No. of words SID Ad– dress mode 6 No. of words Upper bound Ad– dress mode 5 No. of words Upper bound Ad– dress mode 4 No. of words Ad– dress mode 3 No. of words Ad– dress mode 2 Type Word 1 mode Parameter 2 1 Type Word 1 mode Parameter 1 2 Type Ad– dress Type Ad– dress parmeterized pathname open structure open string fixed structure fixed string 2–word scalar 1–word scalar 2–word scalar 1–word scalar mode Size in words Size of list Parameter n 0 Address of data instead of the data itself. Word 2 for IN parameters for OUT and IN OUT parameters Parameter type class Figure 7.3.2.2–2. 1 data words Internal Parameter Enoding Scheme Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 71 Datum/Date : Datum/Date: von/of 95 7.4 Extension Parts 7.4.1 String Encoding Whenever textual components (names, string constants etc.) are to be encoded, they take the form shown in the picture. The string is prefixed with its length (number of characters) and encodes 4 characters per word. It is padded with blanks to fill a full word, if the length is not a multiple of 4. Length Word 1 Word 2 Word 3 ... Word n name, 4 characters per word, padded with blanks to full word Name length Figure 7.4.1–1. String encoding 7.4.2 Parameter Definition Part This section associates each parameter with a name and a type and, in the case of parameterized parameters, with a parameter list. The parameter stream is prefixed with the size of the stream in words, then for each parameter the type and name (and possibly the extension parts of its parameter list) are given, and a null word terminates the stream. The type is a number that references either a UCL/HLCL predefined type (a number in the range 1 – 31, see 7.2) or a user–declared type defined in the type definition part (a number > 31, see 7.4.3). The name is encoded as a string (see 7.4.1) in upper–case letters. Size in words Parameter 1 31 Name Type Name ... Parameter 2 Parameter definition part Parameter n Type definition part 0 parameterized pathname simple parameter name encoded as a string in upper–case letters Figure 7.4.2–1. Parameter definition part Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 72 Datum/Date : Datum/Date: von/of 95 7.4.3 Type Definition Part This section defines user–declared types, in addition to the predefined UCL/HLCL types (see 7.2). Types defined here are numbered in the order of their definition, starting at 32. Size in words Type 32 ... Type 33 record type 1 9 Component list statecode set type 1 8 Statecode list No. of words Statecode 1 Base type Statecode 2 Statecodes are coded in two words each, with upper–case letters, padded with blanks to 8 characters. ... Statecode n open array type 1 6 Element Upper bound type Upper bound is 0 .. n – 1 1 5 Element Upper bound type Upper bound is 1 .. n 1 4 Element Length type 1 3 Element Max type length open string type fixed array type fixed string type enumeration type 1 2 No. of words unitized type 1 1 Length is 1 .. n Max length is 1 .. n Literals are identifiers encoded as strings, with upper–case letters. List of literals Literal 1 Base type 0 Base type is a discrete 1–word scalar type 1 7 Max 0 See details on next page discrete set type Min Type n Literal 2 Unit text ... Literal n Unit name 0 The unit is encoded in its textual representation as a string, together with its name, if any. Figure 7.4.3–1. Type definition part, simple types Note that the structure indicators in the picture consist of two parts, each encoded in a halfword. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 73 Datum/Date : Datum/Date: von/of 95 Record type definitions record type 1 9 No. of words Type 2 1 Type Component list Component 1 ... Component 2 Component n 0 Name A component is either a field or a variant part. Variants Tag field Name No. of words 2 2 Selector list No. of words Selector 1 Variant 1 Variant 2 ... Variant n Component list like above (recursive definition) Component list Selector 2 Min Max Statecode ... Selector n 0 0 A selector is either a range of values or a statecode, depending on the tag field type. Figure 7.4.3–2. Type definition part, record type Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 74 Datum/Date : Datum/Date: von/of 95 7.5 Example (call of a libr. procedure, minimal external scheme) Declaration (UCL): procedure PROC (in in out in in in in out in in in NUMBER : SWITCH : DOUBLE : STATE : TEXT_1 : TEXT_2 : ARRAY_1: ARRAY_2: PATH_1 : PATH_2 : INTEGER; BOOLEAN; LONG_REAL; statecode; STRING_9; string; REAL_ARRAY_4; array of REAL; pathname; pathname() ); -- 1–word scalar -- 1–word scalar -- 2–word scalar -- 2–word scalar -- fix–size string -- open string -- fix–size array -- open array -- simple pathname -- parameterized pathname Call (HLCL): PROC NUMBER : SWITCH : DOUBLE : STATE : TEXT_1 : TEXT_2 : ARRAY_1: ARRAY_2: PATH_1 : PATH_2 : 123, TRUE, some variable $MEDIUM, ”ABCDEFGHI”, ”ABCDEFGHI”, some variable, (1.0, 2.0, 3.0, 4.0), \some_path\X, \some_path\Y (3.14) -- 1–word scalar -- 1–word scalar -- 2–word scalar -- 2–word scalar -- fix–size string -- open string -- fix–size array -- open array -- simple pathname -- parameterized pathname Encoded parameter list: size of list 52 NUMBER 0 1 INTEGER 123 SWITCH 0 1 BOOLEAN true DOUBLE 1 2 LONG_REAL 0 STATE 0 2 STATECODE TEXT_1 0 3 4 9 TEXT_2 0 5 4 9 9 ARRAY_1 2 4 4 1.0 2.0 3.0 4.0 ARRAY_2 0 6 4 3 1.0 2.0 3.0 4.0 PATH_1 0 1 PATHNAME 17535 PATH_2 0 7 5 17536 4 1 REAL 3.14 end of list Figure 7.3.1–1. 0 MEDI UM A B CD E F GH I A B CD E F GH I 0 0 Encoded Parameter List Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 75 Datum/Date : Datum/Date: von/of 95 7.6 Stack Machine Representation of AP Parameters Within the memory of the Stack Machine the parameters are represented as shown in the picture: AP global data frame GP 0 1 2 3 4 5 6 1–word scalar 2–word scalar value AP parameters are treated as the first n global variables. This is analogous to local procedure parameters. Addresses are obtained by allocation of space in memory for non–scalars. value fixed structure address address open structure Non–scalar parameters are allocated space in memory and referenced via their address. upper bound param. pathname address ... ... contents of fixed structure These are the n data words contents of open structure These are the n data words contents of parameterized pathname This is the SID, the No. of data words and the encoded parameter list like defined here, but with addresses to structured data, instead of the data words themselves. data parts of parameterized pathname MP Figure 7.3.1–1. ... Global Data Frame Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 76 Datum/Date : Datum/Date: von/of 95 8 Symbol Table and Debug Table 8.1 Functional Description In order to support separate compilation and symbolic debugging, the UCL compiler generates two kinds of tables: a Symbol Table and a Debug Table. These tables are stored in the Mission Database under the respective Library or Automated Procedure entry. Both kinds of tables exhibit a common format and structure (with some minor differences). A Symbol Table is generated for each UCL unit that can be imported in other units, this comprises Automated Procedures (APs), library specification and any Parameterized Items. It contains the public (exported) declarations of the unit in an internal binary format. It basically enables the compiler to perform type checking across library boundaries. The Symbol Table is used by the compiler during compilation of the unit’s body or one of its clients (i.e. all APs and/or other units using that unit), in order to import the declarations. A Debug Table, on the other hand, is generated for each UCL main program (AP) or Library body. It is basically identical to the Symbol Table, except that it additionally contains information required by the I–Code Interpreter/Debugger for symbolic debugging, e.g. references to source line numbers and procedure/function scope information. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 77 Datum/Date : Datum/Date: von/of 95 8.2 Structure of the Symbol / Debug Table A Symbol Table or a Debug Table consists of a header followed by a possibly empty list of imports and sections. It is terminated by a suffix. A section describes the contents of a main program, subprogram (i.e. procedure or function) or library (that is, a section corresponds to a visibility scope in UCL). A section contains objects, types and components and is terminated by a scope identification. An object corresponds to a named declaration in UCL. Each type definition is represented by a type item. Some objects and types may also contain references to components (e.g. parameters or fields). This is depicted in Fig. 8.2. O2 C C C O1 T T T Legend O = object T = type C = component Figure 8.2 C C Elements of Symbol Table / Debug Table section Items may reference (or point to) other items. Items generation is such that all references can be resolved without ”forward references”; this means that the item being referenced must occur before all other items referencing it. A referenced item may in turn reference another item. This may lead to multiply nested reference chains. Items which may be referenced are numbered sequentially, in order of creation. The generated reference number is then used by other items as ”reference pointer”. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 78 Datum/Date : Datum/Date: von/of 95 8.3 Layout Internally, a Symbol Table or a Debug Table is a sequence of bytes. Groups of bytes build ”items”. The items appear according to the following syntax expressed using EBNF (Extended Backus–Naur Form) with the following extension: If the name of any syntactic category starts with an italicized part, it is equivalent to the category name without the italicized part. The italicized part is intended to convey some semantic information. For example Line_Number and Address_Number are both equivalent to Number alone. An item is introduced by an identifier and followed by a sub–identifier, that determines the kind of the item. Identifiers and sub–identifiers are bytes. They are represented by a symbolic keyword in bold face in the EBNF. In the following table, their numerical values are given in hexadecimal: TAB SYMBOL DEBUG CTL IMPORT SCOPE LOOP END TYP ENUM PARAM IDENTITY RANGE UNIT SET STRING DYN_STRING ARRAY DYN_ARRAY RECORD STATECODE PATHNAME SUBITEM_PATHNAME IMPORT INHERITED UNION CMP IN_PAR OUT_PAR IN_OUT_PAR FIELD ENUM_CONST STATECODE DB_ITEM DB_SUBITEM TYPE OBJ PAR VAR CONST TYPE PROC FUNC UNIT ALIAS 02 A TAB (table) identifier introduces each table. 00 01 F0 00 01 02 03 F1 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F 10 F2 00 01 02 03 04 05 06 07 08 F3 00 01 02 03 04 05 06 07 CTL (control) identifiers are used to control the reading of Symbol and Debug Tables. They are used to group sections that belong together. TYP (type) identifiers are used to reflect type definitions in a Symbol or Debug Table. CMP (component) identifiers represent components of types and objects, e.g. record fields, formal parameters and enumeration constants. OBJ (object) identifiers represent named UCL declarations, like variables, constants, types etc. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 79 Datum/Date : Datum/Date: von/of 95 8.4 Table Framework Symbol_Table = TAB ( SYMBOL | DEBUG ) Version_String { Import } { Section } Suffix. Symbol Tables and Debug Tables start with an appropriate header item, followed by lists of Import and Section items and terminated by a Suffix item. Version_String 4–character version string of the form “nn/x” where nn is the version number (the first n possibly being a space character), and x is either a hyphen (’–’) for the first issue, or a capital letter A, B, C, ... for later issues. It refers to an issue of this Reference Manual. Import = CTL IMPORT Library_Name, SID_Word. An Import item serves as reference to an imported UCL item, e. g. library. Library_Name Name of the imported item SID_Word ID of the imported item Suffix = CTL END Datasize_Byte, Subprogram_Byte. The Suffix item is written at the end of each Symbol or Debug Table. Datasize_Byte the highest address used in the global data of the generated I–Code Subprogram_Byte the highest subprogram number used in the generated I–Code Section = { Object | Type } Scope. A Section item describes the contents of a main program, subprogram (i.e. procedure or function) or library (that is, a section corresponds to a visibility scope in UCL). Each section is terminated by a scope identification. Scope = General_Scope | Loop_Scope. General_Scope = CTL SCOPE Subprogram_Byte. A General_Scope item is written for each procedure, function and library. All Object and Type items preceding this item belong to this scope. Subprogram_Byte number of the subprogram, or 0 for the library body or AP body. Loop_Scope = CTL LOOP Position_Word. A Loop_Scope item is written for each for loop. The object item directly preceding this item is the loop counter variable. Position_Word PC of the corresponding ITER instruction within the I–Code. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 80 Datum/Date : Datum/Date: von/of 95 8.5 Objects Object = [ Unit_Object | Procedure_Object | Function_Object | Constant_Object | Type_Object | Variable_Object | Parameter_Object | Alias_Object ]. For each named declaration, an Object item is output in the Symbol or Debug Table. Unit_Object = OBJ UNIT Object_Name, Unit. For each unit declaration, a Unit_Object item is output. Object_Name the name of the new unit Unit the unit definition Procedure_Object = { Parameter } OBJ PROC Object_Name, Body_Byte, Line_Word, Column_Word, Body_Line_Word, Body_Column_Word, Subprogram_Byte, Guarded_Byte. For each procedure, a Procedure_Object item is output. All Parameter items preceding this item belong to this procedure. Object_Name the name of the procedure Body_Byte 0 = the subprogram is defined in a library specification and implemented in the body 1 = the subprogram is declared in the body only Line_Word line number of the subprogram declaration within the library specification Column_Word column number of the subprogram declaration within the library specification Body_Line_Word line number of the subprogram declaration within the body Body_Column_Word column number of the subprogram declaration within the body Subprogram_Byte the index number of the subprogram (starting at 1) Guarded_Byte an indication whether the procedure is guarded (1) or not (0) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Function_Object = 81 Datum/Date : Datum/Date: von/of 95 { Parameter } OBJ FUNC Object_Name, Body_Byte, Line_Word, Column_Word, Body_Line_Word, Body_Column_Word, Type_Ref, Subprogram_Byte, Guarded_Byte. For each function, a Function_Object item is output. All Parameter items preceding this item belong to this function. Object_Name the name of the function Body_Byte 0 = the subprogram is defined in a library specification and implemented in the body 1 = the subprogram is declared in the body only Line_Word line number of the subprogram declaration within the library specification Column_Word column number of the subprogram declaration within the library specification Body_Line_Word line number of the subprogram declaration within the body Body_Column_Word column number of the subprogram declaration within the body Type_Ref reference to the type of the value returned by the function Subprogram_Byte the index number of the subprogram (starting at 1) Guarded_Byte an indication whether the function is guarded (1) or not (0) Parameter = In_Parameter | Out_Parameter | In_Out_Parameter. For each parameter of a procedure or function, a Parameter item is output. It is different for each parameter mode (IN, OUT or IN OUT). In_Parameter = CMP IN_PAR Parameter_Name, Type_Ref, Guarded_Byte, Default_Value. For each IN parameter of a subprogram, an In_Parameter item is output. Parameter_Name the name of the parameter Type_Ref reference to the type of the parameter Guarded_Byte an indication whether the parameter is guarded (1) or not (0) Default_Value the default value, 0 if no default value given Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Out_Parameter = 82 Datum/Date : Datum/Date: von/of 95 CMP OUT_PAR Parameter_Name, Type_Ref, Guarded_Byte. For each OUT parameter of a subprogram, an Out_Parameter item is output. Parameter_Name the name of the parameter Type_Ref reference to the type of the parameter Guarded_Byte an indication whether the parameter is guarded (1) or not (0) In_Out_Parameter = CMP IN_OUT_PAR Parameter_Name, Type_Ref, Guarded_Byte. For each IN OUT parameter of a subprogram, an In_Out_Parameter item is output. Parameter_Name the name of the parameter Type_Ref reference to the type of the parameter Guarded_Byte an indication whether the parameter is guarded (1) or not (0) Constant_Object = OBJ CONST Object_Name, Body_Byte, Line_Word, Column_Word, Type_Ref, Value. For each constant declaration, a Constant_Object item is output. Object_Name the name of the constant Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration Type_Ref reference to the type of the constant Value the value of the constant Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Type_Object = 83 Datum/Date : Datum/Date: von/of 95 OBJ TYPE Object_Name, Body_Byte, Line_Word, Column_Word, Type_Ref. For each type declaration, a Type_Object item is output. Object_Name the name of the type Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration Type_Ref reference to the type definition Variable_Object = OBJ VAR Object_Name, Body_Byte, Line_Word, Column_Word, Type_Ref, Level_Byte, Address_Byte, Mode_Byte, Initial_Value. For each variable declaration, a Variable_Object item is output. Object_Name the name of the variable Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration Type_Ref reference to the type of the variable Level_Byte the level of the variable (0 = global, 1 = local) Address_Byte the address of the variable in its data frame Mode_Byte the variable mode (0 = simple variable, 4 = loop index variable) Initial_Value the initial value of the value, 0 if no initial value Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Parameter_Object = 84 Datum/Date : Datum/Date: von/of 95 OBJ PAR Object_Name, Body_Byte, Line_Word, Column_Word, Type_Ref, Level_Byte, Address_Byte, Mode_Byte, Guarded_Byte. For each formal parameter, a Parameter_Object item is output. Object_Name the name of the parameter Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration Type_Ref reference to the type of the parameter Level_Byte the level of the parameter (0 = global, 1 = local) Address_Byte the address of the parameter in its data frame Mode_Byte the parameter mode (1 = in, 2 = out, 3 = in out) Guarded_Byte an indication whether the parameter is guarded (1) or not (0) Alias_Object = OBJ ALIAS Object_Name, Body_Byte, Line_Word, Column_Word, SID_Word, Selector_Name. For each alias declaration, an Alias_Object item is output. Object_Name the name of the alias Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration SID_Word the SID associated with this alias Selector_Name If the alias denotes an item from a library, then Selector_Name is the name of this item, otherwise it is an empty string. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 85 Datum/Date : Datum/Date: von/of 95 8.6 Types Type = [ Enumeration_Type | Identity_Type | Parameterized_Type | Range_Type | Unitized_Type | Set_Type | String_Type | Array_Type | Record_Type | Statecode_Type | Pathname_Type | Subitem_Pathname_Type | Imported_Type | Inherited_Type | Union_Type ]. A Type item is generated for each UCL type definition. For reference purposes, each generated Type item is assigned a reference number. Note that Type items are not generated for built–in (predefined) UCL types. The latter are referenced by their fixed, preassigned reference numbers (listed below under definition of Ref). Enumeration_Type = { Enumeration_Constant } TYP ENUM Size_Number. An Enumeration_Type item is output for each enumeration declaration. All Enumeration_Constant items preceding this item belong to this enumeration type. Size_Number the size of objects of this type Enumeration_Constant = CMP ENUM_CONST Constant_Name, Body_Byte, Line_Word, Column_Word. An Enumeration_Constant item is output for each enumerated constant. Constant_Name the name of the constant (the enumeration literal) Body_Byte location of the object declaration (0 = specification, 1 = body) Line_Word line number of the object declaration Column_Word column number of the object declaration Identity_Type = TYP IDENTITY Size_Number, Basetype_Ref. An Identity_Type item is output for each identity type declaration. Size_Number the size of objects of this type Basetype_Ref reference to the base type Parameterized_Type = TYP PARAM Size_Number, Basetype_Ref. A Parameterized_Type item is output for each parameterized type declaration. Size_Number the size of objects of this type Basetype_Ref reference to the base type Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Range_Type = 86 Datum/Date : Datum/Date: von/of 95 TYP RANGE Size_Number, Basetype_Ref, { Data_Word }. A Range_Type item is output for each subrange type declaration. Size_Number the size of objects of this type Basetype_Ref reference to the base type { Data_Word } the MIN and MAX values of the range, respectively. If the base type is of a double word type class, e.g. LONG_REAL, then the bound are given by four Data_Words representing two double word values, otherwise by two Data_Words. Unitized_Type = TYP UNIT Size_Number, Basetype_Ref, Unit_Name. A Unitized_Type item is output for each unitized type declaration. Size_Number the size of objects of this type Basetype_Ref reference to the base type Unit_Name string representation of the unit. Unit_Name must have been previously defined by an OBJ UNIT item. Set_Type = TYP SET Size_Number, Elementtype_Ref. A Set_Type item is output for each set type declaration. Size_Number the size of objects of this type Elementtype_Ref reference to the element type String_Type = TYP STRING Size_Number, Elementtype_Ref, Indextype_Ref | TYP DYN_STRING Size_Number, Elementtype_Ref. A String_Type item is output for each string type declaration. Size_Number the size of objects of this type Elementtype_Ref reference to the element type (CHARACTER or BYTE) Indextype_Ref reference to the index type. For dynamic, i.e. open, strings, no index type is ex- plicitly given (it is INTEGER by definition). Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Array_Type = 87 Datum/Date : Datum/Date: von/of 95 TYP ARRAY Size_Number, Elementtype_Ref, Indextype_Ref | TYP DYN_ARRAY Size_Number, Elementtype_Ref. An Array_Type item is output for each array type declaration. Size_Number the size of objects of this type Elementtype_Ref reference to the element type Indextype_Ref reference to the index type. For dynamic, i.e. open, arrays, no index type is explicitly given (it is INTEGER by definition). Record_Type = { Field } TYP RECORD Size_Number. A Record_Type item is output for each record declaration. All Field items preceding this item belong to this record. Size_Number the size of objects of this type Field = CMP FIELD Field_Class, Field_Name, Type_Ref, Offset_Number, Field_Selector_Byte, [ Labels ]. A Field item is output for each record field. Field_Cass specifies whether the item is a normal record field, a selector field or a field contained in a case variant (see definition below) Field_Name the name of the field Type_Ref reference to the type of the field Offset_Number the offset in words of the record field to the start of the record Field_Selector_Byte the index of the case selector field (counting all record fields starting with 1) for the innermost case variant containing the current field; it is zero for record fields outside variants Labels If the Field_Selector_Byte is non–zero, it is followed by case Labels; otherwise, Labels are omitted entirely. Field_Class = Byte. Indicating classes of record fields: 0 1 2 3 NONE NORMAL_FIELD a normal record field SELECTOR_FIELD a case selector field CASE_FIELD a field inside a variant Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: Labels = 88 Datum/Date : Datum/Date: von/of 95 Count_Byte, { Start_Word, End_Word }. This is the list of case labels used for the definition of a record field (for variant records.) Count_Byte the length of the following list of start/end value pairs of case label ranges Start_Word the first value of a label range End_Word the last value of a label range (for a single value End_Word = Start_Word) Statecode_Type = { Statecode_Constant } TYP STATECODE Size_Number. A Statecode_Type item is output for each declaration of a statecode type. All Statecode_Constant items preceding this item belong to this type. Size_Number the size of objects of this type Statecode_Constant = CMP STATECODE Statecode_Longword. A Statecode_Constant item is output for each enumerated statecode name in a statecode declaration. Statecode_Longword the name of the statecode constant, padded with spaces Pathname_Type = { DB_Item } TYP PATHNAME Size_Number. A Pathname_Type item is output for each declaration of a pathname type.All DB_Item items preceding this item belong to this type. Size_Number the size of objects of this type DB_Item = CMP DB_ITEM Item_Type_Name. A DB_Item item is output for each enumerated database item type name in a pathname declaration. Item_Type_Name the name of the database item type Subitem_Pathname_Type = { DB_Subitem } TYP SUBITEM_PATHNAME Size_Number. A Subitem_Pathname_Type item is output for each declaration of a subitem pathname type. All DB_Subitem items preceding this item belong to this type. Size_Number the size of objects of this type Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: DB_Subitem = 89 Datum/Date : Datum/Date: von/of 95 CMP DB_SUBITEM Subitem_Type_Name. A DB_Subitem item is output for each enumerated database subitem type name in a subitem pathname declaration. Subitem_Type_Name the name of the database subitem type Imported_Type = TYP IMPORT Library_Number, Type_Name. An Imported_Type item is output for each type which is actually imported from another compilation unit. Library_Number the index of the exporting library in the import list (sequence of CTL IMPORT items) Type_Name the declared identifier for the imported type Inherited_Type = TYP INHERITED Size_Number, Basetype_Ref, SID_Word. An Inherited_Type is output for each type inherited from an item in the database, e. g. a measurement item, with the UCL type of construct. Size_Number the size of objects of this type Basetype_Ref the reference to the base type SID_Word the SID of the library the type is inherited from Union_Type = { Member_Type } TYP UNION. A Union_Type item is output for an HLCL type union, i. e. for an overloading of one or more types. All member type items preceding this item belong to the type union. Member_Type = CMP TYPE Member_Type_Ref. A Member_Type item is output for each member type of a type union. Member_Type_Ref the reference to the member type Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 90 Datum/Date : Datum/Date: von/of 95 8.7 Type References Ref = Number. A Ref item refers to the sequence numbers generated by the compiler to identify specific UCL types. They allow subsequent references to these items to be made by other Symbol or Debug Table items. The reference numbers of the standard (built–in) UCL types are predefined as follows: 0: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: no specific type, all types allowed (HLCL only) Boolean Character Integer Unsigned_Integer Real Long_Real Bitset Time Duration Word string of Character statecode pathname pathname.* (subitem pathname) Pulse Burst_Pulse Completion_Code Byte Long_Word string of Byte The numbers 21 .. 31 are reserved for future built–in types. The reference number of the first non–standard structure is 32. 8.8 Units of Measure Unit = Absolute_Byte m_Signed_Byte, kg_Signed_Byte, s_Signed_Byte, A_Signed_Byte, K_Signed_Byte, mol_Signed_Byte, cd_Signed_Byte, Factor_Longword, [ Offset_Longword ]. A Unit item is output for each unit of measure. Absolute_Signed_Byte 1 = absolute unit, 0 = relative unitLength_Word m_Signed_Byte, kg_Signed_Byte, ..., cd_Signed_Byte exponent to the corresponding SI base unit Factor_Longword the factor of the unit Offset_Longword the offset of the unit (for absolute units only) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 91 Datum/Date : Datum/Date: von/of 95 8.9 Names, Values Name = String. A Name item describes names in the Symbol or Debug Table. It is used for is used for UCL identifiers. String = Length_Byte, { Data_Byte }. A String item is used to describe text strings. It is simply a sequence of bytes, beginning with the length of the string as an unsigned byte value. Value = Value_Class, { Data_Word }. For each IN parameter, each constant and each variable declaration, a constant value descriptor is output. A Value starts with a Value_Class, indicating the type class of the constant value. It is followed by a number of Data_Words, where the number depends on the Value_Class. Class = Byte. Each constant value in a Symbol or Debug Table starts with a Class, indicating the type class of the constant. This is either 0 if there is no value. It is thus used if there is no default specified for this parameter or no initialization value for this variable (and thus not used for plain constants). No data words follow. 1..30 followed by the simple constant value (Note that the data type classes are equally coded like the Ref Numbers). The number of data bytes is shown in the following table: 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: Boolean Character Integer Unsigned_Integer Real Long_Real Bitset Time Duration Word string of Character 12: 13: 14: 15: 16: 17: 18: 19: 20: statecode pathname pathname.* Pulse Burst_Pulse Completion_Code Byte Long_Word string of Byte (1 word) (1 word) (1 word) (1 word) (1 word) (2 words) (1 word) (2 words) (2 word) (1 word) (1 word length, n bytes data padded to next word boundary) (2 words) (1 word) (2 words) (1 word) (1 word) (1 word) (1 word) (2 words) (1 word length, n bytes data padded to next word boundary) Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 31 Number = 92 Datum/Date : Datum/Date: von/of 95 followed by the structured value as a sequence of data words. This is simply a sequence of words (where each value is encoded like a simple constant), beginning with the length of the value as a 4 byte integer number. Word. A Number item is a word containing an integer value. Longword = Word, Word. A Longword item contains a long real or any other value representable in a longword, i.e. in two words. Byte ordering and internal data representation are according to the conventions stated in Appendix C. Word = Byte, Byte, Byte, Byte. A Word item contains an integer, real or any other value representable in a word. Byte ordering and internal data representation are according to the conventions stated in Appendix C. Byte = any value between 0 .. 255. Signed_Byte = any value between –128 .. 127. Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 93 Datum/Date : Datum/Date: von/of 95 8.10 Example This example shows the Debug Table generated for the ”Example” AP shown in thechapter on I–Code generation. It is shown here both in a symbolic and in binary format (after the semicolon on the right side). TAB DEBUG VERSION = ” 2/–” ; CTL IMPORT NAME = ”\LIB\IO_LIBRARY”, ; ; ; ; 8: 16: 24: 26: F0 49 52 00 ; ; ; ; ; ; 30: 34: 38: 39: 40: 41: F3 00 01 58 00 00 00 03 01 00 01 00 SID = 2003000 = = = = = = ”X”, INTEGER, 1, 0, 1, FALSE 1: 02 01 04 20 32 2F 2D 00 0F 5C 4C 49 42 5C 4F 5F 4C 49 42 52 41 59 1E 90 38 OBJ PAR NAME TYPE LEVEL ADDRESS MODE GUARDED CTL SCOPE SUBPROGRAM = 1 ; 42: F0 01 01 CTL SCOPE SUBPROGRAM = 2 ; 45: F0 01 02 OBJ VAR NAME TYPE LEVEL ADDRESS MODE VALUE = = = = = = ”SUM”, INTEGER, 0, 0, 0, NONE ; ; ; ; ; ; 48: 54: 58: 59: 60: 61: F3 01 03 53 55 4D 00 00 00 03 00 00 00 00 OBJ VAR NAME TYPE LEVEL ADDRESS MODE VALUE = = = = = = ”N”, INTEGER, 0, 1, 0, NONE ; ; ; ; ; ; 62: 66: 70: 71: 72: 73: F3 01 01 4E 00 00 00 03 00 01 00 00 CMP IN_PAR NAME TYPE GUARDED DEFAULT = = = = ”X”, INTEGER, FALSE, NONE ; ; ; ; 74: 78: 82: 83: F2 00 01 58 00 00 00 03 00 00 OBJ PROC NAME = ”ADD”, SUBPROGRAM = 1, GUARDED = FALSE ; ; ; 84: F3 04 03 41 44 44 90: 01 91: 00 OBJ FUNC NAME TYPE SUBPROGRAM GUARDED ; 92: F3 05 04 4D 45 41 4E ; 99: 00 00 00 03 ; 103: 02 ; 104: 00 = = = = ”MEAN”, INTEGER, 2, FALSE Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: = = = = = = ”I”, INTEGER, 0, 2, 4, NONE ; ; ; ; ; ; 105: 109: 113: 114: 115: 116: 94 Datum/Date : Datum/Date: von/of 95 OBJ VAR NAME TYPE LEVEL ADDRESS MODE VALUE F3 01 01 49 00 00 00 03 00 02 04 00 CTL LOOP POSITION = 41 ; 117: F0 02 00 00 00 29 CTL END ADDRESS = 6, SUBPROGRAM = 2 ; 123: F0 03 06 ; 126: 02 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34 Dok.-Nr/Doc. No.: Ausgabe/Issue: Überarbtg./Rev.: Seite/Page: 95 Datum/Date : Datum/Date: von/of 95 9 Ada Programming Interface The following CLS Ada packages reflect stack machine memory architecture and I–Code definition. They should be used for any implementation of the UCL Virtual Stack Machine, in order to make sure all implementations are based on the same definitions. Package CLS This package defines some global constants, options and exceptions used by the other packages. Package CLS_Types This package defines the runtime representation of all UCL/HLCL datatypes with their operations. Package CLS_Types.Network This package provides functions to convert between platform specific representation and platform independent standard network representation of types declared in CLS_Types. The standard network representation is big endian. Package I_Code_Definition This package defines the I–Code instruction set. It contains the I–Code as an enumeration type, as well as functions to convert between these enumeration values, code representation in memory and textual Assembler representation. Package Runtime_Errors This package defines runtime errors that may occur in an I–Code interpreter. The runtime errors are defined as an enumeration type, together with functions converting between the enumeration values and their textual and machine representation. Package Parameter_Encoding This package maintains parameter lists encoded according to the external encoding scheme. Package Symbol_Table_Definition This package contains definitions for the encoding of symbol tables and debug tables. 2 Daimler–Benz Aerospace AG, D–28199 Bremen – All Rights reserved – Copyright per DIN 34