ANDF installer using the HPcode-Plus compiler intermediate language5280613Abstract A computer software compiler system and method for distributing a machine independent computer program, created on a native computer platform, to heterogeneous target computer platforms. The system comprises installer components which exist on heterogeneous target computer platforms. The installers receive a compiler intermediate representation of the machine independent computer program. The compiler intermediate representation is architecture neutral and represents an architecture neutral distribution format. The installers translate the compiler intermediate representation to object code representations according to an HPcode-Plus compiler intermediate language. The installers operate in a machine dependent manner such that the object code representations are architecture dependent, or machine dependent, on the target computer platforms. Claims We claim: Description CROSS-REFERENCE TO OTHER APPLICATIONS
______________________________________
TABLE OF CONTENTS
______________________________________
1. ANDF Compiler
2. HPcode-Plus
2.1. Virtual Machine Model (Expression Stack Model)
2.2. Memory Model
2.3. Memory Allocation and Data Types
2.4. HPcode-Plus Object File
2.5. HPcode-Plus Instruction Set for ANSI-C
3. ANDF Producer
3.1. Preprocessor
3.2. Compiler
3.2.1. Scanner/Parser
3.2.2. Semantic Analyzer
3.2.3. Code Generator
3.2.3.1.
Memory Allocation
3.2.3.2.
Scope, Linkage, and Decla-
ration of Variable
3.2.3.3.
Constants
3.2.3.3.1.Floating Point and
Integer Constants
3.2.3.3.2.Enumeration
Constants
3.2.3.3.3.Character Constants
3.2.3.4.
Data Conversions
3.2.3.5.
Postfix Expressions
3.2.3.6.
Unary Operations
3.2.3.7.
Other Operations
3.2.3.8.
Folding of Constant Operations
3.2.3.9.
Initialization
3.2.3.10.
Statements
3.2.3.11.
Functions
3.2.3.12.
Example
3.3. High-Level Optimizer
3.4. Archiver
4. ANDF Installer
4.1. Tuple-Generator
4.2. Low-Level Code Generator
4.2.1. Instruction Selection
4.2.2. Memory Allocation
4.2.3. Symbolic Debug Support
4.2.4. Optimization Support
4.2.5. Object File Management
4.3. Low-Level Optimizer
4.4. Register Allocator
4.5. Machine Specific Optimizer
4.6. Object File Generator
______________________________________
1. ANDF Compiler The present invention is directed to the standards being promulgated by ANSI for the C programming language (i.e., ANSI-C) and by the Open Software Foundation (OSF) for Unix computer platforms. It should be understood, however, that the present invention is not limited to the ANSI and OSF standards. The present invention, in either its present form or in the forms now contemplated, is applicable to computing environments which use deviations, modifications, and extensions of the ANSI and OSF standards. The scope of the present invention with respect to the ANSI and OSF standards is more fully described in the following text. As shown in FIG. 1, a conventional compiler 106 is logically divided into two parts, a compiler front end 108 and a compiler back end 116. The compiler front end 108 receives as input a computer program source code 102 as input. The computer program 102 is ordinarily written in a high-level computer programming language such as Pascal, C, and Ada. The compiler front end 108 is responsible for the language processing of computer programs, such as scanning, parsing, and semantic analysis. Following the completion of all language processing, the compiler front end 108 translates the computer program source code 102 into a compiler intermediate representation 112. The compiler intermediate representation 112 is written in a compiler intermediate language, such as Pcode and Ucode. The compiler back end 116 receives as input the compiler intermediate representation 112 and generates object code 120 for a target computer platform (not shown). The target computer platform is the computer platform where the compiler back end 116 resides. The object code 120 is written in a particular machine language of the target computer platform. Ordinarily, the compiler front end 108 operates in a machine dependent, or architecture dependent, manner. Thus, the compiler intermediate representation 112, which is generated by the compiler front end 108, is usually dependent upon the computer architecture of the native computer platform (i.e., the computer platform where the compiler front end 108 resides). The present invention is a significant improvement from the conventional compiler 106 shown in FIG. 1. The improvement of the present invention is achieved by using a HPcode-Plus compiler intermediate language as the compiler intermediate language. The HPcode-Plus compiler intermediate language (or simply, HPcode-Plus) is an improvement upon conventional compiler intermediate languages, such as Pcode and Ucode, in that HPcode-Plus is architecture neutral. As such, compilers which are based on the HPcode-Plus compiler intermediate language operate in an architecture neutral, or machine independent, manner. FIG. 2 presents an overview of a preferred embodiment of the present invention. Included in FIG. 2 is a high-level block diagram of an architecture neutral distribution format compiler 234 of the present invention (i.e., an ANDF compiler). The ANDF compiler 234 shown in FIG. 2 is based on the HPcode-Plus compiler intermediate language. In the preferred embodiment of the present system, logic for the ANDF Compiler 234 is stored in a computer program. The computer program is stored in a computer readable medium, such as a magnetic tape, a magnetic disk, and a read only memory (ROM). Like conventional compilers 106, the ANDF compiler 234 of the present invention has a front end. With the ANDF compiler 234, however, the front end is called an ANDF Producer 208. The ANDF compiler 234 also has one or more back ends. In the preferred embodiment of FIG. 2, two back ends, called ANDF Installers 218 and 228, are shown. The ANDF Producer 208 resides on a native computer platform 206. It should be noted that the native computer platform 206 is also called a producer site. The one or more ANDF Installers 218 and 228 reside on install sites 216 and 226, respectively, which are also called target computer platforms. It should be noted that the producer site 206 and install sites 216, 226 may or may not represent the same computer platform. The ANDF Producer 208 and the ANDF Installers 218, 228 can operate either independently, as two separate computer programs, or together, as two phases of a single computer program. As shown in FIG. 2, the ANDF Producer 208 receives the ANSI-C source code of machine independent computer programs 202. It should be understood, however, that the present invention is not limited to support for only ANSI-C source language programs. As described below, support for other high-level languages is contemplated. Machine independent computer programs 202 are computer programs which are composed of instructions. These instructions include high-level source statements and expressions. Machine independent computer programs 202 do not make assumptions on system specific features, such as memory architectures and register architectures. Machine independent computer programs 202 also do not contain references to system specific functions, such as non-standard operating system function calls. Machine independent computer programs 202 may contain references to standard object-like macros, function-like macros, and data type definitions from standard header files. Machine independent computer programs 202 may also contain references to standardized function calls. The standard header files and standardized function calls are defined by a language standard, such as ANSI-C. The ANDF Producer 208 operates in an architecture neutral, or machine independent, manner according to the HPcode-Plus compiler intermediate language. Thus, in translating the ANSI-C source language program 202 to a compiler intermediate representation 212, the ANDF Producer 208 makes no assumptions about the architecture of the target computer platforms 216 and 226. Thus, the compiler intermediate representation 212 generated by the ANDF Producer 208 is architecture neutral, or machine independent, and represents an architecture neutral distribution format (ANDF). The compiler intermediate representation 212 is distributed to the target computer platforms 216 and 226. The ANDF Installers 218 and 228, which reside on the target computer platforms 216 and 226, respectively, translate the compiler intermediate representation 212 to object code representations 222 and 232. In an alternative embodiment of the present invention, ANDF Installers 216, 226 are replaced by ANDF Interpreters (not shown in FIG. 2). The ANDF Interpreters directly execute the compiler intermediate representation 212 without first translating the compiler intermediate representation 212 to object code representations 222, 232. As noted above, the HPcode-Plus compiler intermediate language is used as the compiler intermediate language in the preferred embodiment of the present invention. Thus, the ANDF Producer 208 writes the compiler intermediate representation 212 in the HPcode-Plus compiler intermediate language. The HPcode-Plus compiler intermediate language is an improvement upon HPcode, which was an improvement upon U-Code. U-Code is a compiler intermediate language which was originally used for distributing a Pascal compiler to the CRAY-1 and S-1 computer platforms. It was developed by Stanford and the University of California at San Diego. U-Code, however, was not architecture neutral and could only support Pascal and Fortran source language programs. HPcode is also a compiler intermediate language. It was based on U-Code, but its instruction set was expanded to support other high-level languages, including Pascal, Fortran, Ada, Cobol, RPG, Business Basic, an internal Algol-like language, and a fourth generation language called HP-Transact. As noted above, the HPcode-Plus compiler intermediate language is an improvement upon HPcode, and upon all conventional compiler intermediate languages, in that HPcode-Plus is architecture neutral . As such, compilers which are based on the HPcode-Plus compiler intermediate language, such as the ANDF compiler 234 of the present invention, operate in an architecture neutral, or machine independent, manner. The HPcode-Plus compiler intermediate language is a further improvement upon HPcode, in that HPcode-Plus supports the C programming language. The following sections describe the present invention in more detail. Section 2 describes the HPCode-Plus compiler intermediate language, which is the compiler intermediate language of the present invention. Section 3 describes the ANDF Producer 208 of the present invention. Section 4 describes the ANDF Installer 218, 228 of the present invention. Some aspects of the present invention can be implemented using existing compiler technology. However, modifications upon existing compiler technology are required to achieve the improvements of the present invention. The discussions in Sections 2, 3, and 4 focus on these modifications upon existing compiler technology. For a general discussion of existing compiler technology, see Compilers, Principles, Technigues, and Tools by Alfred V. Aho, Ravi Sethi, and Jeffrey D. Ullman (Addison Wesley 1986), which is incorporated in its entirety herein by reference. As it presently exists, the HPcode-Plus compiler intermediate language can be used as the compiler intermediate language for architecture neutral C compilers on OSF computer platforms, such as the ANDF compiler 234 of the present invention. Thus, the descriptions of the preferred embodiment of the present invention in Sections 2, 3, and 4 are, for the most part, focused on this computing environment. It should be understood, however, that the present invention is not restricted to this computing environment. Since it is an improvement of HPcode, the HPcode-Plus compiler intermediate language has a rich instruction set for supporting other high-level languages, such as Pascal, Fortran, Ada, Cobol, RPG, Business Basic, an internal Algol-like language, and a fourth generation language called HP-Transact. It is contemplated to modify HPcode-Plus to support these languages in an architecture neutral manner. Additionally, the compiler intermediate representations 212 produced by ANDF compilers 234 should operate on any computer platform, provided that (1) the source language program 202 was written in a machine independent manner using standardized function calls to a run-time library, and (2) appropriate ANDF Installers 218, 228 exist on the target computer platforms 216, 226. 2HPcode-Plus In the preferred embodiment of the present invention, the HPcode-Plus compiler intermediate language is used as the compiler intermediate language. HPcode-Plus is an improvement upon conventional compiler intermediate languages in that HPcode-Plus is architecture neutral. As such, compilers which are based on the HPcodePlus compiler intermediate language, such as the ANDF compiler 234 of the present invention, operate in a architecture neutral, or machine independent, manner. Features of the HPcode-Plus compiler intermediate language are described in this section. HPcode-Plus instructions are shown with all letters capitalized. Other features of HPcode-Plus are described as necessary in Sections 3 and 4 of this document. When reading these sections, it may be helpful to refer to FIGS. 3a through 3d which present a list of the HPcode-Plus compiler intermediate language instructions for ANSI-C. 2.1 Virtual Machine Model (Expression Stack Model) The HPcode-Plus compiler intermediate language is very similar to assembly language for a HPcode-Plus virtual (i.e., fictional) computer platform. Correspondingly, compiler intermediate representations written in the HPcode-Plus compiler intermediate language are very similar to assembly language programs for the HPcode-Plus virtual computer platform. Referring to FIG. 2, for example, the ANDF Producer 208 translates the source code 202 into its equivalent assembly language representation 212. The ANDF Producer 208, however, does not generate the assembly language representation 212 for its native computer platform 206. Rather, the ANDF Producer 208 generates the assembly language representation 212 for the HPcode-Plus virtual computer platform. The HPcode-Plus compiler intermediate language represents the assembly language for the HPcode-Plus virtual computer platform. The ANDF Installer 218, 228 receives the compiler intermediate representation 212, which represents assembly language for the HPcode-Plus virtual computer platform, and generates the object code 222, 232 for its target computer platform 216, 226. The HPcode-Plus virtual computer platform contains an expression stack and a memory. Most HPcode-Plus instructions receive their arguments from and push their results to the expression stack. A data type is associated with each data object on the expression stack. HPcode-Plus instructions do not directly manipulate arbitrary expression stack elements. At most, HPcode-Plus instructions manipulate only the top N elements of the expression stack, where N is defined for each HPcode-Plus instruction. HPcode-Plus instructions DUP, SWP, and ROT manipulate the top elements on the expression stack without altering their values. A HPcode-Plus instruction DEL deletes the top element on the expression stack. Several HPcode-Plus instructions are provided for moving data between the expression stack and the memory, including HPcode-Plus instructions LOD and ILOD for direct and indirect load, HPcode-Plus instructions STR and ISTR for direct and indirect store, and HPcode-Plus instruction INST for indirect non-destructive store. In addition, data object addresses, labels, and procedures are loaded on the expression stack with HPcode-Plus instructions LDA, LDL, and LDP, respectively. HPcode-Plus instructions LDC and LCA are used to load constants and constant addresses on the expression stack. The expression stack may not physically exist on target computer platforms 216, 226. For example, if target computer platforms 216, 226 are register-based, then the expression stack may be modeled in registers. Care must be taken by the ANDF Installers 218, 228 to preserve the semantics of the expression stack. Values loaded onto the expression stack are "copied" onto the expression stack. HPcode-Plus instructions do not alter values already on the expression stack. Certain restrictions are enforced concerning the use of the expression stack. Branching and label HPcode-Plus instructions require the expression stack to be empty. This relieves the ANDF Installer 218, 228 from having to determine all possible jump sources for each label. HPcode-Plus procedure calls may occur when the expression stack is empty. Elements which are on the expression stack when a HPcode-Plus instruction MST is executed will not be visible to the called procedure but will become visible again upon return. 2.2 Memory Model HPcode-Plus defines a memory model in which the memory is divided into 4 areas: Static memory, Local memory, Constant memory, and Parameter memory. Data objects in each memory area can have 3 attributes associated with them: Constant attribute, Register attribute, and Volatile attribute. In the architecture neutral environment of the present invention, the ANDF Producer 206 makes no assumptions concerning the manner in which data objects are mapped into the memories of target computer platforms 216, 226. A HPcode-Plus instruction SYM is provided to defer actual memory allocation to the ANDF Installers 218, 228. The ANDF Producer 208 uses the HPcode-Plus instruction SYM to give a unique symbolic identifier to each data object and data type. The only exception to this rule is that the symbolic identifier of data types and data objects in local scopes can be reused. The ANDF Producer 208 also uses the HPcode-Plus instruction SYM to associate a memory type and attribute (i.e., Constant, Register, and Volatile) with each data object. HPcode-Plus memory reference instructions access memory through the symbolic identifiers of data objects defined by the SYM HPcode-Plus instruction. These HPcode-Plus memory reference instructions include LDA and LCA to load an address of an HPcode-Plus data object onto the expression stack. Also, HPcode-Plus contains instructions which manipulate memory indirectly, such as the string instructions. The ANDF Installers 218, 228 map data objects into the memories of their target computer platforms 216, 226. Such mapping depends on the memory type and attribute associated with each data object. A description of the memory types and attributes is presented in the following paragraphs. Data objects with the Static memory type maintain their values from one invocation of a procedure to the next. Static memory can be subdivided into global static memory, imported static memory, exported static memory, and procedure static memory. Variables mapping into these memories include file static variables, imported static variables, exported static variables, and procedure (or local) static variables, respectively. Data objects with the Local memory type do not maintain their values from one invocation of a procedure to the next. These objects are allocated to the Local memory area. Each procedure receives one Local memory area. For languages which do not support nested level procedures, such as ANSI-C, local data objects can only be referenced by the defining procedure. For languages supdistributing nested level procedures, such as Pascal, local data objects can be referenced by the defining procedure or its lower level nested procedures. For these languages, the scoping rules are equivalent to those in Pascal. Data objects with the Parameter memory type are allocated in the Parameter memory area. Each procedure receives one Parameter memory area. For languages which do not support nested procedures, such as ANSI C, variables in the Parameter memory area may be referenced only by the defining procedure. For languages which support nested procedures, such as Pascal, variables in the Parameter memory area may be referenced from outside the defining procedure subject to the Pascal scoping rules. This area is allocated by the calling procedure. All HPcode-Plus constants reside in the Constant memory area. In addition, any data objects with the Constant memory attribute defined by the SYM HPcode-Plus instruction of KIND.sub.-- MODIFIER are allocated in the Constant memory area. The ANDF Installers 218, 228, if possible, treat the Constant memory area as read-only. The ANDF Producer 208, however, does not assume that the target computer platforms 216, 226 can support read-only memory. Assignment to the Constant memory area yields undefined behavior. The Register attribute serves as a hint to the ANDF Installers 218, 228 that the associated data object should be allocated in fast cache memory. The ANDF Installers 218, 228, however, are not obliged to honor the request. Loading an address of a variable with the register attribute set can automatically turn off the register attribute. 2.3 Memory Allocation and Data Types The ANDF Producer 208 makes no assumptions concerning the manner in which data objects are mapped into the memories of target computer platforms 216, 226. Instead, the ANDF Producer 208 satisfies memory requests through the SYM HPcode-Plus instruction. Actual memory allocation is performed by the ANDF Installers 218, 228. The actual size and alignment of each data object is determined by ANDF Installers 218, 228, based on the data type specified in the SYM HPcode-Plus instruction. HPcode-Plus defines predefined data types. A list of the HPcode-Plus predefined data types is presented in FIG. 5. With minor differences, the HPcode-Plus predefined data types map into the corresponding data types in ANSI-C. The mapping of ANSI-C data types to HPcode-Plus predefined data types is presented in FIG. 6. The HPcode-Plus predefined data types have unique predefined symbolic identifiers. The HPcode-Plus predefined data types are the only data types that need not be defined by the SYM HPcode-Plus instruction. They are the building blocks for user-defined data types. The user-defined data types, which represent all data types besides the HPcode-Plus predefined data types, are defined using the SYM HPcode-Plus instruction with the <sym kind> parameter equal to one of the type values listed in FIG. 7. The ANDF Installers 218, 228 must ensure that their memory allocation schemes are consistent with those of a compiler on the native computer platform 206. 2.4 HPcode-Plus Object File The compiler intermediate representation 212 produced by the ANDF Producer 208 is stored in a HPcode-Plus Object file 1160 (FIG. 11). The HPcode-Plus Object file 1160 is a file containing a sequence of HPcode-Plus instructions in ASCII form which follow certain rules of form. The HPcode-Plus Object file 1160 is also referred to as a compilation unit. As shown in FIG. 11, several HPcode-Plus Object files 1150, 1160 can be achived or linked by an Archiver/Linker 1154 to produce a single HPcode-Plus Archive file 1158 or Linked HPcode-Plus File 1170. The format of the HPcode-Plus Object file 1150, 1160 is shown in FIG. 8. HPcode-Plus instruction names are shown in FIG. 8 in text form for readability only. In actual HPcode-Plus Object files 1150, 1160, numeric opcodes are used instead. Instructions are delimited by ASCII new line characters. All integers, including opcodes, are represented by hexadecimal literals to minimize the size of the HPcode-Plus Object file 1150, 1160. Within a line, fields are delimited by one or more blanks. An `opcode` field is first, followed by zero or more `operand` fields. Operand fields consist of integers, quoted strings, labels, real numbers, digit strings representing sets and `%` or `#` followed by integers representing macro arguments and SYM symbolic ids, respectively. Quoted strings are delimited by double quotes (an internal quote is represented by two double quotes in a row). Each ENT/END HPcode-Plus instruction sequence denotes the code of a procedure. SYM HPcode-Plus instructions within a pair of KIND.sub.-- FUNCTION and KIND.sub.-- END SYM HPcode-Plus instructions represent the data declarations of that procedure. For languages which allow multiple entry points, more than one ENT HPcode-Plus instruction appears before the END HPcode-Plus instruction. The first ENT HPcode-Plus instruction signals the primary entry point and defines the start of the scope of a procedure. The END HPcode-Plus instruction signals the end of the entire procedure. If the HPcode-Plus Object file 1150, 1160 contains the procedure which serves as the program entry point. Then the HPcode-Plus Object file 1150, 1160 is specially marked with an OPTN HPcode-Plus instruction. Execution of an HPcode-Plus computer program begins with the program entry point procedure. Each HPcode-Plus instruction is executed in sequence unless an error occurs or a HPcode-Plus instruction is executed which transfers control. If the source computer program 202 contains nested procedures (Pascal, Cobol or Ada), the outer level procedure and all its inner procedure must appear in the same HPcodePlus Object file 1150, 1160. 2.5 HPcode-Plus Instruction Set for ANSI-C As it presently exists, HPcode-Plus can be used as the compiler intermediate language for architecturally neutral C compilers on OSF computer platforms. It should be understood, however, that the present invention is not restricted to this computing environment. As described above, HPcode-Plus has a rich instruction set for supdistributing high-level languages other than C, such as Pascal, Fortran, Ada, Cobol, RPG, Business Basic, an internal Algol-like language, and a fourth generation language called HP-Transact. It is contemplated to modify HPcode-Plus to support these languages in an architecture neutral manner. Additionally, the compiler intermediate representations produced by ANDF compilers 234 should operate on any computer platform, provided that (1) the source computer program 202 was written in a machine independent manner using standardized function calls to the run-time library, and (2) appropriate ANDF Installers 218, 228 exist on the target computer platforms 216, 226. The HPcode-Plus instruction set for ANSI-C is presented in FIGS. 3A through 3D. These code-Plus instructions are described in the following sections. In these sections, expression stack elements and mandatory passed parameters are denoted by "<>". Optional passed parameters are denoted by "[]". The abbreviation "op" represents "operand". In its present form, HPcode-Plus does not support parallelism and vectorization. Currently, all HPcode-Plus instructions operate on scalar items. However, HPcode-Plus is capable of carrying sufficient information to support vector operations. Thus, HPcode-Plus can easily be enhanced to support both parallelism and vectorization. Existing HPcode-Plus instructions which are required to support other high-level languages, but which are not yet completely architecture neutral, are presented in FIG. 4. 2.5.1. ACVT--Arithmetic ConVerT The syntax of HPcode-Plus instruction ACVT is presented below: ACVT ACVT is used to convert operands to a known data type. ACVT pops <op2> and <opl> from the expression stack. ACVT performs data type conversions on <op2> and <opl> to prepare <op2> and <opl> for arithmetic processing. After conversion, <op2> and <opl> are pushed onto the expression stack. Conversion rules are language specific. HPcode-Plus instruction LANGUAGE OPTN indicates which set of rules to use. For example, the usual arithmetic conversions for ANSI-C are: If either operand has type long double, the other operand is converted to long double. Otherwise, if either operand has type double, the other operand is converted to double. Otherwise, if either operand has type float, the other operand is converted to float. Otherwise, if one operand has type long int and the other has type unsigned int, then if a long int can represent all values of an unsigned int, then the operand of type unsigned int is covered to long int; if a long int cannot represent all the values of an unsigned int, both operands are converted to unsigned long int. Otherwise, if either operand has type long int, the other operand is converted to long int. Otherwise, if either operand has type unsigned int, the other operand is converted to unsigned int. Otherwise, both operands are converted to type int. The ANDF Installers 218, 228 use a general conversion table to implement the conversion rules. This conversion table is implemented as a two dimension conversion table as follows:
__________________________________________________________________________
TYPE.sub.-- CHAR
TYPE.sub.-- UNS.sub.-- CHAR
. .
TYPE.sub.-- CHAR
TYPE.sub.-- INT
TYPE.sub.-- INT
. .
TYPE.sub.-- UNS.sub.-- CHAR
TYPE.sub.-- INT
TYPE.sub.-- INT
. .
. . . . . . . .
__________________________________________________________________________
Each language has a unique conversion table which resides on each target computer platform 216, 226. 2.5.2. ADD--ADD The syntax of HPcode-Plus instruction ADD is presented below: ADD ADD pops <opl> and <op2> from the expression stack. The addition <opl>+<op2> is performed to produce a result. The result, having the same data type as <opl> and <op2>, is then pushed on the expression stack. 2.5.3 AND--logical AND The syntax of HPcode-Plus instruction AND is presented below: AND AND pops <op1> and <op2> from the expression stack. A logical AND operation, <op1> AND <op2>, is performed to produce a result. The result, having the same data type as <op1> and <op2>, is then pushed on the expression stack. A bitwise AND is performed when <op1> and <op2> are integers or characters. That is, corresponding bits in <op1>and <op2> are ANDed to produce <result>. 2.5.4. CEND--Conditional evaluate END The syntax of HPcode-Plus instruction CEND is presented below: CEND This HPcode-Plus instruction marks the end of a conditionally evaluated instruction sequence begun by a matching HPcode-Plus instruction CEXP. The CEND HPcode-Plus instruction does not manipulate the expression stack. The item that is on top of the expression stack is the result produced by the matching CEXP instruction. The type of the item on top of the stack must be the same as the data type of the two CEXP clauses. The CEND HPcode-Plus instruction can only be used to terminate the most recent CEXP HPcode-Plus instruction. It is an error if there is no preceding conditional instruction. 2.5.5. CEVL--Conditional EVaLuate The syntax of HPcode-Plus instruction CEVL is presented below: CEVL This HPcode-Plus instruction leaves the expression stack unchanged. CEVL acts as a delimiter between two parts of a conditional expression. For example, two CEVLs are required with each CEXP instruction. One CEVL separates <boolean value> from <true expression>, and the other separates <false expression> from <true expression>. Stack items on the expression stack at the time of CEVL are not accessed until the conditional expression is terminated with a CEXP instruction. 2.5.6. CEXP--Conditionally evaluate EXPression The syntax of HPcode-Plus instruction CEXP is presented below: CEXP This HPcode-Plus instruction pops a boolean operand <boolean op> off the top of the expression stack. If <boolean op> is FALSE, then control is passed to a matching CSEP instruction. An item that is on top of the expression stack when a matching CEND instruction is encountered is treated as a result of the CEXP instruction. If the item popped off the top of the expression stack is TRUE, then HPcode-Plus instructions up to the matching CSEP are evaluated. Control is then passed to the matching CEND HPcode-Plus instruction. The item that is on top of the stack when the matching CSEP instruction is encountered is treated as the result of the CEXP HPcode-Plus instruction. The HPcode-Plus instructions between the CEXP and the matching CSEP HPcode-Plus instructions represent the true clause of the conditional evaluation. The HPcode-Plus instructions between the CSEP and the matching CEND HPcode-Plus instructions represent the false clause of the conditional evaluation. Both the true clause and the false clause must either result in zero or one item being pushed onto the expression stack. The data type of the resulting item pushed on to the expression stack by either clause must match and corresponds to the data type of the result of the CEXP HPcode-Plus instruction. It is possible for the true and false clauses to not leave any result on the stack. In particular, this happens with the ANSI-C conditional expression operator if the true and false clauses are of type void. There is no <result> pushed to the expression stack in this case. It is an error to specify the CEXP HPcode-Plus instruction without specifying matching CSEP and CEND HPcode-Plus instructions. It is also an error for either the true clause or the false clause to reference items pushed on the expression stack outside the respective clauses. 2.5.7. CLDC--C LoaD Constant The syntax of HPcode-Plus instruction CLDC is presented below: CLDC <flag> <constant value> CLDC converts <constant value> to a data type indicated by <flag> to produce a result. CLDC then pushes the result onto the expression stack. The values and corresponding data types of <flag> are presented below.
______________________________________
<flag> Data Types
______________________________________
0 TYPE.sub.-- INT, TYPE.sub.-- LONGINT, TYPE.sub.-- UNS.sub.--
LONGINT
1 TYPE.sub.-- INT, TYPE.sub.-- UNS.sub.-- INT, TYPE.sub.-- LONGINT,
TYPE.sub.-- UNS.sub.-- LONGINT
2 TYPE.sub.-- UNS.sub.-- INT, TYPE.sub.-- UNS.sub.-- LONGINT
3 TYPE.sub.-- LONGINT, TYPE.sub.-- UNS.sub.-- LONGINT
4 TYPE.sub.-- UNS.sub.-- LONGINT
______________________________________
If <flag> is 0, then the ANDF Installer 218, 228 converts <constant value> to TYPE.sub.-- INT, if possible. If it is not possible, then the ANDF Installer 218, 228 converts <constant value> to TYPE.sub.-- LONGINT, if possible. If it is not possible, then the ANDF Installer 218, 228 converts <constant value> to TYPE.sub.-- UNS.sub.-- LONGINT. The ANDF Producer 208 does not know what the ultimate data type of <constant value> will be. Thus, the ANDF Producer 208 cannot use CLDC prior to arithmetic operations. For arithmetic operations, ANDF Producers must use the ACVT HPcode-Plus instruction. 2.5.8. COMM--COMMent Syntax The syntax of HPcode-Plus instruction COMM is presented below: COMM <comment> COMM i s used to place comments within the HPcode-Plus Object file 1150, 1160. COMM HPcode-Plus instructions can appear anywhere in the HPcode-Plus Object file 1150, 1160. 2.5.9. CSEP--Conditional evaluation SEParator The syntax of HPcode-Plus instruction CSEP is presented below: CSEP CSEP leaves the stack unchanged. CSEP is used in conjunction with CEXP HPcode-Plus instructions. CSEP HPcode-Plus instructions simply act as delimiters between true clauses and false clauses of matching CEXP HPcode-Plus instructions. An error is generated if CSEP HPcode-Plus instructions are not accompanied by CEXP HPcode-Plus instructions. 2.5.10. CSJP--CaSe JumP The syntax of HPcode-Plus instruction CSJP is presented below: CSJP <else label> CSJP pops <selector> from the expression stack. CSJP uses <selector> to jump to either a location specified by HPcode-Plus instruction CTAB or <else label>. CSJP must be immediately followed by one or more consecutive CTAB HPcode-Plus instructions, each of which specifies a label and a range of values. No pair of ranges may overlap. CSJP branches to the label specified by the CTAB HPcode-Plus instruction whose range includes <selector>. If none of the CTAB ranges include <selector>, then CSJP branches to <else label>. <selector> must be the only item on the expression stack when CSJP is executed. 2.5.11. CTAB--Case TABle The syntax of HPcode-Plus instruction CTAB is presented below: CTAB <case label>[#]<low bound>[#]<high bound> CTAB specifies an entry in a case jump table. CTAB must immediately follow either HPcode-Plus instruction CSJP or another CTAB HPcode-Plus instruction. Different CTABs are allowed to have the same <case label>. <Low bound> is an integer or a character specifying the lower bound of the range which selects <case label>. If [#] is passed, <low bound> must be an integer symbolic identifier of an integer or character constant. <High bound> is an integer or a character specifying the upper bound of the range which selects <case label>. <Low bound> has to be less than or equal to <high bound>. If [#] if passed, <high bound> must be an integer symbolic identifier of an integer or character constant. 2.5.12. CUP--Call User Procedure The syntax of HPcode-Plus instruction CUP is presented below: CUP <proc symid> CUP is used to call a procedure or function. <Proc symid>, which represents the symbolic id of the procedure or function, must be previously defined by the KIND.sub.-- FUNC.sub.-- DCL or KIND.sub.-- FUNCTION SYM HPcode-Plus instruction. CUP initiates the procedure or function call using parameters in the procedure's or function's parameter area. These parameters were placed in the procedure's or function's parameter area by previous PAR HPcode-Plus instructions. For function calls (i.e., when the type of the procedure is not TYPE.sub.-- VOID), CUP reserves an area in memory for a return value. The return value is actually placed in this memory area by HPcode-Plus instruction STFN. 2.5.13. CVT--ConVerT The syntax of HPcode-Plus instruction CVT is presented below: CVT <result type> CVT pops <value> from the expression stack. CVT converts <value> to the data type indicated by <result type>. The converted <value> is pushed on the expression stack. The following conversions are allowed:
______________________________________
boolean => integer and character
character => boolean, integer, pointer to a data
object, or other char types
integer => boolean, character, floating point,
pointer, or other integer types
floating => character, integer, or other floating
point point types
pointer to a
=> character, integer, or pointer to any
type of data other type of data object
object
pointer to a
=> pointer to a function of another type
function of one
type
______________________________________
2.5.14. DEL--DELete The syntax of HPcode-Plus instruction DEL is presented below: DEL DEL deletes the item on top of the expression stack. 2.5.15. DIV--Divide The syntax of HPcode-Plus instruction DIV is presented below: DIV DIV pops <left op> and <right op> from the expression stack. A division <left op>/21 right op> is performed to produce a result. The result is always a whole number. For example, 5/2 equals 2 (and -5/2 equals -2). The result, having the same data type as <left op> and <right op>, is pushed on the expression stack. 2.5.16. DUP--Duplicate The syntax of HPcode-Plus instruction DUP is presented below: DUP DUP pops <value> from the expression stack. DUP then pushes <value> back on the expression stack twice. 2.5.17. END--END of procedure The syntax of HPcode-Plus instruction END is presented below: END <proc symid> END signals the end of a procedure. Thus, END must be the last HPcode-Plus instruction in the procedure. <Proc symid> must match the procedure's symbolic identifier. END HPcode-Plus instructions are paired with ENT HPcode-Plus instructions. The expression stack must be empty when END is executed. END behaves like a RET HPcode-Plus instruction. 2.5.18. ENT--procedure ENTry The syntax of HPcode-Plus instruction ENT is presented below: ENT <proc symid> ENT identifies a procedure entry point. The procedure must begin with the ENT HPcode-Plus instruction to identify the main entry point of the procedure. Other ENT HPcode-Plus instructions may be placed in the procedure's body to identify alternate entry points (used by some programming languages such as FORTRAN). If alternate entry points are specified, the flow of control through the procedure must be such that only one ENT HPcode-Plus instruction is actually executed. This may be accomplished by preceding each ENT HPcode-Plus instruction which specifies an alternate entry point with either the RET HPcode-Plus instruction or a branch instruction. There has to be a matching END HPcode-Plus instruction for each main entry ENT HPcode-Plus instruction. 2.5.19. EQU--EQUals The syntax of HPcode-Plus instruction EQU is presented below: EQU EQU pops <right op> and <left op> from the expression stack. If <right op> and <left op> are equal , then the boolean value TRUE is pushed on the expression stack. Otherwise, the boolean value FALSE is pushed on the expression stack. 2.5.20. FJP--False JumP The syntax of HPcode-Plus instruction FJP is presented below: FJP <label> FJP pops boolean value <condition> from the expression stack. <Condition> must be the only item on the expression stack when FJP is executed. FJP jumps to <label> if <condition> is FALSE. <Label> must occur in a LAB HPcode-Plus instruction in the current procedure. 2.5.21. GEO Greater than or EQual The syntax of HPcode-Plus instruction GEQ is presented below: GEQ GEQ pops <left op> and <right op> from the expression stack. If <left op> is greater than or equal to <right op>, then the boolean value TRUE is pushed on the expression stack. Otherwise, the boolean value FALSE is pushed onto the expression stack. For boolean data types, TRUE is greater than FALSE. 2.5.22. GRT--GReaTer than The syntax of HPcode-Plus instruction GRT is presented below: GRT GRT pops <right op> and then <left op> from the expression stack. If <left op> is greater than <right op>, the boolean value TRUE is pushed on the expression stack. Otherwise, FALSE is pushed on the expression stack. 2.5.23. ICUP--Indirect Call User Procedure The syntax of HPcode-Plus instruction ICUP is presented below: ICUP ICUP pops <function ptr> from the expression stack. ICUP then calls a procedure which is pointed to by <function ptr>. The called procedure uses procedure variables which were previously initialized statically or by LDP HPcode-Plus instructions. ICUP is commonly used to support procedures as parameters in Pascal. If ICUP is calling a function (i.e., if the procedure's data type is not TYPE.sub.-- VOID), then a return value will be pushed onto the expression stack after the call. 2.5.24. ICVT--Integral ConVerT The syntax of HPcode-Plus instruction ICVT is presented below: ICVT ICVT pops <value> from the expression stack. ICVT performs an integral promotion of <value> as defined by ANSI-C to produce a result. ICVT then pushes the result onto the expression stack. ICVT accepts only unsigned integral types. For signed varieties, CVT should be used. Since the ANDF Producer 208 cannot determine the result's data type, the result cannot be used immediately for an arithmetic operation which requires operands to be of the same type. The ACVT HPcode-Plus instruction should be used if an arithmetic operation is to be performed. 2.5.25. ILOD--Indirect LOaD The syntax of HPcode-Plus instruction ILOD is presented below: ILOD ILOD pops <address> from the expression stack. <Address>represents an address of a data object. The data object referenced by <address> is retrieved and then pushed onto the expression stack. If <address> references a structure or array, then the structure or array is pushed onto the expression stack with the ILOD HPcode-Plus instruction. 2.5.26. INC--INCrement The syntax of HPcode-Plus instruction INC is presented INC <offset> INC pops <value> from the expression stack, and increments <value> by <offset> to produce a result. if <value> is an address, <offset> is scaled to the size of the data object pointed to by <value>. The result is pushed onto the expression stack. 2.5.27. INIT--INITialize static data area The syntax of HPcode-Plus instruction INIT is presented below: INIT <target id> <source id> INIT is used to initialize static, global, and constant data areas. A source, represented by <source id>, is compatible with a target, represented by <target id>, if <source id> and <target id> are of the same data type, <source id> and <target id> are both simple types and <source id> can be converted to <target id> using a CVT HPcode-Plus instruction. In such cases, the ANDF Installers 218, 228 perform implicit CVT instructions, or <source id> and <target id> are array types and the types of the array elements are the same but the dimension size of the source is smaller than that of the target. In such cases, the ANDF Installers 218, 228 perform partial initialization. 2.5.28. INST--Indirect Non-destructive STore The syntax of HPcode-Plus instruction INST is presented below: INST INST pops <item> and then <address> from the expression stack. INST then stores <item> into <address>. INST also pushes <item> back onto the expression stack. 2.5.29. IOR--Inclusive OR The syntax of HPcode-Plus instruction IOR is presented IOR IOR pops <op1> and <op2> from the expression stack. A logical OR operation, <op1> OR <op2>, is performed to produce a result. The result, having the same data type as <op1> and <op2>, is then pushed on the expression stack. For integer and character data types, a bitwise OR is performed. That is, corresponding bits in <op1> and <op2> are ORed. 2.5.30. ISTR--Indirect SToRe The syntax of HPcode-Plus instruction ISTR is presented ISTR ISTR pops <item> and then <address> from the expression stack. ISTR then stores <item> into <address>. 2.5.31. IXE--IndeX an Element The syntax of HPcode-Plus instruction IXE is presented below: IXE <data type> IXE pops <index item> and <base address> from the expression stack. The value of <index item> is multiplied by the size of the data type specified by <data type>. The product of this multiplication is added to <base address> to produce a result. The result, representing an index address, is then pushed onto the expression stack. 2.5.32. IXF--IndeX a Field The syntax of HPcode-Plus instruction IXF is presented below: IXF <fieldtype> IXF pops <base address> from the expression stack. <Base address> represents the address of a structure. <Fieldtype> represents the symbolic id of a field within the structure. IXF determines the offset from the beginning of the structure (specified by <base address> to the field (specified by <fieldtype> IXF adds the offset to <base address> and then pushes the sum of this addition to the expression stack. <fieldtype> can be a field of a structure type in the case of nested structures. 2.5.33. LAB--LABel The syntax of HPcode-Plus instruction LAB is presented below: LAB <label> <flag> LAB defines the location of <label> in a sequence of HPcode-Plus instructions. Executing LAB has no effect on the expression stack, although the expression stack must be empty when it is executed. <Label> consists of one or more digits or alphabetic characters or `$`. All labels must be unique within a compilation unit. External labels must start with a letter. The values of <flag> and their associated conditions are:
______________________________________
Value Condition
______________________________________
0 A local label that cannot be referenced by a
GOOB HPcode-Plus instruction.
1 An external label that can be referenced by a
GOOB HPcode-Plus instruction.
______________________________________
Note that GOOB is not used by ANSI-C. GOOB is used for Pascal to branch to a non-local label. 2.5.34. LDA--LoaD Address The syntax of HPcode-Plus instruction LDA is presented below: LDA <symid> LDA pushes the address specified by <symid> to the expression stack. <Symid> is the symbolic id of a variable (defined by a KIND.sub.-- SVAR, KIND FPARAM, or KIND.sub.-- DVAR SYM HPcode-Plus instruction) or a constant (defined by a KIND.sub.-- CONST SYM HPcode-Plus instruction or another constant defining SYM HPcode-Plus instruction). 2.5.35. LDC--LoaD Constant The syntax of HPcode-Plus instruction LDC is presented below: LDC <type symid> <value> LDC pushes a simple constant to the expression stack (HPcode-Plus instruction LOD is used to push an aggregate constant to the expression stack). <Type symid> and <value> specify the data type and the value, respectively, of the constant. <Value> must be within the range associated with <type symid>. The external format of <value> is dependent upon the value of <type symid>:
__________________________________________________________________________
TYPE.sub.-- BOOLEAN
Either an integer 0 or an integer 1,
representing FALSE or TRUE, respectively.
TYPE.sub.-- CHAR
An ASCII character in double quotes, with
a double quote being represented by """".
An integer is also allowed. The integer
will be converted implicitly to a
character by the ANDF Installer 218, 228.
TYPE.sub.-- UNS.sub.-- CHAR
An ASCII character in double quotes, with
a double quote being represented by """".
An unsigned integer is also allowed. The
integer will be converted implicitly to a
character by the ANDF Installer 218, 228.
TYPE.sub.-- SINT
An integer. An ASCII characer in double
quotes is also allowed. The ASCII
character will be converted implicitly to
an integer by the ANDF Installer 218, 228.
TYPE.sub.-- INT
An integer. An ASCII characer in double
quotes is also allowed. The ASCII
character will be converted implicitly to
an integer by the ANDF Installer 218, 228.
TYPE.sub.-- LONGINT
An integer. An ASCII characer in double
quotes is also allowed. The ASCII
character will be converted implicitly to
an integer by the ANDF Installer 218, 228.
TYPE.sub.-- UNS.sub.-- SINT
A positive integer. An ASCII characer in
double quotes is also allowed. The ASCII
character will be converted implicitly to
a positive integer by the ANDF Installer
218, 228.
TYPE.sub.-- UNS.sub.-- INT
A positive integer. An ASCII characer in
double quotes is also allowed. The ASCII
character will be converted implicitly to
a positive integer by the ANDF Installer
218, 228.
TYPE.sub.-- UNS.sub.-- LONGINT
A positive integer. An ASCII characer in
double quotes is also allowed. The ASCII
character will be converted implicitly to
a positive integer by the ANDF Installer
218, 228.
__________________________________________________________________________
2.5.36. LDP--LoaD Procedure entry The syntax of HPcode-Plus instruction LOP is presented below: LDP <proc> LDP pushes <proc>, the symbolic id of a procedure, onto the expression stack. LDP is typically used to pass procedures as parameters, or to assign procedures to procedure variables. 2.5.37. LEQ--Less than or EQual The syntax of HPcode-Plus instruction LEQ is presented below: LEQ LEQ pops <right op> and <left op> from the expression stack. If <left op> is less than <right op>, then the boolean value TRUE is pushed onto the expression stack. Otherwise, the boolean value FALSE is pushed onto the expression stack. 2.5.38. LES--LESs Than The syntax of HPcode-Plus instruction LES is presented below: LES LES pops <right op> and <left op> from the expression stack. If <left op> is less than <right op>, the boolean value TRUE is pushed onto the expression stack. Otherwise, the boolean value FALSE is pushed onto the expression stack. 2.5.39. LOC--LOCation The syntax of HPcode-Plus instruction LOC is presented below: LOC LOC is used for debugging purposes. The ANDF Producer 208 generates LOC HPcode-Plus instructions when SYMBOLIC DEBUG OPTN HPcode-Plus instructions are encountered. LOC is used to correlate a source language statement number (i.e., the offset) with a current location counter. LOC must precede HPcode-Plus instructions associated with source language statements. 2.5.40. LOD--LOAD The syntax of HPcode-Plus instruction LOD is presented below: LOD <item> LOD pushes <item> onto the expression stack. <Item> can be a simple variable, a constant, or an aggregate variable such as an array or a structure. 2.5.41. MCAL--Macro CALl The syntax of HPcode-Plus instruction MCAL is presented below: MCAL <macro> <parm list> MCAL invokes <macro>. <Macro> represents the symbolic id of a valid macro definition. <Macro> must be previously defined in a KIND.sub.-- MACRO SYM instruction. <Parm list> represents the actual parameters to <macro>. The number of parameters in <parm list> must match the definition for <macro>. 2.5.42. MPY--MultiPlY The syntax of HPcode-Plus instruction MPY is presented below: MPY MPY pops <op1> and <op2> from the expression stack. A multiplication <op1>*<op2> is performed to produce a result. The result, having the same data type as <op1> and <op2>, is then pushed onto the expression stack. 2.5.43. MST--Mark STack The syntax of HPcode-Plus instruction MST is presented below: MST MST is used to mark the expression stack in preparation for a procedure call. After marking the expression stack with MST, actual parameters for the procedure can be pushed onto the expression stack with PAR HPcode-Plus instructions. The expression stack need not be empty before executing MST. 2.5.44. NEG--NEGate The syntax of HPcode-Plus instruction NEG is presented below: NEG NEG pops <value> from the expression stack. NEG then negates <value> to produce a result. The result is pushed onto the expression stack. <Value> must be a signed integer or a floating point. The result has the same type as <value>. 2.5.45. NEO--Not EQUals The syntax of HPcode-Plus instruction NEQ is presented below: NEQ NEQ pops <right op> and <Ieft op> from the expression stack. If <right op> and <left op> are not equal, the boolean value TRUE is pushed onto the expression stack. Otherwise, the boolean value FALSE is pushed onto the expression stack. <Right op> and <left op> must be the same data type. 2.5.46. NOP--No Op The syntax of HPcode-Plus instruction NOP is presented below: NOP <argument list> NOP represents a non-operation. The ANDF Installers 218, 228 ignore NOP instructions. Parameters in <argument list> are passed to the next HPcode-Plus instruction. 2.5.47. NOT--NOT The syntax of HPcode-Plus instruction NOT is presented below: NOT NOT pops <value> from the expression stack. NOT then performs a logical NOT operation on <value> to produce a result. The result is then pushed back onto the expression stack. For integer and character types, each bit of <value> is NOT'ed. For boolean types, the values TRUE and FALSE are NOT'ed. 2.5.48. OPTN--Option The syntax of HPcode-Plus instruction OPTN is presented below: OPTN <option number> <parameter list> OPTN is used to transmit option information from the ANDF Producer 208 to the ANDF Installers 218, 228. In general , the option information causes the ANDF Installers 218, 228 to alter the manner in which they generate code. <Option number> represents an option. <Parameter list> represents a sequence of zero or more parameters. The number and interpretation of <parameter list> depend on the value of <option number>. OPTN HPcode-Plus instructions may be located in only specific parts of the HPcode-Plus Object file 1150, 1160. For example, some OPTN HPcode-Plus instructions, depending on the value of <option number>, may be located anywhere within a procedure. Others must be located outside the procedure (i.e., before a KIND.sub.-- FUNCTION SYM instruction). In general, OPTN, once set, remains in effect until it is reset. Possible values for <option number> are listed below: LANGUAGE TYPE WARNING LEVEL CODE LISTING LOCALITY SET INIT SYMBOLIC DEBUG COPYRIGHT PROGRAM ENTRY PT HPcode Plus VERSION COMPILATION REC OPTIMIZATION ASSEMBLER FILE OBJECT FILE USER VERSION ROUNDING MODE CONVERSION OVERFLOW CHK ARITHMETIC OVERFLOW CHK PROCEDURE SIDE EFFECT LIBRARY FILE PROGRAM FILE 2.5.49. PAR--PARameter The syntax of HPcode-Plus instruction PAR is presented below: PAR PAR pops <value> from the expression stack. PAR stores <value> into the parameter area of a procedure to be called. 2.5.50. REM--REMainder The syntax of HPcode-Plus instruction REM is presented below: REM REM pops <left op> and <right op> from the expression stack. A division <left op>/<right op> is performed to produce a result. The result represents the remainder of the division operation. For example, 4/2 equals 0, 5/2 equals 1, and -5/2 equals -1. The result is then pushed onto the expression stack. 2.5.51. RET--Return The syntax of HPcode-Plus instruction RET is presented below: RET RET returns program control from a called procedure to a calling procedure. Before returning programming control, RET restores the static and dynamic computing environment of the calling procedure. If the current procedure is a program entry point, normal program termination will occur. The expression stack must be empty before RET is executed. 2.5.52. RND--Round The syntax of HPcode-Plus instruction RND is presented below: RND <result dtype> RND pops <real value> from the expression stack. if <real value> is positive, then RND adds 0.5 to <real value> to produce a temporary result. If <real value> is negative, then RND adds -0.5 to <real value> to produce the temporary result. The integer part of the temporary result is converted to the data type indicated by <result dtype> and then pushed onto the expression stack. 2.5.53. ROT--ROTate The syntax of HPcode-Plus instruction ROT is presented below: ROT ROT rotates the top three items on the expression stack. For example, suppose the expression stack contains <op1> <op2> <op3> before ROT, where <op1> is the top of the expression stack. After ROT, the expression stack would contain <op3> <op1> <op2>, where <op3> is the top of the expression stack. 2.5.54. SHFT--SHiFT The syntax of HPcode-Plus instruction SHFT is presented below: SHFT <direction> SHFT pops <item> and <shift count> from the expression stack. SHFT then shifts <item> by <shift count> bit positions to produce a result. The result is pushed onto the expression stack. When <direction> is 0, <item> shifts either right or left, depending on the sign of <shift count>. If the ANDF Producer 208 knows the shift direction, then <direction> should be set to I for a left shift and to -1 for a right shift. <Shift count> must be positive when <direction> is 1 or -1. The meaning of SHFT depends on the data type of <item>. For signed integers, an arithmetic shift is performed. For unsigned integers, a logical shift is performed. Since the result depends on the size of <item>, SHFT must be used with caution. ANDF Installers 218, 228 may generate a warning when SHFT is used. 2.5.55. STFN--STore FuNction result The syntax of HPcode-Plus instruction STFN is presented below: STFN STFN is used to return a function result. Specifically, STFN pops <value> from the expression stack. STFN then stores <value> in the memory return area set aside by HPcode-Plus instruction CUP. The data type of <value> must match the function's return value data type defined in the KIND.sub.-- FUNCTION SYM instruction. 2.5.56. STR--SToRe The syntax of HPcode-Plus instruction STR is presented below: STR <variable symid> STR pops <value> from the expression stack and stores <value> into the variable specified by <variable symid>. The data type of <value> must match that of <variable symid>. If <variable symid> represents the symbolic id of a constant (i.e., the constant attribute is set), then the behavior of STR is implementation dependent. In such cases, the ANDF Installers 218, 228 generate a warning message. 2.5.57. SUB--SUBtract The syntax of HPcode-Plus instruction SUB is presented below: SUB SUB pops <left op> and <right op> from the expression stack. A subtraction <left op>-<right op> is performed to produce a result. The result, having the same data type as <left op> and <right op>, is then pushed onto the expression stack. When <left op> and <right op> represent two data addresses, then the result will be a scaled integer of TYPE.sub.-- INT (the result is scaled as with INC/IXE, but in a reverse manner). Data objects pointed to by <left op> and <right op> must have the same data type. The behavior of such pointer subtraction is implementation dependent. 2.5.58. SWP--SWaP The syntax of HPcode-Plus instruction SWP is presented below: SWP SWP pops the top two stack items and pushes them back onto the expression stack such that their stack positions are reversed. 2.5.59. SYM--SYMbol Table The syntax of SYM is presented below: SYM <symid> <sym kind> <sym info> SYM is used to defer memory allocation from the ANDF Producer 208 to the ANDF Installers 218, 228. Specifically, through SYM, variable, type, and constant information is conveyed from the ANDF Producer 208 to the ANDF Installers 218, 228. The ANDF Installers 218, 228 use this information to perform memory allocation, alignment, initialization, and machine dependent constant folding. The ANDF Producer 208 use SYM to give a unique symbolic identification (also called symid or symbolic id) to each data object and data type. The only exception to this rule is that the symid of data types and data objects in local scopes can be reused. The ANDF Producer 208 also uses the SYM instruction to associate a memory type (e.g., Static, Local, or Parameter) and attribute (e.g., Constant, Register, or Volatile) with each data object. SYM parameters (or fields) symid, sym kind, and sym info are described in the following sections. 2.5.59.1. Symid Symid stands for Symbolic Identifier. Symids are used by HPcode-Plus instructions to refer to variables, data types, and constants. For example, rather than using an actual physical address to access a data object in memory, HPcode-Plus instructions use the data object's symid. The ANDF Producer 208 assigns symid values starting at 256, although assignment need not be sequential. The ANDF Producer 208, however, does not assign symid values greater than 65535 unless all smaller values have been used. The ANDF Installers 218, 228 must accept symids with values up to at least 65535. HPcode-Plus includes predefined symids for predefined data types listed in FIG. 5. These data types are the only ones that need not be explicitly defined by SYM HPcode-Plus instructions. The predefined symids are presented in FIG. 9. The size of the predefined data types depends on the target computer platform 216, 226 and is determined by the ANDF Installer 218, 228. Thus, TYPE.sub.-- INT can be 16 bits on one computer platform and 32 bits on another. All that the ANDF Producer 208 can rely on is certain minimum ranges, and that TYPE.sub.-- SHORTINT is no larger than TYPE.sub.-- INT and TYPE.sub.-- INT is no larger than TYPE.sub.-- LONGINT. A function begins with a KIND.sub.-- FUNCTION declaration and terminates with a matching KIND.sub.-- END. Properly nested functions, as in Pascal, might exist. The nesting structure is determined implicitly by the placement of KIND.sub.-- FUNCTION and KIND.sub.-- END SYM HPcode-Plus instruction pairs. Certain symids, such as the KIND.sub.-- DVAR declarations of dynamic variables and the KIND.sub.-- FPARAM declarations of formal parameters are also implicitly associated with the nearest enclosing function. When the function is terminated by the matching KIND.sub.-- END, all local symid declarations of associated interior objects become unavailable. The ANDF Producer 208 may reuse any of these "freed" symid values in new SYM declarations. The ANDF Producer 208 reuses such symid values to minimize the size of tables at the ANDF Installers 218, 228. In addition, the ANDF Producer 208 can explicitly tell the ANDF Installer 218, 228 that other symid values (such as a type declaration) are "freed" upon function termination. This is done by using a <free> parameter in those symid declarations. If the <free> parameter is 0, then the symid value will not be freed. If the <free> parameter is 1, then the symid value is associated with the nearest enclosing function and when the function is terminated, the symid value is freed. 2.5.59.2. Sym Kind and Sym Info <Sym kind> and <sym info> are fields which contain symbolic kind and symbolic information, respectively. The structure of <sym info> depends on the value of <sym kind>. Possible values of <sym kind> are presented in FIG. 10. Listed below are descriptions showing the relationship of <sym kind> and <sym info>. These descriptions contain definition and usage information. 2.5.59.2.1. KIND.sub.-- POINTER Syntax: SYM <symid> KIND.sub.-- POINTER <free> <type> [<name>] This SYM variation defines a data object pointer type. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <type> is a symbolic id for the data type that the v pointer is to point to. <Type> must represent a data type and may either be a HPcode-Plus predefined data type (listed in FIG. 5), an existing symbolic id type, or a forward reference to a symbolic id type. In the last case, it is permissible to never supply the missing reference, as long as information about the missing type is not needed. To define a pointer type to a function, see the KIND.sub.-- FUNC.sub.-- PTR SYM entry, below. <name> is a name which is used to reference the pointer type during symbolic debug operations. 2.5.59.2.2. KIND.sub.-- STRUCTURE Syntax: SYM<symid> KIND.sub.-- STRUCT <free><first field><packing>[<name>] This SYM variation defines a structure data type. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <first field> is a symbolic id of the first field in a structure. This may be a forward reference to a symbolic id. <First field> may also be a special value 0, indicating an incomplete structure definition which may be completed later. Symbolic ids of field definitions are chained together in a list by use of the KIND.sub.-- FIELD symbolic declaration. All fields of the structure must be declared before the size of the structure is needed. <packing> is a flag which indicates whether the structure has normal, packed, or crunched packing. Normal packing implies that the ANDF Installer 218, 228 packs fields and array elements in a manner which is consistent with the packing method of the target computer platform 216, 226. Packed implies that the ANDF Installer 218, 228 packs fields and array elements in a manner which is consistent with the packed packing method of the target computer platform 216, 226. Languages like Pascal allows users to specify PACKED packing for arrays and structures. Crunched packing implies that the ANDF Installer 218, 228 may not expand fields and may not leave holes. Every field is bit aligned to conserve space. <name> is a name which is used to reference the structure type during symbolic debug operations. 2.5.59.2.3. KIND.sub.-- UNION Syntax: SYM <symid> KIND.sub.-- UNION <free><first field>[<name>] This SYM variation defines a union data type. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <first field> is a symbolic id of the first field in the union. This may be a forward reference to a symbolic id. <First field> may also be the special value 0 , indicating an incomplete union definition which may be completed later. Symbolic ids of the field definitions are chained together in a list by use of the KIND.sub.-- FIELD symbolic declaration. All fields of the union must be declared before using the size of the union. <name> is a name which is used to reference the union type during symbolic debug operations. Pascal variant records can be implemented in HPcode-Plus as a structure whose last field is a union of structures. 2.5.59.2.4. KIND.sub.-- ARRAY Syntax: SYM<symid> KIND.sub.-- ARRAY <free><size><type><packing>[<name>] This SYM variation defines a structure of an array. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <size> indicates the number of elements in the array. <Size> may be a simple integer constant, or a symid (using the #n notation) of an already defined symbolic constant or variable (in languages which support dynamic sizes, such as FORTRAN and Ada). <Size> is set to the constant 0 to specify an array with unknown size. The array's definition is later completed with an additional SYM HPcode-Plus instruction. A multi-dimensional array is defined to be an array of arrays. <type> is a symbolic id which indicates the data type of each element of the array. <packing> is a flag indicating the type of packing desired as in the description for KIND.sub.-- STRUCT, above. 2.5.59.2.5. KIND.sub.-- ENUM Syntax: SYM <symid> KIND-ENUM <free><member><base type>[<name>] This SYM variation defines an enumerated type. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <member> is a symbolic id of the first member declaration. <member> may be a forward reference to a symbolic id. <member> may also be a special value 0 , indicating an incomplete enumerated type definition which may be completed later. Symbolic ids of the member definitions are chained together in a list by use of the KIND.sub.-- MEMBER symbolic declaration. All members of the enumerated type must appear before using the size of the enumerated type. <base type> is a symid of a predefined integral type. When a member of the enumerated type is located on the HPcode-Plus expression stack, an implicit type conversion to the <base type> is performed. Similarly, items of the <base type> on the stack may be stored into variables of the enumeration type without an explicit conversion. <name> is a name which is used to reference the enumerated type during symbolic debug operations. Note that the width of the enumerated type is not required to be the same as the width of the <base type>. The actual size of a variable of enumerated type is decided by the ANDF Installer 218, 228. The actual size should be a multiple of the size of TYPE CHAR. In a crunched structure or array, the size of an enumerated type field or element should be as small as possible. 2.5.59.2.6. KIND.sub.-- FUNCT PTR Syntax: SYM <symid> KIND.sub.-- FUNC.sub.-- PTR <free><return type>[<name>] The SYM variation defines a "pointer to a procedure" data type. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <return type> is a symbolic id of the data type returned by the procedure. <name> is a name which is used to reference the function pointer type during symbolic debug operations. 2.5.59.2.7. KIND.sub.-- MODIFIER Syntax: SYM<symid> KIND.sub.-- MODIFIER <free><modification><type>[<name>] This SYM variation defines a modified type of an existing type declaration. The original data type and the modified data type are compatible. <free> is a flag which indicates whether <symid> is freed when the nearest enclosing function is terminated. <modification> is a flag with possible values 0, 1, or 2. A <modification> value of 0 indicates that the new data type is a synonym of the original data type (with possibly a different name for symbolic debug purposes) | ||||||
