pTAL Conversion Guide Abstract This publication describes the differences between the programming languages TAL (HP Transaction Application Language) and pTAL (Portable Transaction Application Language). It is not a complete reference for either language. The reader is assumed to be an experienced TAL programmer. Product Version pTAL D44 EPTAL H01 Supported Release Version Updates (RVUs) This publication supports D44.00, G01.00, and H06.
Document History Part Number Product Version Published 117110 pTAL D40 December 1995 527302-002 pTAL D44, EPTAL H01 July 2005
pTAL Conversion Guide Glossary Index What’s New in This Manual xix Manual Information xix New and Changed Information Examples Figures xix About This Manual xxiii Audience xxiii Related Documentation xxiv Notation Conventions xxv 1.
3. Lexical Elements (continued) Contents 3. Lexical Elements (continued) New Reserved Keywords 3-3 New Nonreserved Keywords 3-4 4. Data Representation Constant Lists 4-2 FIXED Variables 4-5 FIXED(*) Variables 4-5 Initializing FIXED Variables That Have Nonzero Scale Factors Data in System Global Variables 4-7 TAL 4-7 pTAL 4-7 5.
8. Simple Variables Contents 8. Simple Variables 9. Arrays Read-Only Arrays 9-1 TAL 9-1 pTAL 9-1 Constant Lists in Array Declarations Read-Only Arrays 9-2 Nonstring Arrays 9-3 Arrays of Addresses 9-4 9-2 10.
11. Structures Contents 11.
12. Equivalenced Variables (continued) Contents 12.
13. Expressions (continued) Contents 13. Expressions (continued) Group Comparison Expressions 13-10 Changing the Data Type of the Data 13-11 Changing the Location of the Data 13-12 14. Bit Operations Shift Operations 14-1 TAL 14-1 pTAL 14-2 Using 32-Bit Operands With Bit Deposit and Bit Extract Operations TAL 14-4 pTAL 14-4 14-4 15.
15. Statements (continued) Contents 15. Statements (continued) RETURN Statement 15-19 RETURN Statement 15-19 Returning a Value and Condition Code in TAL 15-20 Returning a Condition Code in pTAL 15-20 SCAN and RSCAN Statements 15-23 Extended Pointers 15-24 Scanning Across Variable Boundaries 15-24 Scanning Data in P-Relative Arrays 15-25 USE Statement 15-26 TAL 15-26 pTAL 15-26 WHILE Statement 15-27 16.
17. TAL Standard Routines Contents 17. TAL Standard Routines $AXADR 17-2 $BOUNDS 17-2 $CARRY 17-3 TAL 17-3 pTAL 17-3 $COMP 17-5 $DBL 17-5 $HIGH 17-6 $INT 17-6 $LADR 17-7 $LEN 17-8 TAL 17-8 pTAL 17-8 $OCCURS 17-9 $OFFSET 17-10 $OVERFLOW 17-11 TAL 17-11 pTAL 17-12 $RP 17-12 $SWITCHES 17-12 $USERCODE 17-13 $XADR 17-13 18.
18. pTAL Built-In Routines (continued) Contents 18.
18. pTAL Built-In Routines (continued) Contents 18. pTAL Built-In Routines (continued) $WADDR_TO_EXTADDR $WRITEPTE 18-54 18-54 19. Compiler Operation Compiling pTAL Programs 19-1 Input File 19-1 Output Files 19-2 Swap Files 19-3 ASSIGN and SSV Commands 19-3 PARAM Commands 19-3 Running the Compiler at a High or Low PIN Compiler Directives 19-3 For TAL Only 19-3 For pTAL and TAL 19-6 Separate Compilation 19-28 Linking Object Files 19-29 19-3 20.
20. Hardware Indicators (continued) Contents 20. Hardware Indicators (continued) Using Hardware Indicators Across Procedures 20-27 TAL 20-27 pTAL 20-27 Returning the Condition Code to a Caller 20-28 Glossary Index Examples Example 4-1. Example 4-2. Example 5-1. Example 5-2. Example 5-3. Example 5-4. Example 5-5. Example 5-6. Example 5-7. Example 5-8. Example 5-9. Example 7-1. Example 9-1. Example 9-2. Example 9-3. Example 9-4. Example 10-1. Example 10-2. Example 10-3. Example 10-4.
Examples (continued) Contents Examples (continued) Example 10-13. Example 10-14. Example 10-15. Example 10-16. Example 10-17. Example 10-18. Example 10-19. Example 10-20. Example 11-1. Example 11-2. Example 11-3. Example 11-4. Example 11-5. Example 11-6. Example 11-7. Example 11-8. Example 11-9. Example 11-10. Example 11-11. Example 11-12. Example 11-13. Example 11-14. Example 11-15. Example 11-16. Example 11-17. Example 11-18. Example 11-19. Example 11-20. Example 12-1. Example 12-2. Example 12-3.
Examples (continued) Contents Examples (continued) Example 12-10. Example 12-11. Example 12-12. Example 12-13. Example 12-14. Example 12-15. Example 12-16. Example 12-17. Example 13-1. Example 13-2. Example 13-3. Example 13-4. Example 13-5. Example 13-6. Example 13-7. Example 14-1. Example 14-2. Example 15-1. Example 15-2. Example 15-3. Example 15-4. Example 15-5. Example 15-6. Example 15-7. Example 15-8. Example 15-9. Example 15-10. Example 15-11. Example 15-12. Example 15-13. Example 15-14.
Examples (continued) Contents Examples (continued) Example 15-19. Branching From a Subprocedure to Its Containing Procedure (pTAL) 15-14 Example 15-20. Overflow Traps and GOTO Statements 15-15 Example 15-21. Testing an INT Variable Without a Not-Equal Operator (TAL) 15-16 Example 15-22. Testing an INT(32) Variable Without a Not-Equal Operator (pTAL) 15-17 Example 15-23. Value Parameter in Move Statement (TAL) 15-17 Example 15-24. Move Statement With Destination Shorter Than Source 15-18 Example 15-25.
Examples (continued) Contents Examples (continued) Example 16-10. Example 16-11. Example 16-12. Example 16-13. Example 16-14. Example 16-15. Example 16-16. Example 16-17. Example 16-18. Example 16-19. Example 16-20. Example 17-1. Example 17-2. Example 17-3. Example 17-4. Example 17-5. Example 18-1. Example 18-2. Example 18-3. Example 18-4. Example 18-5. Example 18-6. Example 18-7. Example 18-8. Example 18-9. Example 18-10. Example 18-11. Example 18-12. Example 18-13. Example 18-14. Example 18-15.
Examples (continued) Contents Examples (continued) Example 18-19. Example 18-20. Example 18-21. Example 18-22. Example 18-23. Example 18-24. Example 18-25. Example 18-26. Example 18-27. Example 18-28. Example 18-29. Example 18-30. Example 18-31. Example 18-32. Example 18-33. Example 18-34. Example 18-35. Example 18-36. Example 18-37. Example 18-38. Example 18-39. Example 18-40. Example 18-41. Example 19-1. Example 20-1. Example 20-2. Example 20-3. Example 20-4. Example 20-5. Example 20-6. Example 20-7.
Examples (continued) Contents Examples (continued) Example 20-15. Example 20-16. Example 20-17. Example 20-18. Example 20-19. Testing Condition Codes Set in Conditional Expressions 20-25 Testing Condition Codes After Comparing Addresses 20-26 Using Hardware Indicators Across Procedures (TAL) 20-27 Using Hardware Indicators Across Procedures (pTAL) 20-27 Returning the Condition Code to a Caller (pTAL) 20-28 Figures Figure 10-1. Figure 10-2. Figure 10-3. Figure 10-4. Figure 10-5. Figure 10-6. Figure 10-7.
Figures (continued) Contents Figures (continued) Figure 18-10. Figure 18-11. Figure 18-12. Figure 18-13. Figure 18-14. Figure 18-15. Figure 18-16. Figure 18-17. Figure 18-18. Figure 18-19. Figure 18-20. Figure 18-21. Figure 18-22. Figure 18-23. Figure 18-24. Figure 18-25.
Tables (continued) Contents Tables (continued) Table 18-1. Table 18-2. Table 19-1. Table 19-2. Table 19-3. Table 19-4. Table 19-5. Table 19-6. Table 20-1. Table 20-2. Table 20-3.
Contents pTAL Conversion Guide —527302-002 xx
What’s New in This Manual Manual Information pTAL Conversion Guide Abstract This publication describes the differences between the programming languages TAL (HP Transaction Application Language) and pTAL (Portable Transaction Application Language). It is not a complete reference for either language. The reader is assumed to be an experienced TAL programmer. Product Version pTAL D44 EPTAL H01 Supported Release Version Updates (RVUs) This publication supports D44.00, G01.00, and H06.
New What’s New in This Manual New • • • • Information about the EpTAL compiler, throughout this manual, but especially important in: ° ° Table 18-2, pTAL Built-In Routines That TAL Does Not Support, on page 18-4 Section 19, Compiler Operation $TRIGGER on page 18-48 CALL_SHARED on page 19-13 Glossary Changed • • • • • Syntax diagrams, from bracket-and-brace style to railroad-track style (only those whose syntax was changed or corrected have change bars) Terms “TAL standard routines” and “pTAL buil
Moved to This Manual From the pTAL Reference Manual What’s New in This Manual • Section 18, pTAL Built-In Routines Deleted: ° “Atomic Operations” topic, which merely defined “atomic operation” and listed the atomic operations (now the Glossary defines atomic operation and Table 18-2 on page 18-4 identifies the atomic operations) ° $SEND Added: “New” routines deleted from Section 17, TAL Standard Routines Reorganized: “Considerations” for all built-in routines that were listed at the end of TNS Instr
What’s New in This Manual Moved to This Manual From the pTAL Reference Manual pTAL Conversion Guide —527302-002 xxiv
About This Manual This manual describes the differences between the HP Transaction Application Language (TAL) and the portable Transaction Application Language (pTAL). Throughout this manual, the nouns “TAL” and “pTAL” refer to the languages, not to the TAL compiler and public name.
Related Documentation About This Manual Related Documentation Publication Description TAL Reference Manual Describes the entire TAL language TAL Reference Summary Summarizes the TAL syntax diagrams • • TAL Programmer’s Guide TAL Programmer’s Guide Data Alignment Addendum pTAL Reference Manual Explains how to use the TAL compiler Gives guidelines for using TAL Documents the data alignment requirements of TAL • • • Describes the entire pTAL language Explains how to use the pTAL and EpTAL compiler
Notation Conventions About This Manual Notation Conventions • • • Hypertext Links on page xxvii Syntax Diagram Conventions on page xxvii Change Bar Notation on page xxxi Hypertext Links Blue underline is used to indicate a hypertext link within text. By clicking a passage of text with a blue underline, you are taken to the location described. For example: This requirement is described under Audience on page xxv. Syntax Diagram Conventions This manual presents syntax in railroad diagrams.
Syntax Diagram Conventions About This Manual Some examples of the meanings of simple diagrams are: Diagram Piece Meaning Choose item1 or item2. item1 item2 VST407.vsd Choose item1, item2, or neither. item1 item2 VST408.vsd item , Specify item one or more times, separating occurrences with commas. VST409.vsd item Specify item at most n times. n VST742.vsd Note.
Syntax Diagram Conventions About This Manual Spacing rules are: • If the arrow between two diagram pieces is labelled “ns,” put no spaces between the syntactic items that they represent. For example: ns volume $ VST420.vsd means that you type: $NEWVOL not $ NEWVOL • An “ns” on the top line of a choice structure applies to the lower lines in the choice structure as well. For example: ns " ns RETURN^SORT^ERRORS " RETURN_SORT_ERRORS_ VST185.
Syntax Diagram Conventions About This Manual • If two diagram pieces are separated by a separator character, separating the syntactic items that they represent by spaces is optional. For example: MULTIPLY integer1 , integer2 VST411.vsd means that you type: MULTIPLY 3,4 or MULTIPLY 3, 4 • If a diagram piece is immediately followed by a period, putting spaces between the syntactic item and the period is optional. For example: END PROGRAM program-name . VST374.
Change Bar Notation About This Manual Change Bar Notation Change bars are used to indicate substantive differences between this edition of the manual and the preceding edition. Change bars are vertical rules placed in the right margin of changed portions of text, figures, tables, examples, and so on. Change bars highlight new or revised information. For example: The message types specified in the REPORT clause are different in the COBOL environment and the Common Run-Time Environment (CRE).
Change Bar Notation About This Manual pTAL Conversion Guide —527302-002 xxxii
1 Introduction The HP Transaction Application Language (TAL) has constructs that depend on TNS architecture. TAL programs that use these constructs might not have the intended result on other architectures. The portable Transaction Application Language (pTAL) has no constructs that depend on a specific architecture (this is why it is portable). pTAL programs fully utilize the features of native architecture.
TAL FeaturesThat pTAL Does Not Support Introduction • • • Optional clauses to optimize program performance by specifying how data is stored in memory: ° ° FIELDALIGN for structure alignment REFALIGNED for pointer alignment Compiler directives: ° ° ° ° CHECKSHIFTCOUNT FIELDALIGN OVERFLOW_TRAPS REFALIGNED Built-in routines that provide the functionality of some TNS machine instructions The TAL compiler accepts most of the preceding pTAL features (which means the TAL and native compilers can usuall
Converting TAL Source Code to pTAL Object Code Introduction In pTAL program you cannot: In pTAL program you must: (page 2 of 2) Reference hardware indicators—the condition codes (CCL, CCE, CCG), $CARRY, and $OVERFLOW—at arbitrary places in your program Reference a hardware indicators only in an IF statement that immediately follows the statement that sets the hardware indicator.
Introduction Object Code That Runs as a TNS/R Native Process Object Code That Runs as a TNS/R Native Process 1. Using the pTAL compiler, compile your TAL source code with the SYNTAX directive. 2. If the compiler reports syntax errors, correct your TAL source file and repeat Step 1. If not, go to Step 3. 3. Without the SYNTAX directive, compile your source code using the pTAL compiler. The resulting TNS/R object code runs as a TNS/R native process. Object Code That Runs as a TNS/E Native Process 1.
2 Program Structure TAL and pTAL support BLOCK declarations with which, in any one compilation, you can declare: • • • One unnamed block One PRIVATE block Any number of named blocks BLOCK identifier AT PRIVATE (0) BELOW (64) (256) ; END data-declaration BLOCK ; VST001.
Program Structure pTAL Conversion Guide —527302-002 2 -2
3 Lexical Elements This section describes the pTAL lexical elements that differ from those in TAL, which are: • • • • • • • Two-Character Operators on page 3-1 One-Character Unsigned Binary Operators on page 3-2 Bit-Extract Operators on page 3-2 Address-Base Symbols on page 3-3 Indirection Symbols on page 3-3 New Reserved Keywords on page 3-3 New Nonreserved Keywords on page 3-4 Two-Character Operators TAL These two-character operators can have one or more space characters or line breaks between their
One-Character Unsigned Binary Operators Lexical Elements One-Character Unsigned Binary Operators TAL A one-character signed binary operator can have one embedded space character between the operator character and the closing quotation mark. For example: a := a ‘+ ‘ 1; ! Space allowed between + and final ‘ pTAL A one-character signed binary operator cannot have anything between the operator character and the closing quotation mark.
Address-Base Symbols Lexical Elements All other bit-extract operators can be immediately followed by any binary operator, as in TAL.
New Nonreserved Keywords Lexical Elements New Nonreserved Keywords pTAL supports the following new nonreserved keywords: AUTO NODEFAULT RETURNSCC SHARED2 SHARED8 pTAL treats these nonreserved keywords the same way TAL treats nonreserved keywords such as EXTENSIBLE or ELEMENTS: you can use the identifiers for userdefined items (for example, variables, procedures, and defines), but they always retain their special meaning in specific contexts.
4 Data Representation This section describes the differences in pTAL and TAL data representation, which affect: • • • • Data types (see Table 4-1 on page 4-1) Constant Lists on page 4-2 FIXED Variables on page 4-5 Data in System Global Variables on page 4-7 Table 4-1.
Constant Lists Data Representation The remainder of this manual avoids using data type aliases. Constant Lists TAL Contant List: repetition-constant-list [ ] repetition-constant-list constant-list-seq VST011.vsd pTAL Contant List: repetition-constant-list ] repetition-constant-list [ FIELDALIGN-clause constant-list-seq VST621.vsd repetition-constant-list [ repetition-factor constant-list-seq ] * VST008.
Constant Lists Data Representation constant-list-seq is a list of one or more constants, each stored on an element boundary: constant repetition-constant-list , VST029.vsd constant is a character string, a number, or a LITERAL specified as a single operand. The range and syntax for specifying constants depends on the data type (see Table 4-1 on page 4-1). FIELDALIGN-clause FIELDALIGN ( SHARED2 ) SHARED8 VST065.
Constant Lists Data Representation Rules for the FIELDALIGN clause: • • • • You must use the FIELDALIGN clause if SHARED2 and SHARED8 do not produce the same alignment. The FIELDALIGN directive has no effect on constant lists. If you specify SHARED8 and the constants are not well aligned, the native compilers report an error. You might need to rearrange the entries in your constant list or specify one or more zero entries as filler items.
FIXED Variables Data Representation FIXED Variables Topics: • • FIXED(*) Variables on page 4-5 Initializing FIXED Variables That Have Nonzero Scale Factors on page 4-6 FIXED(*) Variables pTAL treats a FIXED(*) variable in an expression as FIXED: FIXED(*) f1 := 123F; FIXED(2) f2; f2 := f1; ! F2 is assigned 123.00 pTAL does not perform scaling on data stored into a FIXED(*) variable: FIXED(2) f1 := 1.23F; FIXED(*) f2; FIXED f3; f2 := f1; f3 := f1; ! F2 is assigned 123 ! F3 is assigned 1 Example 4-2.
Initializing FIXED Variables That Have Nonzero Scale Factors Data Representation Initializing FIXED Variables That Have Nonzero Scale Factors TAL Declaration Initialization Expression Result Simple FIXED variable with nonzero scale factor FIXED constant with a nonzero scale factor TAL scales the FIXED constant when it initializes the variable, whether the variable is global or local.
Data in System Global Variables Data Representation Data in System Global Variables The address type of pointers to system global variables is one of SGBADDR, SGWADDR, SGXBADDR, or SGXWADDR. TAL .SG pointers point to system global variables. pTAL Both .SG and .SGX pointers point to system global variables. pTAL allocates 16 bits for .SG pointers and 32 bits for .SGX pointers: STRING INT .SG s; .SG i; ! s is 16 bits for both pTAL and TAL ! i is 16 bits for both pTAL and TAL STRING INT .SGX s; .
pTAL Data Representation pTAL Conversion Guide —527302-002 4 -8
5 Data Allocation Topics: • • • Data Alignment on page 5-1 Reference Alignment on page 5-3 Volatile Data on page 5-5 Data Alignment Ensuring that data is well-aligned in memory is more important in native processes than in TNS processes. The native compilers, therefore, allocate memory such that each data element is aligned for optimal access time. Data accessed by pointers, however, might not be well-aligned, depending on how you declare the pointers and the addresses you store in the pointers.
Data Alignment in Native Processes Data Allocation Data Alignment in Native Processes In a native process, data can begin at any byte address. Data access is most efficient, however, when the byte address of the data is an integral multiple of the width of the data. For example, access to an INT(32) value is most efficient if the address of the data is an integral multiple of four. Similarly, access to a REAL(64) value is most efficient if the address of the data is an integral multiple of eight.
Reference Alignment Data Allocation The native compilers generate either conservative code or fast code for each data access. Conservative code uses two native instructions to access 32-bit data. Although conservative code is somewhat slower than fast code, it will not cause an exception, regardless of how the data is aligned. Use conservative code for pointers to data that you have not explicitly allocated, such as data in a heap and data in reference parameters.
Reference Alignment Data Allocation The REFALIGNED clause has one parameter, which must be either 2 or 8. The parameter specifies whether the compiler is to generate fast code (REFALIGNED(8)) or conservative code (REFALIGNED(2)). If you specify REFALIGNED(2), the native compilers generate conservative code—code that accesses data that is aligned on any two-byte boundary.
Volatile Data Data Allocation Example 5-1. Reference Alignment (page 2 of 2) ?REFALIGNED(2) INT(32) .ap1; INT(32) .ap2; INT(32) .ap3; INT(32) .ap4; ! References to these pointers ! generate conservative code ! because of REFALIGNED(2) ! directive ?REFALIGNED(8) INT(32) .ap11; INT(32) .ap21 REFALIGNED(2); INT(32) .ap31; INT(32) .
Volatile Data Data Allocation The VOLATILE attribute is recommended for data items that can be accessed asynchronously by other processes, for example: • • Trap handlers that access global data I/O operations that do not notify you when they are complete For I/O operations that notify you when they are complete, you do not need volatile data: Specify a buffer when you initiate an asynchronous I/O operation and access the buffer only after the I/O is complete.
Valid Uses of the VOLATILE Attribute Data Allocation Topics: • • • • Valid Uses of the VOLATILE Attribute on page 5-7 Invalid Uses of the VOLATILE Attribute on page 5-10 Undefined Uses of the VOLATILE Attribute on page 5-11 Difference Between Volatile Data and Atomic Operations on page 5-11 Valid Uses of the VOLATILE Attribute You can specify VOLATILE when you declare a: • • • • Simple variable Pointer Field in a structure or substructure Parameter Example 5-3.
Valid Uses of the VOLATILE Attribute Data Allocation Volatile Simple Variables Each time your program references a volatile simple variable or a volatile simple structure field, the value of the variable is read from or written to memory. Example 5-4. Volatile Simple Variables VOLATILE INT c; INT d; INT e; d := c + .01 * c; ! Each reference to c causes a memory read.
Valid Uses of the VOLATILE Attribute Data Allocation Example 5-5. Volatile Simple Pointers (page 2 of 2) i := p2[p1]; ! The data referenced by p2[p1] is the same as ! p2[a] of the preceding example, but both ! p1 and p2 are volatile.
Invalid Uses of the VOLATILE Attribute Data Allocation Example 5-7. Volatile Parameters PROC p(i, j); VOLATILE INT i, .j; BEGIN ... END; ! Both i and j are always treated as ! volatile, independent of whether the ! actual parameters passed to p are ! volatile PROC q; BEGIN VOLATILE INT a; VOLATILE INT .b; INT c; INT .
Undefined Uses of the VOLATILE Attribute Data Allocation Example 5-8. Invalid Uses of the VOLATILE Attribute (page 2 of 2) VOLATILE INT a[0:9]; VOLATILE INT .b[0:9]; VOLATILE INT .EXT c[0:9]; ! Direct array ! Indirect array ! Extended array VOLATILE INT i = 'P' := "ABCD"; ! Read-only array Undefined Uses of the VOLATILE Attribute The effect of the VOLATILE attribute is undefined for a volatile variable that is the target of an intermediate store operation.
Data Allocation Difference Between Volatile Data and Atomic Operations pTAL Conversion Guide —527302-002 5- 12
6 Constants, LITERALs, and DEFINEs Character constants are the same in TAL and pTAL except in null strings and REAL variables. Null Strings TAL You can assign a character constant null string ("") to a variable in the variable’s declaration or in an assignment statement. You cannot, however, declare a LITERAL whose value is a null string; therefore, you cannot initialize a variable to a null string using a LITERAL.
Constants, LITERALs, and DEFINEs DEFINE Declarations DEFINE Declarations TAL You can use a reserved word as a formal parameter identifier in a define declaration. pTAL You cannot use a reserved word as a formal parameter identifier in a define declaration. This statement is valid in TAL but not in pTAL: DEFINE x(cond, int) = IF cond THEN GOTO int#; You must change int to an identifier that is not a pTAL reserved word.
7 Labels In TAL and pTAL, a label is the target location of a GOTO statement. The following guidelines apply to pTAL: • • • • LABEL is not a valid data type for a formal procedure parameter. A label is not a valid actual procedure parameter. If a GOTO statement in a subprocedure branches to a label in the containing procedure, the label must be declared in a LABEL declaration in the containing procedure.
Branching From a Subprocedure to Its Containing Procedure Labels Branching From a Subprocedure to Its Containing Procedure TAL If the target of a GOTO statement in a subprocedure is a label in the containing procedure, the label in the containing procedure need not be declared in a LABEL declaration. pTAL If the target of a GOTO statement in a subprocedure is a label in the containing procedure, the label must be declared in a LABEL declaration in the containing procedure.
8 Simple Variables A variable that is not an array, a structure, or a pointer is a simple variable. In pTAL, you can declare: • • • Simple variables whose data type is an address type Simple variables whose data type is FIXED(*)x Volatile variables type VOLATILE identifier ; := initialization , VST622.vsd VOLATILE specifies that the value of this variable must be maintained in memory, not in a native register. Each reference to the variable causes a read from or a write to memory.
Simple Variables identifier See the TAL Reference Manual. initialization See the TAL Reference Manual.
9 Arrays Topics: • • • Read-Only Arrays on page 9-1 Constant Lists in Array Declarations on page 9-2 Arrays of Addresses on page 9-4 Read-Only Arrays The data in a read-only array (also called a P-relative array) is stored in a user code segment. Programs can read data from read-only arrays but cannot write to them. TAL A read-only array can be direct or indirect—the TAL compiler generates the same code for both cases. pTAL If a read-only array declaration specifies an indirection symbol (.
Constant Lists in Array Declarations Arrays Constant Lists in Array Declarations pTAL introduces two requirements for array declarations, as follows: • • If an array declaration includes an initialization string, the number of bits in the array and in the initialization string must be equal. If the alignment of the elements of the initialization string under SHARED2 rules and SHARED8 rules is different, you must specify a FIELDALIGN clause in the initialization string.
Nonstring Arrays Arrays Example 9-2. Constant Lists in Read-Only Array Declarations (pTAL) (page 2 of 2) Valid: int p int q[0:3] string r string s[0:3] string t string v string w[0:3] = = = = = = = 'P' 'P' 'P' 'P' 'P' 'P' 'P' := := := := := := := "abcd"; "abcdabcd"; "abcd"; "abcd"; [1,2,3]; [1,2,3,4]; [1,2,3,4]; Nonstring Arrays In TAL and pTAL, you can specify an initialization string when you declare an array.
Arrays of Addresses Arrays pTAL The number of bits in the initialization string must be equal to the number of bits in the array: Example 9-4. Constant Lists in Nonstring Array Declarations (pTAL) Invalid: INT .a[0:3] := [0,1,2]; INT .a[0:3] := [0,1,2,3,4]; ! ERROR: string is too short ! ERROR: string is too long Valid: INT .a[0:3] := [0,1,2,3]; INT .a[0:3] := [%H1234567812345678%F]; Arrays of Addresses In pTAL, the data type of an array can be one of the pTAL address types.
Arrays of Addresses Arrays identifier See the TAL Reference Manual. . .EXT .SG .SGX See the TAL Reference Manual. range [ lower-bound : upper-bound ] VST993.vsd initialization See the TAL Reference Manual.
Arrays of Addresses Arrays pTAL Conversion Guide —527302-002 9 -6
10 Pointers Topics: • • • • • • • • • • • Overview on page 10-1 Declaring Pointers on page 10-2 Address Types on page 10-5 Determining Address Types on page 10-9 @ Operator on page 10-14 Operations on Addresses on page 10-17 Pointers That Have Different Widths on TNS and Native Architectures on page 10-35 Pointers With the Same Widths on TNS and Native Architectures on page 10-39 Reference Alignment with Nonstructure Pointers on page 10-39 Alternatives to Using Address Constants in Native Processes on p
Declaring Pointers Pointers Declaring Pointers In pTAL, pointer declarations can include the following additional syntactic elements: • • • A REFALIGNED clause A VOLATILE attribute An .SGX indirection symbol type VOLATILE identifier . .EXT .SG .SGX REFALIGNED 2 ( ) 8 ; := initialization , VST676.
Declaring Pointers Pointers • • • • • • • • • • • • • • • • FIXED [(fpoint )] INT INT (16) INT (32) INT (64) PROCADDR REAL REAL (32) REAL (64) SGBADDR SGWADDR SGXBADDR SGXWADDR STRING UNSIGNED (width) WADDR fpoint is the implied fixed point of the FIXED variable. In pTAL,fpoint can also be an asterisk (*) as in: FIXED(*) .f; See discussion of FIXED(*) variables in Section 4, Data Representation. See the TAL Reference Manual for further discussion of fpoint.
Declaring Pointers Pointers REFALIGNED Specifies the alignment of the variables or structures that identifier references. 2 specifies that the variables and structures referenced by identifier are aligned as they would be on TNS architecture and might not be well-aligned on native architecture. 8 specifies that the variables and structures will be well-aligned for use on native architecture. Pointers declared with reference alignment of either 2 or 8 are well-aligned on TNS architecture.
Address Types Pointers Address Types TAL You specify where data and pointers are allocated in TNS memory and how data is addressed by the notation you use when you declare the data. Table 10-1 on page 10-5 shows the TAL notation for each class of data reference. Table 10-1.
pTAL Pointers The “Symbol” column notations in Table 10-1 on page 10-5 specify where TAL allocates your data and specify the object code to generate to access the data on TNS architecture. Although you can use a 32-bit extended address to access a 64K-word data segment— for example, the user data segment—your program performs best if you use direct or indirect addressing to access data in 64K-word segments on TNS architecture.
pTAL Pointers ° The addressing mode to use when accessing the data: ° ° Byte-addressed data, which can begin at any byte address Word-addressed data, which must begin at an even-byte address, regardless of which segment it is in A pointer has two data types associated with it: Data Type Description Object data type Data type of the objects that the pointer can reference Address type Data type of the addresses that you can store in the pointer Figure 10-1 on page 10-7 shows two pointer declaratio
pTAL Pointers Table 10-2. Address Types Data Type Address Type BADDR Pointer Size Target Data* TNS Native Example byte 8-bit bytes in the user data segment 16 32 STRING .s; WADDR word 16-bit words in the user data segment 16 32 INT .i; CBADDR byte 8-bit bytes in a user code segment 16 32 STRING s=‘P’:="A"; CWADDR word 16-bit words in a user code segment 16 32 INT i=’P’:=123; SGBADDR byte 8-bit bytes in system globals 16 16 STRING .
Determining Address Types Pointers Figure 10-2. Pointer Declaration and Memory Allocation in TAL STRING .p := %H8000; p := 255; p: ! Store initial address in p ! Store 255 at byte offset %H8000 %h8000 255 %h8000 data type: STRING data type: INT VST002.vsd Figure 10-3 on page 10-9 is the same as Figure 10-2 on page 10-9 except that pTAL compiles the source code to run as a native process. • • p contains %H00008000%D, the 32-bit address of the data The address type of p is BADDR Figure 10-3.
Determining Address Types Pointers The names of the data types are derived from “B” for byte, “W” for word, “C” for code, “SG” and “SGX” from system globals, “PROC” from procedure, and “EXT” from extended. Table 10-3. Object Data Types and Their Address Types (page 1 of 2) Declaration Address Type Object Data Type STRING .s; BADDR STRING INT .i; WADDR INT INT(32) .j; WADDR INT(32) REAL .r; WADDR REAL REAL(64) .s; WADDR REAL(64) FIXED .f; WADDR FIXED UNSIGNED(n) .
Determining Address Types Pointers Table 10-3. Object Data Types and Their Address Types (page 2 of 2) Declaration Address Type Object Data Type STRING .SGX s; SGXBADDR STRING INT .SGX i; SGXWADDR INT INT(32) .SGX j; SGXWADDR INT(32) REAL .SGX r; SGXWADDR REAL REAL(64) .SGX s; SGXWADDR REAL(64) FIXED .SGX f; SGXWADDR FIXED UNSIGNED(n) .
Determining Address Types Pointers Data in the User Data Segment (BADDR and WADDR Address Types) The address type of pointers declared without .EXT to data in the user data segment is WADDR, except for STRING pointers, for which the address type is BADDR: INT a; INT .b; STRING .c; INT(32) d[0:9]; INT .
Determining Address Types Pointers Procedures, Procedure Pointers, and Procedure Entry Points (PROCADDR Address Types) The address type of procedures, procedure pointers (PROCPTRs), and procedure entry points is PROCADDR: PROCADDR pa; PROCPTR q( j ); INT j; END PROCPTR; PROC p( j ); INT j; BEGIN ENTRY p1; ...
@ Operator Pointers Data in Extended Memory (EXTADDR Address Types) The address type of all pointers to extended memory segments is EXTADDR. Extended memory pointers are allocated in the user data segment and usually point to data in an extended memory segment; however, because an EXTADDR is 32 bits, you can store the address of any of your processes’ data in an extended memory pointer.
pTAL Pointers Table 10-4.
pTAL Pointers Example 10-1. @ Operator Applied to Structure Elements (page 2 of 2) STRUCT .EXT t; BEGIN STRUCT s1; BEGIN INT k; END; END; ! Structure in extended memory ... ... ... ... ... ... ... ... ... ... ! ! ! ! ! ! ! ! ! ! := := := := := := := := := := @i; @j; @sw; @sb; @s; @s.s1; @t; @t.s1; @s.s1.k; @t.s1.
Operations on Addresses Pointers Operations on Addresses TAL Addresses are 16-bit or 32-bit integers. Because an address is an integer, you can perform any operation on an address that you can perform on a 16-bit or 32-bit integer.
Converting Between Addresses and Numbers Pointers Example 10-3. Storing Addresses in Pointers and Variables (pTAL) Invalid: INT .i; INT .EXT j; WADDR w; BADDR b; EXTADDR e; i := @b; ! ERROR: Cannot store WADDR into INT Valid: INT .i; INT .
Converting Between Addresses and Numbers Pointers Example 10-4. Numeric Conversions With BADDR and WADDR Addresses (pTAL) Invalid: INT i; INT .j; STRING .s; i := @j; i := @s; @j := i; @s := i; i := @p; ! ! ! ! ! ERROR: ERROR: ERROR: ERROR: ERROR: Cannot Cannot Cannot Cannot Cannot move WADDR (@j) to INT (i) move BADDR (@s) to INT (i) move variable INT (i) to WADDR (@j) move variable INT (i) to BADDR (@s) convert address to INT Valid: DEFINE nil = 0#; STRUCT s(*); BEGIN WADDR next; END; INT i; INT .
Implicit Conversions Pointers Example 10-5.
Implicit Conversions Pointers In the preceding code, the address type of SRC is WADDR, but the address type of DEST is EXTADDR. The native compiler automatically converts the address type of SRC to EXTADDR. • Call-by-reference actual parameters The native compiler automatically converts the address type of an actual parameter to the address type of a formal parameter: PROC p (i); EXTADDR .i; BEGIN ... END; PROC p2; BEGIN INT .
Converting Between Address Types Pointers Table 10-6. Valid Address Conversions (see also Table 10-5 on page 10-21) To From SGWADDR SGWXADDR EXTADDR BADDR Note 2 WADDR Note 2 CBADDR Note 2 CWADDR Note 2 PROCADDR INT SGBADDR SGBXADDR Note 1 Note 2 Note 3 SGWADDR/ SGWXADDR Identity Note 2 Note 4 EXTADDR INT32 Identity PROCADDR Identity INT Identity Note 5 INT32 Note 5 Identity 1.
Converting Between Address Types Pointers • • $WADDR_TO_BADDR(x) $WADDR_TO_EXTADDR(x) These routines are described in Section 17, TAL Standard Routines. The $DBL and $INT routines accept address arguments. $DBL accepts an EXTADDR address as an argument and converts it to a 32-bit integer. $INT accepts a variable whose data type is any of SGBADDR, SGWADDR, SGXBADDR, and SGXWADDR as an argument, and returns a 16-bit integer. No other address types can be used as an argument to $INT.
Pointer Arithmetic Pointers Example 10-7. Address Shifts (pTAL) Invalid: INT a; STRING .b; INT(32) .SG c; STRING .SGX d; @c := @b '>>' 1; ! ERROR: Cannot convert BADDR to SGWADDR Valid: INT a; STRING .b; INT(32) .SG c; STRING .SGX d; @b := @a '<<' 1; @c := @d '>>' 1; ! Convert WADDR to BADDR ! Convert SGXBADDR to SGWADDR Pointer Arithmetic TAL All addresses are INT or INT(32) values, which you can use as operands in expressions anywhere an INT or INT(32) value is valid.
Pointer Arithmetic Pointers Table 10-8. Valid Address Expressions (page 1 of 2) Template1 Result Type Example atype [k]; atype INT .EXT p; @p := @p[2]; atype ‘+’ int16 atype atype INT .p; @p := @p '+' 2; atype ‘-’ int16 atype atype INT .p; @p := @p '-' 4; int16 ‘+’ atype atype INT .p; @p := 2 '+' @p; extaddr + int32 extaddr INT .EXT p; @p := @p + 4D; extaddr - int32 extaddr INT .EXT p; @p := @p - 8D; int32 + extaddr extaddr INT .EXT p; @p := 4D + @p; atype - atype int2 INT .b, .
Pointer Arithmetic Pointers Table 10-8. Valid Address Expressions (page 2 of 2) Template1 Result Type Example procaddr relational procaddr int PROCADDR pa; procptr relational procaddr int PROCPTR p;END PROCPTR; IF @p '=' pa THEN...; 1. atype is any data type except PROCADDR and EXTADDR. 2.
Pointer Arithmetic Pointers Example 10-8. Stepping Pointers Using Indexing (pTAL) (page 2 of 2) INT .pa := @a; STRING .pb := @b; INT .
Pointer Arithmetic Pointers If you increment or decrement a pointer in pTAL, the semantics are the same as those of TAL. That is, the number that you add to a byte address such as a BADDR address is the number of bytes to advance the pointer. Similarly, the number that you add to a word address such as a WADDR is the number of 16-bit words to advance the pointer, not the number of 32-bit words.
Pointer Arithmetic Pointers Example 10-9. Stepping Pointers Using Arithmetic (pTAL) (page 2 of 2) Valid: PROC p; BEGIN STRING .s[0:79]; STRING .sp; ... ! Read data into STRING buffer s @sp := @s; ! Initialize sp to beginning of s ... @sp := @sp '+' 2; @sp := @s '+' $LEN(s) '-' 2; ! Skip to third byte of s ! Skip to last two bytes of s ! Note that @s + $LEN(s) adds ! 16-bit integer to ! WADDR value, which produces ! WADDR value from which ! 16-bit integer, 2, ! is subtracted END; PROC p2; BEGIN STRING .
Pointer Arithmetic Pointers Rules for subtracting one address from another: • • • Neither address can be a PROCADDR address. The addresses must be the same type except that: ° ° SGBADDR and SGXBADDR are interchangeable. SGWADDR and SGXWADDR are interchangeable.
Pointer Arithmetic Pointers Comparing Addresses to Addresses (pTAL) Rules for comparing addresses to addresses: • • • • • The addresses must be the same type except that: ° ° SGBADDR and SGXBADDR are interchangeable. SGWADDR and SGXWADDR are interchangeable. To compare EXTADDR addresses, you must use signed relational operators (<, =, >,<=, <>, >=). To compare all other address types, you must use either: ° ° ° Unsigned relational operators ('<', '=', '>'.
Pointer Arithmetic Pointers Example 10-12. Comparing Addresses to Constants (pTAL) STRUCT .s[0:99]; BEGIN WADDR next; END; PROC p1; BEGIN INT .p(s); IF p.next <> %HFFFF THEN @p := p.
Pointer Arithmetic Pointers Example 10-14. Abbreviated Comparisons TAL INT .p; INT .EXT .q; IF @p THEN ... IF NOT @p THEN ... ! Equivalent to "IF @p <> 0 THEN ..." ! Equivalent to "IF @p = 0 THEN ..." IF @q <> 0D THEN ... IF NOT @q = 0D THEN ... ! Must specify 0D ! Must specify 0D pTAL INT .p; INT .EXT q; IF @p THEN ... IF NOT @p THEN ... ! Equivalent to "IF @p <> 0 THEN ..." ! Equivalent to "IF @p = 0 THEN ..." IF @q THEN ... IF NOT @q THEN ... ! Equivalent to "IF @q <> 0D THEN ...
Using Addresses in Expressions Pointers Using pointer arithmetic described in the preceding topics, you can rewrite the expression in Figure 10-4 on page 10-33 so that it is valid in pTAL. Figure 10-5 on page 10-34 shows how you can create an expression with valid operations on addresses. BASE0 is a WADDR value equal to zero. Subtracting BASE0 from @x produces a 16-bit INT for which addition, multiplication, and division are defined.
Pointers That Have Different Widths on TNS and Native Architectures Pointers Example 10-15. Using Addresses in Expressions (TAL) INT .EXT p; INT i; @p := @p + $UDBL(i) - 2D; pTAL pTAL enforces strong-typing rules for address types. You must explicitly specify all data type conversions. pTAL does not convert addresses from one type to another automatically.
Pointers That Have Different Widths on TNS and Native Architectures Pointers pTAL On native architecture, every pointer holds a 32-bit byte address.
Pointers That Have Different Widths on TNS and Native Architectures Pointers • @sp := @sp '+' 2; ! @sp := %H202; Adding 2 to a byte address on native architecture is the same as on TNS architecture. • @p := @p[3]; ! @p := %H208; Indexing the word address in p by 3 on TNS architecture requires indexing that word address by 6 on native architecture. • @sp := @sp[3]; ! @sp := %H205; Indexing the address in sp by 3 on native architecture is the same as on TNS architecture.
Pointers That Have Different Widths on TNS and Native Architectures Pointers Table 10-9. Pointer Widths (page 2 of 2) Native Architecture TNS Architecture Pointer Address Type Pointer Width Address Unit Pointer Width Address Unit INT INT INT INT INT WADDR CWADDR SGWADDR SGXWADDR EXTADDR 16 16 16 16 32 word word word word byte 32 32 16 32 32 byte byte word byte byte PROCADDR 16 N. A. 32 N. A. .p; .p = ‘P’ := "AB"; .SG p; .SGX p; .EXT p; PROCPTR p; END PROCPTR; Note.
Pointers With the Same Widths on TNS and Native Architectures Pointers Figure 10-6 on page 10-38 illustrates the following points: • • • • The source code is the same for both TNS and native processes. TAL allocates 16 bits for a standard pointer on TNS architecture. pTAL allocates 32 bits for a standard pointer on native architecture. A standard pointer holds a word address on TNS architecture, but holds a byte address on native architecture.
REFALIGNED(2) Pointers REFALIGNED(2) If a pointer specifies REFALIGNED(2), pTAL emits conservative code each time you reference the pointer. For example, you might specify a REFALIGNED(8) compiler directive because you know that most data will be allocated by the compiler and, therefore, will be wellaligned. You might have a pointer, however, that accesses a data item in a record on a heap.
Alternatives to Using Address Constants in Native Processes Pointers Example 10-18. Nonstructure Pointer With REFALIGNED(8) Clause ?REFALIGNED(2) ... INT .f REFALIGNED(8); INT .g; PROC p; BEGIN ... DO IF g THEN ...; IF f THEN ...
Alternatives to Using Address Constants in Native Processes Pointers Figure 10-7. User Data Segment on TNS Architecture TNS segment limit %177777 Upper 32K Words TNS stack limit %100000 Lower 32K Words TNS stack area Secondary global variables 'G'+0 Primary global variables VST035.vsd TAL programs can store the number 3 in the first word of the upper 32K words of the user data segment by storing the address %100000 in a pointer and using the pointer in a statement, as in the following code: INT .
Alternatives to Using Address Constants in Native Processes Pointers Example 10-19.
Alternatives to Using Address Constants in Native Processes Pointers Example 10-20. pTAL Space Allocation (page 2 of 2) ?IFNOT PTAL ?MEM 64 ?SOURCE EXTDECS(LASTADDR) ?ENDIF ...
11 Structures Structure declarations in TAL are upward compatible with pTAL structure declarations. In pTAL, you can use a FIELDALIGN clause or FIELDALIGN compiler directive to control how the compiler aligns a structure in memory and how it aligns the fields of the structure within the structure.
Pictorial Overview of pTAL Structure Alignment Structures Alignment guidelines for native processes: • • • • Accessing data in memory takes the least amount of time if the data is well-aligned and either the compiler has allocated the data or you reference the data with a pointer that specifies REFALIGNED(8). A data item is well-aligned if its byte address is an integral multiple of its length.
Pictorial Overview of pTAL Structure Alignment Structures Table 11-1. Structure Base Alignment Width of Widest Field in Structure FIELDALIGN (SHARED2) FIELDALIGN (SHARED8) 1 1 or 2* 1 or 2* 2 2 2 4 2 4 8 2 8 * Definition (inline) substructures have a base alignment of one. All other structures—definition structures, referral structures, and referral substructures—have a base alignment of two.
Pictorial Overview of pTAL Structure Alignment Structures Figure 11-1.
Pictorial Overview of pTAL Structure Alignment Structures Figure 11-2.
Pictorial Overview of pTAL Structure Alignment Structures Figure 11-3 on page 11-6 shows a structure that is declared FIELDALIGN(SHARED8). The widest fields in s2, i32a and i32b, are each four bytes; therefore, although the field alignment of s2 is SHARED8, the base alignment of s2 is four, not eight. s2 is well-aligned in memory if the base of the structure begins at any address that is a multiple of four. Figure 11-3.
Overview of Field Alignment Structures Figure 11-4 on page 11-7 shows which fields are misaligned if s2 is allocated at an address other than a four-byte address. Figure 11-4.
Overview of Field Alignment Structures • AUTO directs the compiler to align structure fields for optimal access for the intended process type of the object file. Specify AUTO only for structures whose data exists solely within a process, or across multiple processes of the same type. In general, the optimal layout of a structure on native architecture is not the same as the layout of a structure generated by TAL.
Field and Base Alignment Structures Field and Base Alignment The field alignment of a structure specifies the offsets at which fields of the structure must begin relative to the base of the structure. A scalar field is well-aligned when its byte offset is an integral multiple of its width. A substructure is well-aligned when the offset of its base, relative to its encompassing structure, is an integral multiple of its widest field.
Definition Structure Syntax Structures Definition Structure Syntax identifier STRUCT . .EXT .SG .SGX structure-layout range ; field-alignment VST624.vsd . .EXT .SG .SGX are indirection symbols. identifier is the identifier of the new referral structure. range [ lower-bound : upper-bound ] VST993.
Definition Structure Syntax Structures field-alignment FIELDALIGN ( SHARED2 ) SHARED8 AUTO PLATFORM VST992.vsd FIELDALIGN specifies how you want the compiler to align the base of the structure and fields in the structure. The offsets of fields in a structure are aligned relative to the base of the structure.
Definition Structure Syntax Structures • • • • The byte offset of a four-byte field (INT(32), REAL, UNSIGNED(17-31)) must be an integral multiple of four, except that contiguous UNSIGNED fields can be packed. The byte offset of an eight-byte field (FIXED or REAL(64)) must be an integral multiple of eight. The byte offset of a substructure field must be an integral multiple of the widest field in the substructure.
Template Structure Syntax Structures Example 11-1. Indirect Definition Structures STRUCT .inventory1[0:49]; BEGIN INT item; FIXED(2) price; INT quantity; END; ! Standard indirect structure STRUCT .EXT inventory2[0:9999]; BEGIN INT item; FIXED(2) price; INT quantity; END; ! Extended indirect structure Template Structure Syntax STRUCT STRUCTALIGN identifier ( ( MAXALIGN structure-layout * ) ) ; field-alignment VST625.vsd identifier is the identifier of the template structure.
Template Structure Syntax Structures field-alignment FIELDALIGN ( SHARED2 ) SHARED8 AUTO PLATFORM VST992.vsd FIELDALIGN specifies how you want the compiler to align the base of the structure and fields in the structure. The offsets of fields in a structure are aligned relative to the base of the structure. If a definition substructure does not specify a FIELDALIGN clause, the contained substructure’s field alignment is the field alignment of its encompassing structure or substructure.
Referral Structure Syntax Structures PLATFORM specifies that the structure and the fields of the structure must begin at addresses that are consistent across all languages on the same architecture. pTAL allocates such structures according to the rules used by the native mode HP C compiler for AUTO layouts. Referral Structure Syntax The syntax of a pTAL referral structure is the same as in TAL. You cannot specify a FIELDALIGN clause on a referral structure declaration.
REFALIGNED Clause Structures REFALIGNED Clause You can specify the REFALIGNED clause on any pointer field: STRUCT s; BEGIN INT .d REFALIGNED(2); INT .EXT e REFALIGNED(8); END; ! Standard pointer with ! REFALIGNED clause ! Extended pointer Field d is a 16-bit pointer on TNS architecture, but is a 32-bit pointer on native architecture and is valid only if the field alignment of structure s is AUTO or PLATFORM.
FIELDALIGN Compiler Directive Structures FIELDALIGN Compiler Directive As with the FIELDALIGN clause, the parameters to the FIELDALIGN compiler directive include SHARED2, SHARED8, PLATFORM, and AUTO. In addition, you can specify NODEFAULT as the parameter to the FIELDALIGN compiler directive. If you specify FIELDALIGN(NODEFAULT), you must specify a FIELDALIGN clause on every definition structure and template structure declaration in your program.
Using Field Alignment Structures Using SHARED2 Field Alignment The memory layout of a pTAL structure declared with FIELDALIGN(SHARED2) is the same as the memory layout of a structure compiled by the TAL compiler. The structure uses TNS memory optimally, but references to the structure’s fields might be slower on native architecture than if you declare the structure with SHARED8 field alignment.
Using Field Alignment Structures Note. If you include a FIELDALIGN(SHARED2) compiler directive, include a REFALIGNED(2) compiler directive as well. The default for the REFALIGNED compiler directive is 8. With field alignment SHARED2, pTAL can allocate a 32-bit or 64-bit field at any even-byte address. pTAL generates optimal code for data references that use a pointer whose reference alignment is 8.
Using Field Alignment Structures • • • pTAL requires you to explicitly declare filler items to optimally align a SHARED8 structure’s fields for native architecture. pTAL does not add filler automatically to SHARED8 structures and reports a syntax error if you do not declare filler where a structure requires it. The native compiler listing shows where each structure requires filler.
Using Field Alignment Structures The total number of bytes in a SHARED8 structure must be an integral multiple of the widest field in the structure. If needed, you must explicitly declare filler at the end of a SHARED8 structure to ensure this condition. In Example 11-4 on page 11-21, filler is required at the end of each structure. Example 11-4.
Using Field Alignment Structures Example 11-6.
Using Field Alignment Structures Using AUTO Field Alignment If you specify FIELDALIGN(AUTO), the compiler determines the optimal alignment for fields and structures based on the architecture on which you will run your program. TAL aligns an AUTO structure as SHARED2 for execution on TNS architecture. pTAL aligns an AUTO structure for execution on native architecture.
Arrays in Structures Structures Arrays in Structures When you declare an array in a structure, the alignment of the beginning of the array is the alignment of the base type of the array; therefore, for example, the field alignment of an array of INTs is the same as the field alignment of a single INT, which is 2. Declaring an array in a structure is the same as explicitly declaring individual fields, each with the same data type as the array’s base type.
Optimizing Structure Layouts Structures The alignment for the structures in Example 11-7 on page 11-25 is: Structure Alignment S1 2 bytes S2 4 bytes S3 8 bytes S4 4 bytes Example 11-7.
Optimizing Structure Layouts Structures Example 11-8.
Considerations Structures Use SHARED8 structures with care in TNS processes. For example, using the structure s3 from Example 11-10 on page 11-26, you can declare a structure array such as: STRUCT s4(s3) [0:99]; s4 has six bytes of filler for each of its 100 occurrences, a total of 600 bytes of filler.
Structure Alignment Structures Structure Alignment A structure’s alignment is the alignment of the widest field declared in the structure and is always less than or equal to the alignment specified in a FIELDALIGN clause or FIELDALIGN compiler directive. See Table 5-1 on page 5-2 for alignment values of structure fields. The alignment of a field that is a substructure is the alignment of the widest field contained in the substructure. For more information, see Substructure Alignment on page 11-29.
Substructure Alignment Structures Substructure Alignment The rules for field alignment of substructures are the same as the rules for structures. You can specify the field alignment of a substructure explicitly using a FIELDALIGN clause or implicitly by allowing the field alignment of the substructure to default to the field alignment of the containing structure or substructure. In either case, the alignment of fields must conform to the rules described previously, under “Using Field Alignment.
Reference Alignment With Structure Pointers Structures Reference Alignment With Structure Pointers When you declare a structure pointer, you can specify a REFALIGNED clause as part of the declaration. (See Section 10, “Pointers,” for the syntax of a structure pointer.) You can use a REFALIGNED clause to override the base alignment of an instance of a structure, even though the field alignment for the structure does not change.
REFALIGNED(2) Structures Example 11-13. Default Reference Alignment (page 2 of 2) STRUCT s3 FIELDALIGN(AUTO); BEGIN INT i; INT(32) j; END; INT .p1(s1); INT .p2(s2); INT .p3(s3); ! Reference alignment is 2 ! Reference alignment is 8 ! Reference alignment is 2 on TNS architecture, ! 8 on native architecture REFALIGNED(2) When a structure pointer specifies REFALIGNED(2), the base of the structure might or might not be well-aligned for access on native architecture.
REFALIGNED(8) Structures Example 11-14. REFALIGNED(2) (page 2 of 2) STRUCT s(s_templ); ! Template PROC p(struct_addr, p1); WADDR struct_addr; INT .p1(s_templ); ! Use template BEGIN INT .p2(s); ! Reference compiler-allocated structure ! with SHARED8 alignment INT .p3(s_templ) REFALIGNED(2) = p2; ! Equivalence p3 to p2 INT .p4(s_templ) REFALIGNED(2) := struct_addr; ! Use template but use address passed as parameter INT .
REFALIGNED(8) Structures If a structure pointer specifies REFALIGNED(8) or inherits its reference alignment from a SHARED8 structure, but the base of the structure is not well-aligned, your program might run significantly slower than you anticipate. You will observe significantly degraded performance if your REFALIGNED(8) pointer references a structure field that is not, in fact, well-aligned.
Alignment Considerations for Structures and Substructures Structures For the assignment i32 := p3.s.i, pTAL generates fast code to access the field because the declaration of p3 does not include a REFALIGNED clause. The reference alignment therefore defaults to the field alignment of t2, which is SHARED8. Even though the layout of p3 is based on t2 (which, in turn, incorporates t1, which is SHARED2), the reference alignment of p3 is 8 because t2 is SHARED8.
pTAL Code Generation for Structure References Structures pTAL Code Generation for Structure References When pTAL generates code for references to the fields of structures and substructures, it generates two kinds of code. These are referred to as: • • Fast code Conservative code pTAL generates fast code if you reference fields in a structure compiled with FIELDALIGN(SHARED8). It generates conservative code if you reference fields in a structure compiled with FIELDALIGN(SHARED2).
pTAL Code Generation for Structure References Structures In Example 11-17 on page 11-35: • • Because s1 specifies SHARED2 field alignment, pTAL generates conservative code that ensures that an exception does not occur when you reference s1.s2.j. p2 refers to t_s8, a SHARED8 substructure. p2 specifies a reference alignment of 2, which ensures that pTAL generates conservative code that will not cause exceptions for misaligned memory references. p3 does not have a REFALIGNED clause.
pTAL Code Generation for Structure References Structures Example 11-19. Fast Code and Conservative Code (page 2 of 2) STRUCT s5 FIELDALIGN(SHARED8); BEGIN INT i, k; STRUCT s6(s3_shared2); END; INT .p6(s3_shared2); In Example 11-19 on page 11-36: • • pTAL generates fast code for a reference to s5.s6.J because s5.s6.j is at a four-byte offset from s5, which is also well-aligned: References to p6.
Structures pTAL Code Generation for Structure References pTAL Conversion Guide —527302-002 11 -38
12 Equivalenced Variables Equivalenced variables in pTAL are more restricted than in TAL. TAL imposes very few limitations on equivalenced declarations. In pTAL, you can equivalence only specific, well-defined combinations of variables.
Terminology Equivalenced Variables • Direct equivalenced variable A direct equivalenced variable is a simple variable, direct array, direct structure, standard pointer (including a standard structure pointer), or extended pointer (including an extended structure pointer). Direct items can be equivalenced only to other direct items (with two exceptions noted later in this topic).
Terminology Equivalenced Variables Figure 12-1. Indirect Arrays in TAL and pTAL TAL or pTAL Indirect Array INT .A[0:3] := [10,20,30,40]; ! Object date type: INT ! Address type: WADDR TAL Layout A's data: .A: 1000 1000 1001 1002 1003 10 20 30 40 VST043.vsd pTAL Layout 10 20 30 40 A: 1000 1001 1002 1003 VST121.vsd Example 12-1. Valid and Invalid Uses of Equivalenced Pointers INT .a[0:3]; INT .
Declaring Equivalenced Nonstructures Equivalenced Variables Declaring Equivalenced Nonstructures pTAL equivalenced declarations for nonstructure variables include two features that are not supported by TAL: • • Equivalenced arrays An optional REFALIGNED clause on an equivalenced pointer VOLATILE type identifier = ( referral ) previous-identifier ; [ index + offset ] , VST629.vsd VOLATILE specifies that the value of this variable must be maintained in memory, not in a register.
Declaring Equivalenced Nonstructures Equivalenced Variables referral is the identifier of a previously declared structure, structure layout, or structure pointer. previous-identifier the identifier of a previously-declared variable, direct array element, pointer, structure, structure pointer, or equivalenced variable. index is an INT constant that specifies an element offset from previous-ident to which the equivalenced pointer or variable refers. Specify index only with direct variables.
Declaring Equivalenced Structures Equivalenced Variables Declaring Equivalenced Structures pTAL adds a FIELDALIGN clause to TAL equivalenced structure declarations. identifier STRUCT ( referral ) . .EXT = previous-identifier field-alignment ; [ index + offset ] structure-layout VST632.vsd - . (period) is the indirection symbol for standard addressing. .EXT is the indirection symbol for extended addressing. identifier is the identifier that the declaration creates.
Declaring Equivalenced Structures Equivalenced Variables field-alignment ( FIELDALIGN SHARED2 ) SHARED8 AUTO PLATFORM VST992.vsd specifies the memory alignment for the base of the structure and for fields within the structure. See Section 11, Structures, for details about the FIELDALIGN clause. previous-identifier is the name of a previously declared simple variable, direct array element, structure, structure layout, structure pointer, or equivalenced variable.
Declaring Equivalenced Variables Equivalenced Variables Example 12-3.
Equivalencing Standard Pointers to Indirect Items Equivalenced Variables Example 12-4. Valid and Invalid Equivalenced Declarations WADDR a; ! a is 16 bits on TNS architecture, ! 32 bits on native architecture INT .
Equivalencing Extended Pointers to Extended Items Equivalenced Variables Table 12-1. Valid Equivalenced Variable Declarations Equivalenced Variable Category Equivalenced Variable Variable Example Previous Variable Category Direct Simple variable INT i; Direct or Pointer Direct array INT i[0:3]; Direct structure STRUCT s; BEGIN INT i; END; Indirect array INT Indirect structure STRUCT .s; BEGIN INT i; END; Extended array INT Extended structure STRUCT .
Equivalenced Variable Must Fit Within Previous Variable Equivalenced Variables Example 12-6. Equivalencing Extended Pointers to Extended Items (page 2 of 2) INT .EXT d[0:9]; ! Extended array INT .
Declaring Structures in Equivalenced Declarations Equivalenced Variables Figure 12-2. Equivalenced Variables That Are Valid in TAL But Not in pTAL s r[0] 0 r[1] 1 INT r[0:2]; r[2] 2 t 3 4 INT(32) s = r[2]; 5 INT t = r[5]; 6 VST005.vsd Figure 12-3. Equivalenced Arrays INT(32) i; INT j[0:1] = i; INT k[0:3] = i; ! ERROR: k is not contained within i i j[0] j[1] k[0] k[1] 0 1 k[3] k[2] 2 3 4 5 6 VST006.
Declaring Pointers in Equivalenced Declarations Equivalenced Variables If you declare b and then declare a, the pTAL compiler does not report an error, because a fits within the four bytes already allocated for b. Example 12-9.
Equivalencing PROCADDRs and PROCPTRs Equivalenced Variables Table 12-2. Data Types for Equivalenced Variables Example Object Data Type Address Type INT INT INT a; .b; .EXT c; INT INT INT WADDR WADDR EXTADDR BADDR BADDR BADDR d; .e; .EXT f; BADDR BADDR BADDR WADDR WADDR EXTADDR EXTADDR g; EXTADDR .h; EXTADDR .EXT i; EXTADDR EXTADDR EXTADDR WADDR WADDR EXTADDR STRING STRING STRING STRING STRING STRING BADDR BADDR EXTADDR j; .k; .
Using Structure Variants Equivalenced Variables Example 12-11. Equivalencing PROCADDRs and PROCPTRs (page 2 of 2) PROCPTR f; END PROCPTR = b; ! f is a procedure pointer equivalenced ! to a procedure address Using Structure Variants In TAL and pTAL, you use substructures to declare variant records in structures. pTAL does not detect addresses that are redefined by equivalenced variant substructures. Example 12-12. Structure Variants STRUCT s FIELDALIGN(AUTO); BEGIN STRUCT v1; BEGIN INT .p; ! .
Using a REFALIGNED Clause With Equivalenced Declarations Equivalenced Variables Example 12-13. Structure Variants in Reverse Order of Example 12-12 STRUCT s FIELDALIGN(AUTO); BEGIN STRUCT v1; BEGIN INT .EXT e; ! e is 4 bytes on TNS & native architectures END; STRUCT v2 FIELDALIGN(SHARED8) = v1; BEGIN INT .p; ! p is 2 bytes on TNS architecture, ! 4 bytes on native architecture INT q; ! pTAL reports a warning END; END; Note. In pTAL, v2 is eight bytes to maintain the alignment of variables in native memory.
Using the FIELDALIGN Clause Equivalenced Variables Using the FIELDALIGN Clause You can include a FIELDALIGN clause in an equivalenced structure declaration. The FIELDALIGN clause specifies the alignment of the fields of a structure and the alignment of the structure itself in memory. You can use an equivalenced declaration to create two layouts for the same area, one of which is optimized for pTAL programs running as TNS processes, the other optimized for pTAL programs running as native processes.
pTAL Equivalenced Variables pTAL pTAL requires .SG (or .SGX) indirection notation for pointers to data in system globals and for fields within a structure in system globals; therefore, it accepts only the second pair of declarations. Example 12-16. .SG Notation in pTAL STRUCT .SG s = 'SG' + 0; BEGIN INT .SG i; INT(32) .SG j; STRUCT BEGIN INT END; k; .SG m; INT END; n; Using Equivalenced Variables You can use an equivalenced variable in an expression anywhere an operand is valid.
13 Expressions This section describes differences between TAL and pTAL expressions in the following areas: • • • • • • • Using 16-bit Operands and Operations on page 13-1 Using Unsigned Operators and INT(32) Operands on page 13-4 Comparing Addresses on page 13-6 Using Indexing on page 13-8 Using FIXED(*) Variables on page 13-9 Relational Operators and Condition Codes on page 13-10 Group Comparison Expressions on page 13-10 Using 16-bit Operands and Operations This section gives considerations for using
Results After Overflow Expressions Results After Overflow The result of the code in Example 13-1 on page 13-2, which assumes that overflow traps are disabled, is different for TNS and native processes: TNS Native i+1 -32,768 32,768 i+1 > 0 FALSE TRUE Example 13-1. Overflow Results That Vary For TNS and Native Processes INT i := 32767; IF i + 1 > 0 THEN ...
Guaranteeing 16-Bit Results Expressions Example 13-3. Overflow INT i := 32767; INT j; j := i + 1; IF j < 0 THEN ... Guaranteeing 16-Bit Results The native compiler generates extra instructions that ensure that 16-bit operators generate 16-bit results, except in these cases: • • • The result of the +, -, *, /, and << operators is undefined if the result has more than 16 bits.
Using Unsigned Operators and INT(32) Operands Expressions Example 13-4. Using Result of 16-bit Operator After an Overflow INT i; i := 32767; i := i + 1; IF i = %H8000 THEN ... ! Largest positive signed 16-bit value ! Value of i is now undefined ! Conditional expression is TRUE ! in TNS processes, ! undefined in native processes Using Unsigned Operators and INT(32) Operands In pTAL, you can use INT(32) operands with some operators with which you can use only INT operands in TAL.
Expressions Using INT(32) Operands With Unsigned Comparison Operators Using INT(32) Operands With Unsigned Comparison Operators In pTAL, you can use INT(32) operands with unsigned comparison operators ('<', '<=', '=', '<>', '>=', and '>'). The INT(32) operands are treated as nonnegative values in the range 0 to 232 -1. Using INT(32) Operands With Unsigned Add and Subtraction Operators In pTAL, you can use INT(32) operands with unsigned addition and subtraction operators ('+' and '-').
Comparing Addresses Expressions Comparing Addresses In pTAL, the rules for comparing address types are more restrictive than the rules for comparing non-address types. Table 13-1 on page 13-6 shows valid address-type comparisons in pTAL. Table 13-1.
Comparing Nonextended Addresses Expressions Example 13-5. Comparing Extended Addresses EXTADDR e; INT .EXT i; IF IF IF IF IF IF e < @i THEN ... @i >= 0D THEN ... e = 0D THEN ... e <> 0D THEN ... e THEN ... NOT e THEN ... ! ! ! ! ! ! OK: e and @i are both EXTADDR OK: @i is EXTADDR, 0D is 32 bits OK OK OK OK IF e > i THEN ... ! ERROR: e is EXTADDR, i is INT IF e '<' @i THEN ...
Using Indexing Expressions Using Indexing TAL You can index any variable except an entire structure, which you can index only if it is a structure array. pTAL You cannot index simple variables or value parameters because they do not point to arrays. You can, however, index the following simple variables: • • • • Variables in any global data block, including the unnamed global data block Equivalenced variables and reference variables Direct SG variables Fields of a structure Example 13-6.
Using FIXED(*) Variables Expressions Example 13-6. Indexing in TAL and pTAL (page 2 of 2) t := i7 [1]; ! OK: i7 is referenced in an equivalence ! declaration t := i8 [1]; t := j [1]; t := k [1]; ! OK: i8 is an equivalenced variable ! ERROR: cannot index a value parameter ! OK: k is a reference parameter t := m [1]; ! OK: m is referenced in an equivalenced ! declaration t := s1.a[1]; t := s1.
Relational Operators and Condition Codes Expressions Relational Operators and Condition Codes TAL A condition code (a 2-bit field in the processor status word)—reflects the value of the most recently evaluated arithmetic or conditional expression: Condition Code Meaning CCL Condition code less than CCE Condition code equal CCG Condition code greater than pTAL pTAL simulates this 2-bit field when you use a condition code. You can access this field only by means of the condition code notation.
Changing the Data Type of the Data Expressions Topics: • • Changing the Data Type of the Data on page 13-11 Changing the Location of the Data on page 13-12 Changing the Data Type of the Data In TAL and pTAL, you can compare two strings using a group comparison expression, and save the address where the comparison stopped in a variable or pointer. In Figure 13-1 on page 13-11, the IF statement compares x to y on a word-by-word basis.
Changing the Location of the Data Expressions Figure 13-2. Ending Address After Comparing Strings of Data Type STRING and INT PROC p; BEGIN INT x[0:1] := ["AB","CD"]; STRING y[0:1] := ["A", "C"]; STRING .p; INT q; IF x = y FOR 1 WORDS -> @p THEN ... ; q := p; ! q is assigned "AB" on a TNS processor ! q is assigned "BC" on a TNS/R processor END; User Data Segment P B A B C D X A C Y VST012.
Changing the Location of the Data Expressions Figure 13-3. Ending Address After Comparing INT Strings in Extended Memory and the User Data Segment PROC p; BEGIN INT x[0:1] := ["AB","CD"]; STRING .EXT y[0:1] := ["AX"]; STRING .EXT p; INT q; IF x = y FOR 1 WORDS -> @p THEN ... ; q := p; ! q is assigned "AB" on a TNS processor ! q is assigned "BC" on a TNS/R processor END; P User Data Segment B A B C D X Extended Memory Segment A C Y VST013.
Changing the Location of the Data Expressions pTAL Conversion Guide —527302-002 13 -14
14 Bit Operations This section describes differences between bit operations in TAL and pTAL. Topics: • • Shift Operations on page 14-1 Using 32-Bit Operands With Bit Deposit and Bit Extract Operations on page 14-4 Shift Operations Topics: • • TAL on page 14-1 pTAL on page 14-2 TAL If the shift count is a constant or constant expression, the TAL compiler reports an error if the shift count is greater than or equal to 64.
pTAL Bit Operations Example 14-1.
pTAL Bit Operations If the shift amount is a dynamic expression and is greater than the maximum allowed (one bit less than the number of bits being shifted), the result depends on the CHECKSHIFTCOUNT compiler directive, as follows: • • If CHECKSHIFTCOUNT is enabled and a dynamic shift count is equal to or greater than the number of bits in the value being shifted, the system aborts your program with an instruction trap.
Bit Operations Using 32-Bit Operands With Bit Deposit and Bit Extract Operations Using 32-Bit Operands With Bit Deposit and Bit Extract Operations TAL You can perform bit extract and bit deposit operations only on 16-bit operands: INT i; INT j; INT(32) k; i := j.<12:15>; i := k.<12:15>; i := k.
pTAL Bit Operations pTAL Conversion Guide —527302-002 14- 5
pTAL Bit Operations pTAL Conversion Guide —527302-002 14- 6
15 Statements This section describes the differences between statements in TAL and pTAL. Table 15-1 on page 15-1 lists briefly the changes in each statement. Table 15-1. Summary of Statement Differences in pTAL (page 1 of 2) Statement Differences From TAL ASSERT No change. Assignment Statement on page 15-2 pTAL enforces strong typing. CALL Statement on page 15-7 The data types of formal and actual parameters must match.
Assignment Statement Statements Table 15-1. Summary of Statement Differences in pTAL (page 2 of 2) Statement Differences From TAL RETURN Statement on page 15-19 Procedures that return a condition code must specify the RETURNSCC procedure attribute and must explicitly specify, in the RETURN statement, the condition code to return.
Data Types Must Match Statements • If your program tests the value of the condition code after an assignment statement, it must follow guidelines that differ from those of TAL. Topics: • • • Data Types Must Match on page 15-3 Address Types Must Match on page 15-5 Changing Implicit Pointers on page 15-7 Data Types Must Match pTAL data type compatibility rules for assignment statements are more restrictive than those of TAL.
Data Types Must Match Statements Example 15-1.
Address Types Must Match Statements In TAL and pTAL, when an INT variable is assigned to a STRING variable, the upper eight bits of the INT variable are not retained in any way in the STRING variable. In Example 15-4 on page 15-5, the comparison of i1 to i2 in the final statement fails because i2 still holds the full 16 bits that were assigned to it at the beginning of the code, but i1 holds only the lower eight bits. The upper eight bits of i1 are not transferred to s in the assignment statement s := i1.
Address Types Must Match Statements Example 15-5.
Changing Implicit Pointers Statements Changing Implicit Pointers TAL You can change the implicit pointer of an indirect array or indirect structure. Example 15-6. Implicit Pointer Change (TAL) INT .a[0:99]; INT .b[0:99]; @a := @b; ! Change a to reference b's data pTAL You cannot assign a value to the implicit pointer of an indirect array or indirect structure.
CASE Statement Statements pTAL A procedure’s formal and actual parameters match if the data type of each formal parameter and its corresponding actual parameter match exactly or match if the data type of the actual parameter is converted according to the rules in Table 10-5 on page 10-21 and Table 10-6 on page 10-22. In Example 15-8 on page 15-8, TAL accepts all three parameters in the CALL statement; pTAL reports syntax errors for all three parameters to the CALL statement: Example 15-8.
CASE Statement Operation When No Alternatives Match the Index Statements Example 15-9.
Empty CASE Statements Statements Empty CASE Statements TAL The TAL compiler allows an empty, unlabeled CASE statement—that is, a CASE statement in which there are no alternatives, as in Example 15-10 on page 15-10. Example 15-10. Empty CASE Statement (TAL) CASE i OF BEGIN END; pTAL The native compiler requires that a CASE statement include at least one alternative, even if no statements are specified for that alternative. Example 15-10 on page 15-10 is invalid in pTAL.
DO-UNTIL Statement Statements DO-UNTIL Statement In pTAL, the conditional expression in a DO-UNTIL statement cannot reference hardware indicators—only IF statements can test hardware indicators. For more information, see Section 20, Hardware Indicators. Example 15-13 on page 15-11 is valid in TAL but not in pTAL. Example 15-13. DO-UNTIL Statement With Condition Code (TAL) DO BEGIN ... READ(...
DROP Statement Statements DROP Statement The DROP statement removes either a label (from the symbol table) or a temporary variable that was created by a USE statement. TAL A register allocated by a USE statement is accessible even after executing a DROP statement, although such access is a result of the implementation of TAL and is not a documented feature. Your program might execute a DROP statement explicitly, or it might execute a DROP statement implicitly by returning from a procedure.
Labels as Procedure Parameters Statements Labels as Procedure Parameters TAL You can declare a formal parameter to be a label, pass a label to the procedure when you call it, and use a GOTO statement to branch to the label parameter from the called procedure. Example 15-17. Labels as Procedure Parameters (TAL) PROC p1 (label_a); LABEL label_a; BEGIN GOTO label_b; END; ! Procedure with label parameter ! Go to label label_b in procedure p2 PROC p2; BEGIN ... CALL p1 (label_b); label_b: ...
Branching From a Subprocedure to Its Containing Procedure Statements Branching From a Subprocedure to Its Containing Procedure A GOTO statement can branch from a subprocedure to a label in the containing procedure. TAL You do not have to declare the label explicitly. Example 15-18. Branching From Subprocedure to Its Containing Procedure (TAL) PROC p1; BEGIN ... SUBPROC p2; BEGIN GOTO label_a; END; ... label_a: ...
Overflow Traps in pTAL Statements Overflow Traps in pTAL In pTAL, if a GOTO statement and the target of the GOTO statement are in different BEGIN-END blocks: • • Overflow trapping must be enabled in both blocks or disabled in both blocks. The respective overflow trapping states can be established by compiler directive, by procedure attribute, or by BEGIN-END block attribute.
IF Statement Statements IF Statement The IF statement conditionally selects one of two statements to execute. Topics: • • • Testing Address Types on page 15-16 Testing Hardware Indicators on page 15-16 Testing INT(32) Variables Without a Not-Equal Operator on page 15-16 Testing Address Types In both TAL and pTAL, an IF statement can test any 16-bit compatible value—INT, STRING, or UNSIGNED(1-16)—as if it were a Boolean value.
Move Statement Statements Example 15-22. Testing an INT(32) Variable Without a Not-Equal Operator (pTAL) INT(32) i; ... IF i THEN ... ! OK: same as "IF i <> 0D THEN ..." Move Statement A move statement copies a block of data from one location in memory to another. You specify the number of bytes, words, or elements to copy in the move statement.
Destination Shorter Than Source Statements Destination Shorter Than Source Unlike the TAL compiler, the native compiler reports a warning if it detects more bytes in the source of a move than in the destination of the move. For example, if the number of bytes to move is a constant or constant expression whose value is larger than the number of bytes in the destination.
RETURN Statement Statements RETURN Statement A RETURN statement causes a routine to return control to its caller. When you return from a function, the RETURN statement also specifies a value to return to the function’s caller. Note. In the discussion of the RETURN statement, the word “procedure” implies both procedures and subprocedures but not functions.
Returning a Value and Condition Code in TAL Statements Returning a Value and Condition Code in TAL The value of the condition code after returning from a function is based on the nature of the expression in the RETURN statement as well as on the value returned by the function. If a function’s value is the result of a computation, comparison, or load of a numeric value, the condition code is based on the sign of the value returned. Example 15-26.
Returning a Condition Code in pTAL Statements Example 15-27. Procedure Without RETURNSCC Attribute (pTAL) PROC p; BEGIN ... END; PROC q; BEGIN CALL p; IF < THEN ... END; ! ERROR: p did not return a condition code Example 15-28 on page 15-21 is the syntactically correct version of Example 15-27 on page 15-21. Example 15-28. Procedure With RETURNSCC Attribute (pTAL) PROC p RETURNSCC; BEGIN INT i; ... RETURN ,i; END; PROC q; BEGIN CALL p; IF < THEN ...
Returning a Condition Code in pTAL Statements Example 15-30. INT PROC p(i) RETURNSCC; INT i; BEGIN INT cc_result; ... cc_result := IF i < max_val THEN -1 ELSE IF i = max_val THEN 0 ELSE 1; RETURN i, cc_result; ! Return function value and END; ! condition code that indicates ! whether the function value is ! less than, equal to, or ! greater than some maximum A function or procedure that specifies RETURNSCC must include cc-expression on every RETURN statement.
SCAN and RSCAN Statements Statements Example 15-32. Function Returns Condition Code Based on Its Rturn Value (pTAL) INT PROC p(i); INT i; BEGIN ... RETURN i; ! Return i and set the condition code END; ! based on the numeric value of i Example 15-33. Function Returns Condition Code Not Based on Its Return Value (pTAL) INT PROC p(i) RETURNSCC; INT i; BEGIN ... RETURN i, f(i); ! Return the value of i and set the END; ! condition code according to the ! value returned by function f Example 15-34.
Extended Pointers Statements Extended Pointers TAL The scan variable in an SCAN or RSCAN statement must refer to data in the user data segment. pTAL The scan variable can refer to data declared with the .EXT indirection symbol. In this case, the address type of the next-address variable must be EXTADDR. Example 15-35. Extended Pointers in pTAL SCAN and RSCAN Statements (pTAL) STRING .EXT s; STRING .
Scanning Data in P-Relative Arrays Statements Example 15-36. pTAL Structure With FIELDALIGN(SHARED2) (page 2 of 2) BADDR end_addr; ... s.stopper := 0; SCAN s.buffer UNTIL char -> end_addr; IF end_addr = @s.stopper THEN BEGIN ! Target character was not found ... END; Scanning Data in P-Relative Arrays TAL The address type of pointers in an SCAN or RSCAN statement that scans a P-relative array must be CBADDR or CWADDR.
USE Statement Statements Example 15-38. Scanning Data in P-Relative Arrays (pTAL) STRING s = 'P' := [ 1, "msg1.", 2, "msg2.", 3, "msg3.
WHILE Statement Statements See the TAL Reference Manual and TAL Programmer’s Guide for specific information on optimized FOR loops. Although pTAL manages USE variables as it does INT variables, as in TAL, pTAL reports a syntax error if you apply an @ operator to a USE variable. Example 15-39. Invalid Use of @ Operator (pTAL) ! TAL code USE i; INT j; j := @i; ! pTAL reports syntax error ! Equivalent pTAL code USE i; WADDR j; j := @i; ! pTAL reports syntax error Avoid USE variables.
WHILE Statement Statements Example 15-41. WHILE Statement With Hardware Indicator (pTAL) INT continue_loop; ... continue_loop := TRUE; WHILE continue_loop DO BEGIN ... READ(...); IF <> THEN continue_loop := FALSE; END; Example 15-42 on page 15-28 is the same as Example 15-41 on page 15-28 except that it uses a GOTO statement to exit the WHILE loop. Example 15-42. WHILE Statement With Hardware Indicator and GOTO Statement (pTAL) WHILE true DO BEGIN ... READ(...); IF <> THEN GOTO out; END; out: ...
16 Procedures, Subprocedures, and Procedure Pointers Topics: • • • • • Procedure Syntax on page 16-1 Variable and Extensible Procedures on page 16-5 Procedure Pointers on page 16-6 Using PROCs as Formal Parameters on page 16-16 Procedure Parameters on page 16-17 Note. In this section, a reference to procedures is understood to mean a reference both to procedures and to subprocedures unless otherwise noted. Procedure Syntax pTAL syntax for procedure declarations differs from that of TAL.
Procedures, Subprocedures, and Procedure Pointers Procedure Syntax type is one of the following: • • • • • • • • • • • • • • • • • STRING INT INT(32) REAL REAL(64) UNSIGNED( width ) FIXED [ ( fpoint ) ] WADDR BADDR CWADDR CBADDR SGWADDR SGBADDR SGXWADDR SGXBADDR EXTADDR PROCADDR width is a constant integer expression from 1 through 31. fpoint is a constant integer expression from -19 through 19. identifier is the procedure identifier to use in the compilation unit.
Procedures, Subprocedures, and Procedure Pointers Procedure Syntax parameter-list ( ) param-name param-pair , VST210.vsd param-name is the identifier of a formal parameter. A procedure can have up to 32 formal parameters. param-pair is a pair of formal parameter identifiers that comprise a language-independent string descriptor in the form: string : length VST039.vsd string is the identifier of a standard or extended STRING simple pointer.
Procedures, Subprocedures, and Procedure Pointers Procedure Syntax proc-attribute MAIN INTERRUPT RESIDENT CALLABLE PRIV VARIABLE EXTENSIBLE ( count ) RETURNSCC OVERFLOW_TRAPS NOOVERFLOW_TRAPS LANGUAGE C COBOL FORTRAN PASCAL UNSPECIFIED VST635.vsd For descriptions of individual attributes (MAIN, INTERRUPT, and so on), see the TAL Reference Manual or the pTAL Reference Manual.
Procedures, Subprocedures, and Procedure Pointers Variable and Extensible Procedures All of the syntactic elements in the procedure syntax are the same in pTAL as they are in TAL except the following: • • • attribute can be empty. attribute can be RETURNSCC, OVERFLOW_TRAPS, or NOOVERFLOW_TRAPS. type can be an address type in addition to the types recognized by TAL. Example 16-1. Procedure Declaration (pTAL) INT var; ! Global INT WADDR PROC p(i) , RETURNSCC,; INT .
Procedures, Subprocedures, and Procedure Pointers pTAL pTAL In pTAL, variable and extensible procedures are implemented as extensible procedures; therefore, you can declare procedures variable or extensible but the effect is the same.
Procedures, Subprocedures, and Procedure Pointers • • • • • • • • • • • Procedure Pointers FIXED [ ( scale ) ] WADDR BADDR CWADDR CBADDR SGWADDR SGBADDR SGXWADDR SGXBADDR EXTADDR PROCADDR width is a constant integer expression from 1 to 31. scale is a constant integer expression from -19 to 19. procptr-name is a standard pTAL identifier. formal-param-names ( param-name ) param-pair , VST210.vsd param-name is the same as a TAL or pTAL formal procedure parameter.
Procedures, Subprocedures, and Procedure Pointers Procedure Pointers attributes MAIN INTERRUPT RESIDENT CALLABLE PRIV VARIABLE EXTENSIBLE ( count ) RETURNSCC OVERFLOW_TRAPS NOOVERFLOW_TRAPS LANGUAGE C COBOL FORTRAN PASCAL UNSPECIFIED VST635.vsd For descriptions of individual attributes (MAIN, INTERRUPT, and so on), see the TAL Reference Manual. In pTAL, attribute can be empty. TAL does not allow attribute to be empty. See RETURN Statement on page 15-19 for detailed information about RETURNSCC.
Procedures, Subprocedures, and Procedure Pointers Procedure Pointers formal-param-spec procptr param-type identifier . .EXT .SG .SGX ( referral ) , VST712.vsd param-type is any of: • • • • • • • • • • • • • • • • • STRING INT INT(32) REAL REAL(64) UNSIGNED( width ) FIXED [ ( scale ) ] WADDR BADDR CWADDR CBADDR SGWADDR SGBADDR SGXWADDR SGXBADDR EXTADDR, PROCADDR [ type ] PROC identifier is a standard pTAL identifier. referral is the name of a previously declared structure or structure pointer.
Procedures, Subprocedures, and Procedure Pointers Declaring PROCPTR Variables Topics: • • • • Declaring PROCPTR Variables on page 16-10 Declaring PROCPTRs in Structures on page 16-11 Procedures as Formal Parameters on page 16-13 Assigning Values to PROCPTR Variables on page 16-14 Declaring PROCPTR Variables You declare PROCPTR variables using the following syntax: procptr = prev-identifier := procaddr ; VST714.vsd procptr is as described previously in this section.
Procedures, Subprocedures, and Procedure Pointers Declaring PROCPTRs in Structures You can equivalence a PROCPTR to any previously declared variable provided that the width of the previous variable must be greater than or equal to the width of the PROCPTR. Example 16-2. PROCPTRs as Variables and Formal Parameters INT i; INT .EXT j; REAL k; PROCADDR pa; PROC p (i, j) EXTENSIBLE, CALLABLE; INT i, .EXT j; FORWARD; PROCPTR a (i, j) EXTENSIBLE, CALLABLE; INT i, .
Procedures, Subprocedures, and Procedure Pointers Declaring PROCPTRs in Structures prev-identifier is the identifier of a field at the same level as procptr in the same structure. Example 16-3. Array of PROCPTRs STRUCT s1 [0:9]; BEGIN REAL PROCPTR f(x); REAL x; END PROCPTR; END; You use an index to reference elements of array s1 in Example 16-3 on page 16-12: CALL s1[3].f(3.0e1); Example 16-4.
Procedures, Subprocedures, and Procedure Pointers Procedures as Formal Parameters Procedures as Formal Parameters TAL In TAL, you can declare a formal parameter of type PROC. Example 16-6. PROC Parameters (TAL) PROC p1(i); INT i; BEGIN ...
Procedures, Subprocedures, and Procedure Pointers Assigning Values to PROCPTR Variables Example 16-7. @ Before Actual Procedure Parameters (pTAL) (page 2 of 2) PROC c(pa); PROCADDR pa; BEGIN ...
Procedures, Subprocedures, and Procedure Pointers Assigning Values to PROCPTR Variables Example 16-9.
Procedures, Subprocedures, and Procedure Pointers Using PROCs as Formal Parameters Example 16-10. Assigning Values to PROCPTR Variables (page 2 of 2) @a := @p; @d := @s1[2].f; @s1[3].f := @d; CALL c(d); After you have assigned a value to a PROCPTR variable—that is, when it points to a procedure—you can call that procedure by using the PROCPTR name in a CALL statement or, if the PROCPTR is typed, in an expression. Example 16-11. Using a PROCPTR Variable CALL a(1, 2); r := d(r); IF (s1[i].f(r)) < 1.
Procedures, Subprocedures, and Procedure Pointers Procedure Parameters Procedure Parameters Topics: • • • • • • Dynamically selected procedure calls Passing parameters to VARIABLE and EXTENSIBLE procedures VARIABLE, EXTENSIBLE, and RETURNSCC procedures as actual parameters Passing STRING value parameters Passing a .EXT actual parameter to a nonEXT reference parameter Declaring STRUCTs as formal parameters When a procedure is called, each actual parameter is bound to its corresponding formal parameter.
Procedures, Subprocedures, and Procedure Pointers Dynamically Selected Procedure Calls Example 16-13.
Procedures, Subprocedures, and Procedure Pointers Parameters and VARIABLE and EXTENSIBLE Procedures Parameters and VARIABLE and EXTENSIBLE Procedures In pTAL as in TAL, memory is allocated for all parameters to VARIABLE or EXTENSIBLE procedures; therefore, your program can store default values for those parameters the caller does not pass.
Procedures, Subprocedures, and Procedure Pointers Using Formal STRING Value Parameters pTAL In pTAL, you can pass a procedure or procedure pointer that includes an EXTENSIBLE, VARIABLE, or RETURNSCC attribute as a parameter to a procedure whose formal parameter is a PROC, but you cannot reference the PROC formal parameter identifier in a CALL statement.
Procedures, Subprocedures, and Procedure Pointers Passing a .EXT Parameter to a Non-EXT Reference Parameter Example 16-17. Formal STRING Value Parameters (TAL) PROC p (s); STRING s; BEGIN IF s = "A" THEN ... ; ... IF s[1] = "A" THEN ... ; END; ! Value parameter of type STRING ! Fails because "A" is in lower half ! of word but s tests upper half ! Succeeds CALL p("A"); pTAL In pTAL, you cannot declare a STRING value parameter.
Procedures, Subprocedures, and Procedure Pointers Declaring STRUCTs as Formal Parameters Example 16-19. Structures as Formal Parameters (TAL) PROC p(i, j); INT i; STRUCT .J; BEGIN INT a; INT b; END; BEGIN ... END; pTAL In pTAL, you cannot declare a definition STRUCT as a formal parameter. You can achieve the same effect in pTAL by using a referral STRUCT as a formal parameter, and having it reference a previously declared structure, as in Example 16-20 on page 16-22. Example 16-20.
Procedures, Subprocedures, and Procedure Pointers Referencing Parameters Referencing Parameters In TAL, your code might reference one parameter relative to another. In TAL, this works because TAL allocates memory for parameters in the same order as they are declared in your program. In pTAL, you cannot make assumptions about the order in which parameters are allocated in memory. You must refer to each parameter only as a named entity.
Procedures, Subprocedures, and Procedure Pointers pTAL Conversion Guide—527302-002 16 -24 Referencing Parameters
17 TAL Standard Routines This section describes TAL standard routines for which pTAL has either: • • Nothing similar (“Deleted” in Table 17-1 on page 17-1) A built-in routine that has the same name but slightly different behavior (“Changed” in Table 17-1 on page 17-1) Note. TAL also supports some pTAL built-in routines that are not based on TAL standard routines—see Table 18-1 on page 18-3. Table 17-1.
TAL Standard Routines $AXADR $AXADR $AXADR is a privileged TAL routine for which pTAL has a privileged built-in routine with the same name but slightly different behavior. Note. The EpTAL compiler does not support this routine. (The EpTAL compiler does allow $AXADR as a DEFINE name.) $AXADR converts a standard address or a relative extended address to an absolute extended address. $AXADR ( variable ) VST116.
TAL Standard Routines $CARRY count is an INT value that specifies the number of 16-bit words in param. $CARRY $CARRY is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior. $CARRY routine returns a value that indicates whether an arithmetic carry occurred during certain arithmetic operations or during execution of a SCAN or RSCAN statement. $CARRY VST076.vsd TAL The value returned by $CARRY is based on the carry bit (K) in the TNS environment register.
TAL Standard Routines pTAL Example 17-1. Procedure That Returns $CARRY (TAL) PROC p1(i, j); INT .i, j; BEGIN i := j + 1; END; ! Sets $CARRY to 0 or 1 PROC p2; BEGIN INT a; CALL p1(a, 4); IF $CARRY THEN ... END; ! Local variable ! Testing $CARRY works in TAL ! pTAL compiler reports error: ! $CARRY is not available after a ! procedure call $CARRY cannot be an actual parameter. If it is important to pass the value of $CARRY to a procedure, use code similar to that in Example 17-2 on page 17-4.
TAL Standard Routines $COMP $COMP $COMP is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior. $COMP returns the one’s complement of its argument. $COMP ( int-expression ) VST077.vsd expression is an expression whose value is: TAL pTAL An INT value An INT or INT(32) value The data type of the expression returned by $COMP is the same as the data type of its argument. Example 17-4.
TAL Standard Routines $HIGH expression is an expression whose value is: TAL • • • • • • pTAL INT INT(32) FIXED REAL UNSIGNED(1-16) UNSIGNED(17-31) Any that TAL allows and: • • • EXTADDR PROCADDR REAL(64) $DBL sets the overflow indicator if the value of expression is fixed. $HIGH $HIGH is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior. $HIGH converts the high-order (leftmost) 16 bits of its argument to an INT value.
TAL Standard Routines $LADR expression is an expression whose value is: TAL • • • • • • • pTAL INT INT(32) FIXED REAL REAL(64) UNSIGNED(1-16) UNSIGNED(17-31) Any that TAL allows and: • • • • SGBADDR SGWADDR SGXBADDR SGXWADDR If expression is not a FIXED, REAL, or REAL(64) value, $INT returns the low-order (rightmost) 16 bits of expression. $INT never causes overflow. $INT does not explicitly maintain the sign of expression.
TAL Standard Routines $LEN $LEN $LEN is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior. $LEN returns the length, in bytes, of a variable. $LEN ( variable ) VST096.vsd identifier is the identifier of a simple variable, array element, pointer, structure, or structure data item. TAL The TAL compiler adds a filler byte at the end of some structures to round the length of the structure up to an even number of bytes.
TAL Standard Routines $OCCURS $OCCURS $OCCURS is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior. $OCCURS returns the number of elements declared in an array. $OCCURS ( variable ) VST103.vsd identifier is a variable, array, structure, or structure field. identifier cannot be the name of a structure template.
TAL Standard Routines $OFFSET Table 17-3. $OCCURS for Structure Arrays and Arrays Within Structures $OCCURS Argument Unindexed structure array or substructure array or an element of a structure array or substructure array or an array that is a field within a structure or substructure Entire structure or nonarray field of a structure or substructure Structure template $OCCURS Returns Example In TAL In pTAL 10 10 8 8 5 5 10 1* 8 1* 5 1* 1 1 1 1 Comp.-time err. 10 10 Comp.
TAL Standard Routines $OVERFLOW variable TAL pTAL UNSIGNED field Returns the bit offset of the 16-bit word that contains the UNSIGNED field Reports an error (use $BITOFFSET instead of $OFFSET) Item that is not a field in a structure Returns zero Reports an error Structure array whose lower bound is nonzero Returns an offset as though the structure array’s lower bound were zero Reports an error (but $OFFSET applied to a substructure array whose lower bound is nonzero returns the appropriate offs
TAL Standard Routines pTAL pTAL You can test $OVERFLOW only if overflow traps are disabled and only following an assignment statement in which the final operator executed on the right side of the assignment is one of the following operators or standard routines: • • • • • • • • • • • • Negate (unary -), +, -, *, /,’/’ $DBL of an INT, FIXED, REAL, or REAL(64) value $FLTR of a REAL(64) value $FIX of a REAL or REAL(64) value $FIXD $FIXI $FIXL $FIXR of a REAL or REAL(64) value $INT of a FIXED, REAL, or REAL
TAL Standard Routines $USERCODE $USERCODE $USERCODE is a TAL routine for which pTAL has nothing similar. $USERCODE returns the contents of a specified location. ( $USERCODE ) expression VST022.vsd expression is an INT or UNSIGNED(1-16) expression whose value is the address of a word in the current code space of the current user code segment: $XADR $XADR is a TAL routine for which pTAL has a built-in routine with the same name but slightly different behavior.
TAL Standard Routines $XADR pTAL Conversion Guide—527302-002 17 -14
18 pTAL Built-In Routines In TAL, CODE statements enable you to execute specific TNS instructions. pTAL does not support CODE statements. Instead, pTAL built-in routines provide the functionality of required TNS instructions that standard pTAL features and millicode routines do not provide.
pTAL Built-In Routines TNS Instruction Codes Supported by Millicode Routines TNS Instruction Codes Supported by Millicode Routines pTAL programs running as native processes can call millicode routines (using standard procedure call syntax) that provide the same functionality as the following TNS instructions: BCLD DISP FTL RCHN RUS SNDQ TRCE XIST CAFL DLTX IXA RIOC SEND SPT VSEM XLIM CMAP DTL INSX RIR SGSZ SSW WIOC XMSK CMRW EIOC MRL RIBA SMBP SXBL XADD XRST CXBL FRST PSE
pTAL Built-In Routines TNS Instruction Codes Supported by pTAL Built-In Routines TNS Instruction Codes Supported by pTAL Built-In Routines Many of the pTAL built-in routines provide the functionality of TNS instructions that otherwise would be unavailable in pTAL. Tables: • • Table 18-1, pTAL Built-In Routines That TAL Supports, on page 18-3 Table 18-2, pTAL Built-In Routines That TAL Does Not Support, on page 18-4 Table 18-1.
pTAL Built-In Routines TNS Instruction Codes Supported by pTAL Built-In Routines Table 18-2.
pTAL Built-In Routines TNS Instruction Codes Supported by pTAL Built-In Routines Table 18-2.
pTAL Built-In Routines Parameters to Built-In Routines Table 18-2. pTAL Built-In Routines That TAL Does Not Support (page 3 of 3) Routine Name P1 CC2 $UDIVREM325 OF3 C4 Y $UNLOCKPAGE5 Y $WRITEPTE5 Y Description Divides an INT(32) dividend by an INT divisor to produce an INT(32) quotient and INT remainder Y Unlocks one physical page of extended memory Y Writes a segment-page table entry 1. Y specifies that a process must be privileged to execute this built-in routine. 2.
pTAL Built-In Routines Parameters to Built-In Routines If a parameter to a built-in routine is an output parameter whose data type is one of the address types (for example, BADDR or EXTADDR), pass the address of a pointer, not the address of a simple variable: STRING s; STRING .
pTAL Built-In Routines Built-In Routines and Hardware Indicators Built-In Routines and Hardware Indicators If the built-in routine does not specify the value of a hardware indicator, the value of the hardware indicator is undefined after the built-in routine completes. If you reference a hardware indicator when it is undefined, the native compiler reports a syntax error. If the value of $OVERFLOW would be nonzero after executing a built-in routine, an overflow trap occurs if overflow traps are enabled.
pTAL Built-In Routines $ASCIITOFIXED qvaluein input FIXED(*):value is a value that $ASCIITOFIXED adds to the result of converting the bytes at bufferaddr. $ASCIITOFIXED multiples qvaluein by 10 for each digit it converts from ASCII to FIXED. After it converts the last digit at bufferaddr, $ASCIITOFIXED adds qvaluein to the result of the conversion to establish the value that it returns qvalueout.
pTAL Built-In Routines $ATOMIC_ADD $ATOMIC_ADD $ATOMIC_ADD, an atomic operation, increments a variable by a specified value. $ATOMIC_ADD ( , var value ) ; VST607.vsd Sets condition code Yes (according the final value of var ) Sets $CARRY Yes, if traps are disabled Sets $OVERFLOW Yes, if traps are disabled; otherwise, traps on overflow var input,output sINT:variable is the variable that $ATOMIC_ADD increments. value input sINT:value is the value $ATOMIC_ADD adds to var.
pTAL Built-In Routines $ATOMIC_AND $ATOMIC_AND $ATOMIC_AND, an atomic operation, performs a logical “and” operation (bitwise “and”—LAND) on a variable and a mask and stores the in the variable. $ATOMIC_AND ( var , mask ) ; VST608.vsd Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No var input,output sINT:variable is the variable to which $ATOMIC_AND applies mask. mask input INT:value is a 16-bit mask that $ATOMIC_AND applies to var.
pTAL Built-In Routines $ATOMIC_DEP $ATOMIC_DEP $ATOMIC_DEP, an atomic operation, deposits bits into an INT variable. $ATOMIC_DEP value ) ( , var mask , ; VST609.vsd Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No var input,output INT:variable is the variable into which $ATOMIC_DEP deposits bits from value. mask input INT:value is a 16-bit mask word that determines which bits of value to deposit into var.
pTAL Built-In Routines $ATOMIC_GET Examples of $ATOMIC_DEP: var value mask result %H0000 %H1234 %HAAAA %H0220 %H0000 %H1234 %H5555 %H1010 %H0000 %H6789 %HAAAA %H2288 %H0000 %H6789 %H5555 %H1010 $ATOMIC_GET $ATOMIC_GET, an atomic operation, gets (returns) the value of a variable. $ATOMIC_GET ( var ) ; VST610.vsd Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No var input type:variable is the variable whose value $ATOMIC_GET returns.
pTAL Built-In Routines $ATOMIC_OR $ATOMIC_OR $ATOMIC_OR, an atomic operation, performs a logical “or” operation (bitwise “or”— LOR) on a variable and a mask and stores the result in the variable. $ATOMIC_OR ( var , mask ) ; VST611.vsd Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No var input,output INT:variable is the variable to which $ATOMIC_OR apples mask. mask input INT:value is a 16-bit mask that $ATOMIC_OR applies to var.
pTAL Built-In Routines $ATOMIC_PUT $ATOMIC_PUT $ATOMIC_PUT, an atomic operation, puts (stores) a value into a variable. $ATOMIC_PUT ( , var value ) ; VST612.vsd Sets condition code No Sets $CARRY No Sets $OVERFLOW No var output type:variable is the variable into which $ATOMIC_PUT stores value. value input type:value is the value $ATOMIC_PUT stores in var. var must be one of: • • A one-byte , two-byte, or four-byte variable whose address is an integral multiple of its width.
pTAL Built-In Routines $BADDR_TO_EXTADDR $BADDR_TO_EXTADDR $BADDR_TO_EXTADDR converts a BADDR address to an EXTADDR address. $BADDR_TO_EXTADDR ( ) expression VST683.vsd pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is a BADDR address. Example 18-8. Call to $BADDR_TO_EXTADDR Routine STRING .
pTAL Built-In Routines $CHECKSUM The result of $BADDR_TO_WADDR is undefined if the least significant bit of expression is 1. The least significant bit of an address is not truncated when a byte address is converted to a word address—the address is not rounded down to the preceding even-byte address. Example 18-9. Call to $BADDR_TO_WADDR Routine INT .i; STRING s; @i := $BADDR_TO_WADDR(@s); ! @s is a BADDR address $CHECKSUM $CHECKSUM computes the checksum of data in extended memory.
pTAL Built-In Routines $COUNTDUPS $CHECKSUM accumulates the checksum by performing an exclusive-or operation on the accumulated checksum and wordcount successive 16-bit words, starting at bufferaddr. When $CHECKSUM completes, checksum holds the accumulated checksum and buffaddr is unchanged. Figure 18-2. TAL Code Equivalent to $CHECKSUM Routine STACK checksum, bufferaddr, wordcount; CODE(XSMX); STORE checksum; Example 18-10. Call to $CHECKSUM Routine LITERAL buffer_len = 100; INT c_sum_val; INT .
pTAL Built-In Routines srcaddr $COUNTDUPS input,output EXTADDR:variable is an extended memory address. Starting at srcaddr, $COUNTDUPS scans 16bit words until it encounters two adjacent words that are not equal. At the end of the operation, srcaddr points to the word that differs from the first word and which, therefore, terminated the scan. If there are no duplicates in the buffer, srcaddr points immediately after the last two words it compared—that is, at the first word $COUNTDUPS did not examine.
pTAL Built-In Routines $EXCHANGE Example 18-11. Call to $COUNTDUPS Routine LITERAL INT .EXT INT INT buffersize = 100; buffer[ 0:buffersize-1 ]; maxwords; duplication_count; maxwords := maxbuff; $COUNTDUPS(@buffer, maxwords, duplication_count); $EXCHANGE $EXCHANGE exchanges the contents of two variables of the same data type. $EXCHANGE ( var1 , var2 ) ; VST615.
pTAL Built-In Routines • $EXECUTEIO If var1 or var2 names an entire array, $EXCHANGE exchanges element 0 of the array. Figure 18-4. TAL Code Equivalent to $EXCHANGE Routine STACK var1, var2; STORE var1, var2; Example 18-12. Call to $EXCHANGE Routine INT INT INT(32) INT(32) var1; var2; var3; var4; $EXCHANGE(var1, var2); $EXCHANGE(var3, var4); $EXECUTEIO Note. The EpTAL compiler does not support this procedure. $EXECUTEIO initiates a command to the channel.
pTAL Built-In Routines $EXTADDR_TO_BADDR lprmcommand input uINT:value is the load parameter. lacsubcommand input sINT:value is the load address and the command word. rdstdevstatus output uINT:variable is the controller and device status. channelstatus output sINT:variable See the system description manual for your system for details. Figure 18-5.
pTAL Built-In Routines $EXTADDR_TO_WADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an EXTADDR address. In TAL, the result of $EXTADDR_TO_BADDR is undefined if the conversion cannot be performed. Example 18-14. Call to $EXTADDR_TO_BADDR Routine PROC p(x); STRING .EXT x; BEGIN STRING .
pTAL Built-In Routines $FILL8, $FILL16 and $FILL32 Example 18-15. Call to $EXTADDR_TO_WADDR Routine PROC p(x); INT .EXT x; BEGIN INT .j; @j := $EXTADDR_TO_WADDR(@x); @j := $EXTADDR_TO_WADDR(x); ! ERROR: x is INT, not EXTADDR END; $FILL8, $FILL16 and $FILL32 $FILL8, $FILL16, and $FILL32 fill an array or structure with repetitions of an 8-bit, 16-bit, or 32-bit value, respectively (sometimes called a “smear” operation). $FILL8 CALL $FILL16 $FILL32 ( area-to-fill , repetitions , value ) VST688.
pTAL Built-In Routines $FIXEDTOASCII $FILL32 performance is significantly degraded if area-to-fill is not aligned to at least a 4-byte boundary. None of the fill procedures ($FILL8, $FILL16, $FILL32) perform bounds-checking on their parameters. If you write more bytes than the size of area-to-fill, the results are undefined.
pTAL Built-In Routines $FIXEDTOASCIIRESIDUE maxdigits input uINT:value is the maximum number of ASCII digits to write at bufferaddr. $FIXEDTOASCII sets $OVERFLOW if it converts maxdigits bytes but leading digits in qvalue were not converted; otherwise, it resets $OVERFLOW. Note. In TNS processes, the CQA operator alters the condition code based on the initial value of qvalue. $FIXEDTOASCII does not set the condition code. Figure 18-6.
pTAL Built-In Routines qvalue $FIXEDTOASCIIRESIDUE input FIXED(*):value is a quadrupleword integer value to convert to ASCII digits. bufferaddr input BADDR:value is the byte address at which to write the ASCII digits. maxdigits input uINT:value is the maximum number of ASCII digits to write at bufferaddr. qresidue output FIXED(*):variable holds any of the original value that was not converted because maxdigits bytes were converted without converting all of qvalue.
pTAL Built-In Routines $FREEZE $FREEZE Note. The EpTAL compiler does not support this procedure. Use $TRIGGER on page 18-48 instead. (The EpTAL compiler does allow $FREEZE as a DEFINE name.) $FREEZE asserts a system freeze and halts the processor in which its process is running. $FREEZE VST619.
pTAL Built-In Routines $INT_OV pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY No Sets $OVERFLOW No Figure 18-9. TAL Code Equivalent to $FREEZE Routine CODE(HALT); Example 18-20. Call to $HALT Routine $HALT; $INT_OV Note. $INT_OV is supported in the D40 and later RVUs. $INT_OV converts its argument to an INT value. $INT_OV ( expression ) VST689.
pTAL Built-In Routines $INTERROGATEHIO If the data type of its argument is an INT(32) value greater than 32767 or less than -32768, $INT_OV traps if overflow traps are enabled; otherwise, $INT_OV ignores the problem. $INTERROGATEHIO Note. The EpTAL compiler does not support this procedure. $INTERROGATEHIO is used by the operating system’s high-priority interrupt handler to get the interrupt cause and status from a high-priority controller and to reset the corresponding interrupt.
pTAL Built-In Routines $INTERROGATEIO rist-int-cause output uINT:variable is the read interrupt status received from the controller holding the completed I/O. channel-status output uINT:variable is an integer variable that holds the status returned by the controller. Figure 18-10. TAL Code Equivalent to $INTERROGATEHIO Routine STACK 0,0; CODE(HHIO); STORE channel_status; STORE rist_interrupt_status; STORE ric_interrupt_status; STORE rank_channel; STORE select; Example 18-21.
pTAL Built-In Routines $INTERROGATEIO pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No $INTERROGATEIO ( select, ! o select output sINT:variable is an integer variable that is always set to 0. rank-channel output sINT:variable is an integer variable that is always set to 0. ric-int-cause output sINT:variable is the read interrupt cause received from the controller holding the completed I/O.
pTAL Built-In Routines $LOCATESPTHDR Example 18-22. Call to $INTERROGATEIO Routine INT select; INT rank_channel; INT ric_interrupt_status; INT rist_interrupt_cause; INT channel_status; $INTERROGATEIO(select, rank_channel, ric_interrupt_status, rist_interrupt_status, channel_status); $LOCATESPTHDR Note. The EpTAL compiler does not support this procedure. $LOCATESPTHDR provides the address of the segment page table (SPT). $LOCATESPTHDR sptbase ( ) headersize , virtaddr , ; VST645.
pTAL Built-In Routines $LOCKPAGE sptbase output EXTADDR:variable is the address of the segment-page-table header associated with virtaddr. $LOCATESPTHDR returns in sptbase the extended memory address of the segment-page table for the address in virtaddr. Figure 18-12. TAL Code Equivalent to $LOCATESPTHDR Routine STACK headersize, virtaddr; CODE(ASPT); STORE sptbase; Example 18-23.
pTAL Built-In Routines $MOVEANDCXSUMBYTES lock-count input sINT:value is the total number of bytes to lock in the page. virtaddr input EXTADDR:value is the beginning virtual address to lock. $LOCKPAGE calculates the page associated with virtaddr. Figure 18-13. TAL Code Equivalent to $LOCATESPTHDR Routine STACK only_if_locked, lock_count, virtaddr; CODE(LCKX); Example 18-24.
pTAL Built-In Routines $MOVEANDCXSUMBYTES checksum input,output uINT:variable contains an initial value for the checksum. When $MOVEANDCXSUMBYTES completes, checksum contains the newly computed checksum. destaddr input,output EXTADDR:variable is the extended memory address to which $MOVEANDCXSUMBYTES moves data. When $MOVEANDCXSUMBYTES completes, destaddr points to the memory location following the last byte written.
pTAL Built-In Routines $MOVENONDUP Example 18-25. Call to $MOVEANDCXSUMBYTES Routine INT checksum; INT .EXT source; INT .EXT dest; INT(32) count; checksum := 0; $MOVEANDCXSUMBYTES(checksum, @dest, @source, count); $MOVENONDUP $MOVENONDUP moves 16-bit words from one location in extended memory to another until $MOVENONDUP encounters two consecutive words with the same value. $MOVENONDUP maxwords ( , lastword destaddr , ) ; srcaddr , VST648.
pTAL Built-In Routines $PROCADDR maxwords input,output sINT:variable is the maximum number of 16-bit words to move. When $MOVENONDUP completes, maxwords is the number of words not moved because $MOVENONDUP found a duplicate, or, if a duplicate was not found, maxwords is zero. lastword input,output uINT:variable holds the 16-bit word against which the first word at srcaddr is compared. When $MOVENONDUP completes, lastword contains the last word moved. Figure 18-15.
pTAL Built-In Routines $READBASELIMIT identifier is either a procedure address (that is, @procedure-name ) or an INT(32) expression. $READBASELIMIT Note. The EpTAL compiler does not support this procedure. $READBASELIMIT returns the base and limit of the current extended segment. $READBASELIMIT ( xbase , xlimit ) VST649.
pTAL Built-In Routines $READSPT $READSPT Note. The EpTAL compiler does not support this procedure. $READSPT makes a copy of an entry from the Segment Page Table (SPT). Both the SPT and the copy are in extended memory. $READSPT ( virtaddr , sptentryaddr ) VST650.
pTAL Built-In Routines $READTIME $READTIME $READTIME is a routine that returns the number of microseconds since the last cold load. $READTIME VST651.vsd pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No Figure 18-18. TAL Code Equivalent to $READSPT Routine CODE(RTIM); Example 18-29.
pTAL Built-In Routines $SGBADDR_TO_SGWADDR $SGBADDR_TO_EXTADDR returns expression converted to an EXTADDR address. Example 18-30. Call to $SGBADDR_TO_EXTADDR Routine STRING .SG s; INT .EXT i; INT j; @i := $SGBADDR_TO_EXTADDR(@s[j]); ! OK if @s[j] is at an ! even-byte offset; ! otherwise, @i is ! undefined. $SGBADDR_TO_SGWADDR $SGBADDR_TO_SGWADDR converts an SGBADDR or SGXBADDR address to an SGWADDR address. $SGBADDR_TO_SGWADDR ( expression ) VST604.
pTAL Built-In Routines TAL TAL TNS processes ignore the low-order bit of expression; therefore, if the low-order bit is 1, your program addresses the byte at the next lower byte address than that specified by expression. pTAL Native processes do not support this “round-down” effect. The value returned by $SGBADDR_TO_SGWADDR for programs run as native processes is undefined if the least significant bit of expression is 1.
pTAL Built-In Routines $SGWADDR_TO_SGBADDR $SGWADDR_TO_SGBADDR $SGWADDR_TO_SGBADDR converts an SGWADDR or SGXWADDR address to an SGBADDR address. $SGWADDR_TO_SGBADDR ( expression ) VST690.vsd pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an SGWADDR or SGXWADDR address.
pTAL Built-In Routines $STACK_ALLOCATE pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No size is an INT expression that specifies the number of bytes to allocate. size is an unsigned value from 0 through 65534. $STACK_ALLOCATE rounds size up to the next integral multiple of 8 if it is not already an integral multiple of 8.
pTAL Built-In Routines Using a Single Block Acquired From $STACK_ALLOCATE For TNS processes, the system allocates data blocks from smaller addresses to larger addresses. For native processes, the system allocates data blocks from larger addresses down to smaller addresses. This difference between how the systems allocate memory affects how you use memory areas allocated by $STACK_ALLOCATE and the compatibility of source code for TNS and native processes.
pTAL Built-In Routines • Using Multiple Blocks Acquired From $STACK_ALLOCATE as One Large Block You can use the block as an array of entries, allocated from high addresses to low addresses, by mapping each array reference to the correct array entry. This approach, however, is very error-prone. Move operations, scan operations, string comparison operations, and equivalencing must be used with great care and, depending on how you access your data, might not be usable at all for such an array.
pTAL Built-In Routines $TRIGGER Figure 18-20. Memory Allocation From $STACK_ALLOCATE (Native Process) @p1 := $STACK_ALLOCATE (30); @p2 := $STACK_ALLOCATE (24); @p3 := $STACK_ALLOCATE (34); Process Global Data Direction of Stack Growth Procedure Local Data p1 3096 Requested 30 bytes, allocated 32 bytes p2 3064 Requested 24 bytes, allocated 24 bytes p3 3040 Requested 34 bytes, allocated 40 bytes 3000 VST019.vsd $TRIGGER Note. The pTAL compiler does not support this routine.
pTAL Built-In Routines $UDIVREM16 pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY No Sets $OVERFLOW No op is an INT(32) value. Example 18-35. Call to $TRIGGER Routine INT(32) op; $TRIGGER (op); $UDIVREM16 Note. The EpTAL compiler does not support this procedure. $UDIVREM16 provides the functionality of the TNS LDIV instruction. $UDIVREM16 performs unsigned division and produces a quotient and a remainder.
pTAL Built-In Routines $UDIVREM16 quotient output sINT:variable remainder output sINT:variable Figure 18-21. TAL Code Equivalent to $UDIVREM16 Routine STACK dividend, divisor; CODE(LDIV); STORE quotient, remainder; If the quotient is too large to fit in quotient, overflow occurs.
pTAL Built-In Routines $UDIVREM32 $UDIVREM32 Note. The EpTAL compiler does not support this procedure. $UDIVREM32 provides the functionality of the TNS LDIV instruction. $UDIVREM32 performs unsigned division and produces a quotient and a remainder. $UDIVREM32 quotient ( dividend remainder , , ) divisor , ; VST654.
pTAL Built-In Routines $UNLOCKPAGE pTAL checks the following conditions during compilation: • If divisor evaluates to a constant value of zero, pTAL reports an error that divide by zero is invalid: $UDIVREM32(dividend, 2 / 2 - 1, quot, rem); • ! Report error If both dividend and divisor are constants, and you test $OVERFLOW following the call to $UDIVREM32, pTAL reports a warning that overflow cannot occur: $UDIVREM32(32767, 256, quot, rem); IF $OVERFLOW THEN ...
pTAL Built-In Routines $WADDR_TO_BADDR unlockcount input sINT:value is the total number of bytes to unlock in the page. virtaddr input EXTADDR:value is the beginning virtual address to unlock. $UNLOCKPAGE calculates the page associated with virtaddr. $UNLOCKPAGE is for exclusive use of the operating system’s memory manager. Privileged programs must use the UNLOCKMEMORY procedure to unlock memory. Figure 18-23.
pTAL Built-In Routines $WADDR_TO_EXTADDR Example 18-39. $WADDR_TO_BADDR Routine STRING .s; INT t; @s := $WADDR_TO_BADDR(@t); !@t is a WADDR address $WADDR_TO_EXTADDR $WADDR_TO_EXTADDR converts a WADDR address to an EXTADDR address. $WADDR_TO_EXTADDR ( expression ) VST692.vsd pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is a WADDR address.
pTAL Built-In Routines $WRITEPTE pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY Yes Sets $OVERFLOW No ptetag input uINT:value are the page attribute bits associated with pageframe. pageframe input INT(32):value is the frame number of the physical frame associated with abs. abs input EXTADDR:value is the virtual address to which $WRITEPTE maps pageframe. Figure 18-24.
pTAL Built-In Routines $WRITEPTE pTAL Conversion Guide—527302-002 18 -56
19 Compiler Operation This section compares the operation of the native compilers to the operation of the TAL compiler. It does not completely describe the operation of any compiler.
Compiler Operation Output Files Native Compiler The input file for the native compiler must be an edit-format disk file. The compiler reads a maximum of 132 characters per record and ignores characters after the 132nd. The compiler does not read input from a terminal or from any other source or file format. In general, the compiler opens each source file as it needs it and keeps it open until the end of the compilation.
Compiler Operation Swap Files Swap Files For the TAL and native compilers, swap files are stored on the volume specified by, in order of priority: 1. 2. 3. 4. The SWAP run-option in the TACL RUN command (if present) The TACL command PARAM SWAPVOL (if present) The TACL command SET SWAP (if present) The volume on which the program resides ASSIGN and SSV Commands The TAL and native compilers support the same ASSIGN and SSV commands.
Compiler Operation For TAL Only Table 19-1 on page 19-4 applies to all forms of each directive unless otherwise specified: Example ABORT DO_PTAL CODE Applies to: • • • • • • • • • • ABORT NOABORT DO_PTAL NODO_PTAL PUSHDO_PTAL POPDO_PTAL CODE PUSHCODE POPCODE Not NOCODE (because NOCODE has its own entry) For more information about TAL compiler directives, see the TAL Reference Manual. Table 19-1. Unsupported TAL Compiler Directives (page 1 of 2) Native Compiler ...
Compiler Operation For TAL Only Table 19-1. Unsupported TAL Compiler Directives (page 2 of 2) Native Compiler ...
Compiler Operation For pTAL and TAL For pTAL and TAL All compiler directives in Table 19-2 on page 19-6 belong to pTAL, and some also belong to TAL: Status in pTAL Meaning For more information: Unchanged Directive is the same in pTAL and TAL (except for the minor syntax change explained in the following Note) pTAL Reference Manual or TAL Reference Manual Changed Directive is different in pTAL and TAL Table 19-3 on page 19-8 New Directive belongs only to pTAL (the TAL compiler ignores it) New Di
Compiler Operation For pTAL and TAL Table 19-2. pTAL Compiler Directives (page 2 of 3) Unchanged in pTAL Changed in pTAL New in pTAL IF, IFNOT, and ENDIF ERRORFILE ERRORS EXPORT_GLOBALS FIELDALIGN FMAP GMAP GP_OK1 INNERLIST INVALID_FOR_PTAL LINES LIST MAP OPTIMIZE OPTIMIZEFILE OVERFLOW_TRAPS3 PAGE PRINTSYM REFALIGNED RESETTOG ROUND SAVEGLOBALS2 SECTION SETTOG SOURCE SRL1 SUPPRESS SYMBOLS SYNTAX 1. The EpTAL compiler ignores this directive. 2. The EpTAL compiler does not accept this directive. 3.
Compiler Operation For pTAL and TAL Table 19-2. pTAL Compiler Directives (page 3 of 3) Unchanged in pTAL Changed in pTAL New in pTAL TARGET3 USEGLOBALS2 WARN 1. The EpTAL compiler ignores this directive. 2. The EpTAL compiler does not accept this directive. 3. The pTAL and EpTAL compilers treat this directive differently—for details, see the pTAL Reference Manual. The directives in Table 19-3 on page 19-8 are different in pTAL and TAL. Table 19-3.
Compiler Operation For pTAL and TAL ENDIF identifies the end of code that is to be conditionally compiled. ENDIF toggle-number toggle-name target pTAL VST693.vsd pTAL is new in pTAL and identifies the beginning of code that is to be compiled by the native compiler but not by the TAL compiler: Compiler IF pTAL IFNOT pTAL pTAL or EpTAL True False TAL False True OPTIMIZE OPTIMIZE sets the object code’s default optimization level. OPTIMIZE level = VST665.
Compiler Operation For pTAL and TAL PAGE The first PAGE prints a heading (if any) on the compiler listing, skips a line, and continues printing. Each subsequent PAGE prints a heading (if any) and causes a page eject. PAGE " heading-string " VST160.vsd heading-string is a character string whose maximum length is 82 characters in TAL and 122 characters in pTAL. WARN WARN suppresses compiler warning messages. WARN NOWARN warning-number VST675.vsd TAL and pTAL warning numbers are disjoint.
Compiler Operation For pTAL and TAL The directive DO_PTAL on page 19-15 is new in TAL. The native compilers ignore it. The directives in Table 19-4 on page 19-11 are new in pTAL. The TAL compiler ignores them. Table 19-4.
Compiler Operation For pTAL and TAL Default: The compiler allocates data items in the _GLOBAL data block Placement: Before the first data declaration in a compilation Scope: Applies to the compilation unit Dependencies: • • Has no effect without the USEGLOBALS directive If you specify either SAVEGLOBALS or USEGLOBALS, your compilation unit must have exactly one BEGINCOMPILATION directive If you specify BLOCKGLOBALS, the compiler allocates its own data block for each global variable that is not de
Compiler Operation For pTAL and TAL Table 19-6. Data Block Names for Indirect and Extended Arrays and Structures Without BLOCKGLOBALS With BLOCKGLOBALS Declaration Pointer Data Pointers and Data INT .a[0:9] #GLOBAL $_GLOBAL A INT.EXT a[0:9] #GLOBAL $_GLOBAL A STRUCT .a; BEGIN INT i; END #GLOBAL $_GLOBAL A STRUCT .EXT a; BEGIN INT i; END #GLOBAL $_GLOBAL A CALL_SHARED CALL_SHARED determines whether the compiler generates shared code (PIC). Note.
Compiler Operation For pTAL and TAL CHECKSHIFTCOUNT CHECKSHIFTCOUNT controls instruction traps for invalid shift operations. CHECKSHIFTCOUNT NOCHECKSHIFTCOUNT PUSHCHECKSHIFTCOUNT POPCHECKSHIFTCOUNT VST659.
Compiler Operation For pTAL and TAL See Section 14, Bit Operations, for more information and examples. DO_PTAL DO_PTAL enables new features in TAL. The native compilers ignore it. DO_PTAL SYNTAX NODO_PTAL POPDO_PTAL PUSHDO_PTAL VST003.
Compiler Operation For pTAL and TAL NODO_PTAL cancels DO_PTAL. PUSHDO_PTAL pushes the current setting (DO_PTAL or NODO_PTAL) onto the DO_PTAL directive stack. Does not change the current setting. POPDO_PTAL pops the top value from the DO_PTAL directive stack and changes the current setting to that value. For an explanation of directive stacks, see the pTAL Reference Manual.
Compiler Operation For pTAL and TAL Construct Example INT(32) bit extract source INT(32) i; ... i.<0:15> INT(32) bit deposit target INT(32) i; i.<0:15> := ... LAND, LOR, or XOR operator with INT(32) operands INT(32) i, j; ... i LAND j INT(32) argument to the $COMP routine INT(32) i; ... $COMP(i) Unsigned addition or subtraction operator ('+', '-') with INT(32) operands INT(32) i, j; ...
Compiler Operation For pTAL and TAL PUSHTNS_SYNTAX pushes the current setting (DOTNS_SYNTAX or NODOTNS_SYNTAX) onto the DOTNS_SYNTAX directive stack. Does not change the current setting. POPTNS_SYNTAX pops the top value from the DOTNS_SYNTAX directive stack and changes the current setting to that value. For an explanation of directive stacks, see the pTAL Reference Manual.
Compiler Operation Default: For pTAL and TAL EXPORT_GLOBALS Placement: Scope: • • • Can appear any number of times in a compilation unit Must appear before the first procedure is compiled Cannot appear within BLOCK declarations Applies to the compilation unit, except that NOEXPORT_GLOBALS does not affect a compilation’s private data block, which is always exported Dependencies: • • You must specify NOEXPORT_GLOBALS when declaring a data block that belongs to an SRL In a compilation that includes
Compiler Operation For pTAL and TAL AUTO specifies that the structure and the fields of the structure be aligned according to the optimal alignment for the architecture on which the program will run. (This AUTO attribute is not necessarily the same as the AUTO attribute in the native mode HP C compiler.) PLATFORM specifies that the structure and the fields of the structure must begin at addresses that are consistent across all languages on the same architecture—CISC, RISC, or Itanium®.
Compiler Operation For pTAL and TAL PUSHGP_OK pushes the current setting (GP_OK or NOGP_OK) onto the GP_OK directive stack. Does not change the current setting. POPGP_OK pops the top value from the GP_OK directive stack and changes the current setting to that value. For an explanation of directive stacks, see the pTAL Reference Manual.
Compiler Operation For pTAL and TAL OPTIMIZEFILE OPTIMIZEFILE specifies the optimization level for individual procedures and subprocedures. filename OPTIMIZEFILE VST666.vsd filename is, in the Guardian environment, an EDIT file. Each line of the file must have this syntax: optimize-level routine-name IS proc-name ns . # ns subproc-name comment blank line VST064.vsd See Example 19-1 on page 19-23. routine-name is a procedure name that the compiler recognizes. It can be preceded by white space.
Compiler Operation For pTAL and TAL subproc-name is a subprocedure name. The default optimization level of a subprocedure is that of its enclosing procedure. comment is any text. Default: The optimization level that OPTIMIZE specified Placement: Only in the compilation command (not in the source file) Scope: Applies to the compilation unit Dependencies: None Example 19-1. File for OPTIMIZEFILE Directive # This is the optimizefile for compilation xyz. abc.
Compiler Operation For pTAL and TAL Difference between pTAL and EpTAL compilers: pTAL Compiler EpTAL Compiler Does not issue warnings for errors in filename Issues a warning when filename : • • • • • Does not exist Cannot be opened Is not an EDIT file (Guardian operating systems only) Has the same routine-name on more than one line Has a line that: ° ° ° ° Exceeds 511 characters (Windows operating systems only) Has a routine-name that does not match any routine declaration in the source file Has an
Compiler Operation For pTAL and TAL NOOVERFLOW_TRAPS disables overflow traps throughout the program, except where you specify an overflow trapping procedure attribute or block attribute. PUSHOVERFLOW_TRAPS pushes the current setting (OVERFLOW_TRAPS or NOOVERFLOW_TRAPS) onto the OVERFLOW_TRAPS directive stack. Does not change the current setting. POPOVERFLOW_TRAPS pops the top value from the OVERFLOW_TRAPS directive stack and changes the current setting to that value.
Compiler Operation For pTAL and TAL PUSHREFALIGNED pushes the current setting [REFALIGNED (2) or REFALIGNED (8)] onto the REFALIGNED directive stack. Does not change the current setting. POPREFALIGNED pops the top value from the REFALIGNED directive stack and changes the current setting to that value. For an explanation of directive stacks, see the pTAL Reference Manual. SRL Note. The EpTAL compiler ignores this directive.
Compiler Operation For pTAL and TAL TARGET TARGET specifies the architecture on which you will run the object file produced by the current compilation. TARGET TNS_R_ARCH _TNS_E_TARGET RISC1 TNS_ARCH T16 LIBERTY ANY VST673.vsd TNS_R_ARCH RISC1 specifies the TNS/R architecture. This is the only option that the pTAL compiler accepts. It is also the default for the pTAL compiler. _TNS_E_TARGET specifies the TNS/E architecture. This is the only option that the EpTAL compiler accepts.
Compiler Operation Default: Separate Compilation pTAL compiler: TNS_R_ARCH EpTAL compiler: _TNS_E_TARGET Placement: Anywhere Scope: Applies to the compilation unit Dependencies: None Separate Compilation In both TAL and pTAL, separate compilation allows you to compile and save the global declarations for a program and then reference the already-compiled global data in subsequent compilations of the program.
Compiler Operation Linking Object Files Global declarations files created through TAL cannot be used with pTAL, nor can global declarations files created through pTAL be used with TAL. Linking Object Files The linker is used instead of Binder for native object files. Binder and the linker have a different syntax and operate on different object file types, but perform essentially the same operations.
Compiler Operation Linking Object Files pTAL Conversion Guide—527302-002 19 -30
20 Hardware Indicators This section compares the use hardware indicators in TAL and pTAL.
Hardware Indicators • • • • Managing Overflow Traps in TAL OVERFLOW_TRAPS Procedure Attribute on page 20-5 ENABLE_OVERFLOW_TRAPS Block Attribute on page 20-6 Running Programs With Overflow Traps Disabled on page 20-8 Comparing Overflow Trapping in Native Processes on page 20-8 Managing Overflow Traps in TAL TNS processes check for and can report overflow during certain arithmetic operations. In addition, they also report overflow if a process attempts to divide a number by 0.
Hardware Indicators Managing Overflow and Traps in pTAL Handling Overflow and Traps Across TAL Procedures When a TAL procedure calls another procedure, the system saves the current state of the environment register, which includes the T and V bits, on the call stack. The system does not, however, change the values of the T and V bits in the environment register. The values of the T and V bits, therefore, are the same upon entering the called procedure as they were in the calling procedure.
Hardware Indicators Static T Flag Static T Flag TAL programs can test TNS architecture’s T bit dynamically, but pTAL provides a “static T flag” with which you specify whether traps are enabled or disabled at any point in your program.
Hardware Indicators OVERFLOW_TRAPS Procedure Attribute Example 20-1. OVERFLOW_TRAPS Directive (page 2 of 2) ?NOOVERFLOW_TRAPS PROC q; BEGIN ... END; ! Correct use of OVERFLOW_TRAPS directive ! because it is between procedure ! declarations OVERFLOW_TRAPS Procedure Attribute In pTAL, you can use the OVERFLOW_TRAPS and NOOVERFLOW_TRAPS procedure and subprocedure attributes to enable or disable overflow traps for a procedure or subprocedure.
Hardware Indicators ENABLE_OVERFLOW_TRAPS Block Attribute The object code produced by the native compiler for Example 20-2 on page 20-5: • • • • • Disables traps for procedure x Enables traps for procedure y Disables traps for procedure z Enables traps for subprocedure s Disables traps upon returning from subprocedure s to the site in Z from which S was called.
Hardware Indicators ENABLE_OVERFLOW_TRAPS Block Attribute The TAL compiler generates code to enable or disable overflow traps at the end of any BEGIN-END block that specifies an overflow traps block attribute and whose encompassing block has the opposite overflow traps value. If no encompassing block specifies an overflow traps value, the current value of the OVERFLOW_TRAPS compiler directive determines the state of overflows upon leaving the block. Example 20-3.
Hardware Indicators Running Programs With Overflow Traps Disabled Example 20-4.
Hardware Indicators Comparing Overflow Trapping in Native Processes A program running as a TNS process can enable or disable overflow traps only by using overflow trapping block attributes. Each time you enter or exit a block that specifies a block overflow trapping attribute, your program enables or disables overflow traps by executing a small number of TNS instructions that set or reset the T bit in the TNS environment register.
Hardware Indicators Comparing Overflow Trapping in Native Processes Table 20-1. Trapping State Within a Procedure (page 2 of 2) Process Type TNS # Statement Sequence Caller’s Traps Enabled 2 ?OVERFLOW_TRAPS PROC p ENABLE_OVERFLOW_TRAPS; BEGIN ... END; Enabled Enabled Enabled Enabled Enabled Disabled Disabled Disabled Disabled Disabled Enabled Enabled Enabled Enabled Enabled 3 ?OVERFLOW_TRAPS PROC p NOOVERFLOW_TRAPS; BEGIN BEGIN:ENABLE_OVERFLOW_TRAPS ...
Hardware Indicators Comparing Overflow Trapping in Native Processes Table 20-2. TNS Versus Native Overflow Trapping Behavior (page 1 of 2) S P 1 Statements TNS(m1) TNS(m2) Native ?OVERFLOW_TRAPS Enabled Enabled Enabled 2 19 PROC p NOOVERFLOW_TRAPS; Enabled Enabled Enabled 3 20 BEGIN Enabled Enabled Enabled 4 21 Enabled Enabled Enabled 5 22 Enabled Enabled Enabled Enabled Enabled Enabled ...
Hardware Indicators Overflow Traps Considerations Table 20-2.
Hardware Indicators • Overflow Traps Considerations Your program might trap at slightly different locations for TNS processes than for native processes, even if the program’s trapping state—enabled or disabled—is the same for both processes. For a native process, overflow is detected in a pTAL program only when the expression on the right side of an assignment statement is assigned to the destination on the left side.
Hardware Indicators Setting Hardware Indicators If you want to ensure that overflow is detected on a particular operation by TNS and native processes, you must write your code so that if overflow occurs, it occurs during execution of the root operator—the last operator executed—on the right side of the assignment statement, as in Example 20-6 on page 20-14. Example 20-6. Ensuring That Overflow is Detected PROC p; BEGIN INT a := 32767; INT b := 1000; a := a + 1; IF NOT $OVERFLOW THEN a := a - b ELSE ...
Hardware Indicators Setting Hardware Indicators in TAL Setting Hardware Indicators in TAL When the condition code is accessible following an assignment statement, the numeric value of the evaluated expression on the right side of the assignment statement determines the value of the condition code.
Hardware Indicators ° Setting Hardware Indicators in TAL In TAL, STRING functions and INT functions can return either a single byte or an INT value, independent of the data type of the value returned by the function.
Hardware Indicators ° Setting Hardware Indicators in TAL The left side of the assignment statement must be one of: ° A local or sublocal simple variable PROC p; BEGIN INT i; i := i + 1; END; ° The address cell of a local pointer INT i; INT .
Hardware Indicators ° Setting Hardware Indicators in TAL A variable containing indexing, field selection, or bit selection STRUCT s; BEGIN INT f; END; INT a[0:9]; INT i; s.f := i; a[9] := i; i.<3:5> := a; ! Field selection: condition code is ! not available ! Index: condition code not available ! Bit Selection: condition code is ! not available The preceding rules are also described in Table 20-3 on page 20-19.
Hardware Indicators Setting Hardware Indicators in TAL Example 20-7. Testing Condition Code After Assignments (pTAL) (page 2 of 2) y := i + 1; a[i] := a[i+1]; s.s1[0] := i; s.s2 := i; i.<0:8> := i; i := str; ! ! ! ! ! ! i := $ABS(i); ! ERROR: Right side is call to ! built-in routine @k := @k + 1D; r := r + 1.
Hardware Indicators Setting $CARRY Table 20-3. Setting Condition Codes in Assignment Statements (page 2 of 2) To test condition codes after an assignment statement: Left side must be one of: Left side cannot be: Right side cannot: * A value parameter: A pointer: Be an expression that evaluates to a floating-point type [REAL or REAL(64)]: PROC p(i); BEGIN INT i; i := ... INT .p; p := ... REAL r; ... := r + 1.0E1 An implicit pointer: Be a constant or constant expression: INT .p[0:9]; p := ... ...
Hardware Indicators Setting $OVERFLOW Setting $OVERFLOW For a pTAL program running as a native process, the native compiler generates code that tests for overflow after every assignment statement if overflow traps are enabled or if all of the following conditions are true: • • Overflow traps are disabled.
Hardware Indicators • • Testing Hardware Indicators Assign the value of a hardware indicator to a variable in an assignment statement. Pass a hardware indicator as an actual parameter to a procedure. The following statements illustrate valid references to hardware indicators: IF < THEN ... IF $CARRY THEN ... IF $OVERFLOW THEN ... The following statements contain invalid references to hardware indicators: INT i; i := >; CALL p( < ); i := IF < THEN -i ELSE i; DO ... CALL AWAITIOX( ....
Hardware Indicators Testing Hardware Indicators The following example illustrates these cases: • i := i + 1; IF i >= 0 THEN IF > THEN ... ! OK: >= is a relational operator i := i + 1; IF >= THEN IF > THEN... ! OK: >= is a condition code An IF statement that tests a hardware indicator cannot be labeled. See Section 7, Labels, for more information and an example. Example 20-9. Testing Hardware Indicators in IF Statements INT a; a := a - 1; IF < THEN ...
Hardware Indicators Nesting Condition Code Tests Nesting Condition Code Tests You can test for more than one value of the condition code by nesting IF statements, as in the following example: Example 20-11. Nesting Condition Code Tests i := i + 1; IF < THEN ... ELSE IF = THEN ... ELSE ... ! Must be > Rules for nested IF statements: • $CARRY and $OVERFLOW cannot appear in the conditional expression of any IF statement in a nest of IF statements: i := i + 1; IF > THEN IF $CARRY THEN ...
Hardware Indicators Testing Condition Codes Set in Conditional Expressions Example 20-13 on page 20-25 is functionally equivalent to Example 20-12 on page 20-24 but is valid only in TAL. Example 20-13. Testing Condition Code for Multiple Values (TAL only) INT PROC p; BEGIN CALL READ( ... ); IF < THEN RETURN -1; IF > THEN RETURN 1; RETURN 0; END; ! OK ! ERROR: Condition code must be tested ! immediately after statement ! that sets it Example 20-14.
Hardware Indicators Testing Condition Codes After Comparing Addresses Testing Condition Codes After Comparing Addresses An IF statement’s THEN or ELSE clause cannot, in turn, test the condition code established by the outer IF statement’s conditional expression if the outer IF statement’s conditional expression uses signed operators (= or <>) to compare two 16bit, nonEXTADDR addresses, as in Example 20-16 on page 20-26. Example 20-16.
Hardware Indicators Using Hardware Indicators Across Procedures Using Hardware Indicators Across Procedures TAL In TAL, the values of hardware indicators are always available. A TAL procedure can set a hardware indicator—for example, a condition code—and call another procedure, which can read the condition code set by the first procedure. pTAL does not support this capability. Similarly, a TAL procedure can set a hardware indicator and return to its caller.
Hardware Indicators Returning the Condition Code to a Caller Example 20-18. Using Hardware Indicators Across Procedures (pTAL) (page 2 of 2) PROC a; BEGIN INT i, j, k; ...
Glossary accelerate. To speed up emulated execution of a TNS object file by applying the Accelerator for TNS/R system execution or the TNS Object Code Accelerator (OCA) for TNS/E system execution before running the object file. accelerated mode. See TNS accelerated mode. accelerated object code.
Glossary explicitly parallel instruction set computing (EPIC) explicitly parallel instruction set computing (EPIC). A processor architecture in which the instruction stream encodes what can be done in parallel (so that the hardware need not do this). Compare to complex instruction set computing (CISC) and reduced instruction set computing (RISC). high PIN. A process identification number (PIN) that is greater than 255. Compare to low PIN. HP Transaction Application Language (TAL).
Glossary PIC (position-independent code) PIC (position-independent code). Executable code that need not be modified to run at different virtual addresses. External reference addresses appear only in a data area that can be modified by the loader; they do not appear in PIC code. PIC is also called shared code. Portable Transaction Application Language (pTAL).
Glossary TNS accelerated mode TNS accelerated mode. A TNS emulation environment on a TNS/R or TNS/E system in which accelerated TNS object files are run. TNS instructions have been previously translated into optimized sequences of MIPS or Intel® Itanium® instructions. TNS accelerated mode runs much faster than TNS interpreted mode. Accelerated or interpreted TNS object code cannot be mixed with or called by native mode object code. See also TNS Object Code Accelerator (OCA).
Glossary TNS process TNS process. A process whose main program object file is a TNS object file, compiled using a TNS compiler. A TNS process executes in interpreted or accelerated mode while within itself, when calling a user library, or when calling into TNS system libraries. A TNS process temporarily executes in native mode when calling into native-compiled parts of the system library.
Glossary TNS/R native object file TNS/R native object file. An object file created by a TNS/R native compiler that contains MIPS RISC instructions and other information needed to construct the code spaces and the initial data for a TNS/R native process. TNS/R native process. A process initiated by executing a TNS/R native object file. Compare to TNS process and TNS/E native process. white space. One or more space or tab characters.
Index Numbers 16-bit operands and operations 13-1/13-4 32-bit operands with bit operations 14-4 with unsigned operators 13-4/13-5 A Abbreviated comparisons 10-32 ABORT directive 19-4 ABSLIST directive 19-4 Address arithmetic 13-6/13-7 Address constants, alternatives to 10-41/10-44 Address types determining 10-9/10-11 testing 15-16 using 10-5/10-9 Addresses arrays of 9-4/9-5 comparing See Comparing addresses computing number of bytes between 10-29/10-30 converting See Converting addresses in expressions 10-
Index C BADDR_TO_EXTADDR routine 18-16 BADDR_TO_WADDR routine 18-16/18-17 Base alignment 11-9 BCLD instruction 18-2 BEGINCOMPILATION directive 19-8, 19-28 BELOW clause 2-1 BFI instruction 18-2 BIKE instruction 18-2 Binder 19-29 Bit operations deposit 14-4 extract before binary operators 3-2/3-3 with 32-bit operands 14-4 shift 14-1/14-3 BLOCK declaration 2-1 BLOCKGLOBALS directive 19-11/19-13 BNDW instruction 18-2 BOUNDS routine 17-2/17-3 Branching from subprocedure to containing procedure 7-2, 15-14 BSUB
Index D Conventions for syntax diagrams xxvii/xxx Converting addresses implicitly 10-20/10-22 to numbers 10-18/10-20 using arithmetic operations 10-23/10-24 using standard TAL routines 10-22/10-23 Converting TAL to pTAL 1-3/1-4 COUNTDUPS routine 18-18/18-20 CPU directive 19-4 CROSSREF directive 19-4 CWADDR address type numeric conversions and 10-20 uses for 10-13 CXBL instruction 18-2 D Data alignment background 5-1/5-3 in native processes 5-2/5-3 in TNS processes 5-1 NODEFAULT 11-15 of structure fields
Index F Equivalenced variables (continued) REFALIGNED clause and 12-16 standard pointers to indirect items 12-9 terminology 12-1/12-3 using 12-18 ERRORFILE directive 19-7 ERRORS direcitve 19-7 ESE instruction 18-2 EXCHANGE routine 18-20/18-21 EXECUTEIO routine 18-21/18-22 EXIT instruction 18-2 EXPORT_GLOBALS directive 19-18/19-19 Expressions generally 13-1/13-13 addresses in 10-34 group comparison 13-10/13-13 indexes in 13-8/13-9 INT(32), in CASE statements 15-10 EXTADDR address type location of 10-14 num
Index G Formal parameters procedures as 16-16 STRING 16-20/16-21 structures as 16-21 FORWARD keyword 16-4 FREEZE routine 18-28 FRST instruction 18-2 FTL instruction 18-2 G Global variables, system 10-12 GMAP directive 19-7 GOTO statement 15-12/15-15 GP_OK directive 19-20/19-21 Group comparison expressions 13-10/13-13 H HALT routine 18-28/18-29 Hardware indicators across procedures 20-27/20-28 built-in pTAL routines and 18-8 GOTO statement and 15-16 setting 20-14/20-21 testing 20-21/20-25 HEAP directive
Index M LADR routine 17-7 LARGESTACK directive 19-5 LEN routine 17-8 Lexical elements 3-1 LIBRARY directive 19-5 LINES directive 19-7 LIOC instruction 18-2 LIST directive 19-7 LITERALs 6-1 LMAP directive 19-5 LOCATESPTHDR routine 18-33/18-34 LOCKPAGE routine 18-34/18-35 Low PIN 19-3 M Managing overflow traps in pTAL 20-3 in TAL 20-2/20-3 MAP directive 19-7 MAPS instruction 18-2 MAXALIGN attribute 11-13 Memory, extended 10-14 Millicode routines 18-2 Move statement 15-17/15-18 MOVEANDCXSUMBYTES routine 18-
Index P P PAGE directive 19-10 Page heading 19-10 PARAM commands 19-3 Parameters EXTENSIBLE procedures and 16-19 label 7-1 of procedures 16-17/16-23 procedures as actual 16-19/16-20 formal 16-16 referencing 16-23 to built-in pTAL routines 18-6/18-7 VARIABLE procedures and 16-19 .
Index R Procedures (continued) syntax of 16-1/16-5 VARIABLE generally 16-5 parameters and 16-19 PROCPTR variables assigning values to 16-14/16-16 comparing to PROCADDR 10-32 declaring generally 16-10/16-11 as formal parameters 16-13/16-14 in structures 16-11/16-12 Program structure 2-1 PSEM instruction 18-2 pTAL language converting TAL to 1-3/1-4 lexical elements of 3-1 new features in 1-1/1-2 Punctuation characters in syntax diagrams xxvii PUSH instruction 18-2 PUSHname directive See name directive PUSH,
Index S RUS instruction 18-2 RWCS instruction 18-2 S SAVEABEND directive 19-5 SAVEGLOBALS directive 19-8 Scale factor, nonzero 4-6 SCAN statement 15-23/15-26 SCMP instruction 18-2 SCPV instruction 18-2 SEARCH directive 19-5 SECTION directive 19-7 SEND instruction 18-2 Separate compilation 19-28/19-29 SETE instruction 18-2 SETP instruction 18-2 SETS instruction 18-2 SETTOG directive 19-7 SGBADDR address type location of 10-12 numeric conversions and 10-19 SGBADDR pointers 10-39 SGBADDR_TO_EXTADDR routine
Index T Structures alignment of 11-1/11-7, 11-28, 11-34/11-37 See also Field alignment arrays in 11-24 arrays of 11-24/11-25 as formal parameters 16-21 declaring definition 11-10/11-13 referral 11-15 template 11-13/11-15 fields of 11-15 in equivalenced declarations 12-12 optimizing layouts of 11-25/11-27 variant records in 12-15/12-16 Subprocedures 10-13 Substructures alignment of 11-29, 11-34/11-37 arrays of 11-24/11-25 SUBTYPE directive 19-5 SUPPRESS directive 19-7 SVMP instruction 18-2 Swap files 19-3
Index W Variables (continued) REAL 6-1 simple 8-1/8-2 storing addresses in 10-17/10-18 system global 10-12 Variant records 12-15/12-16 VOLATILE attribute for parameters 5-9/5-10 for simple pointers 5-8/5-9 for structure pointers 5-9 invalid uses of 5-10/5-11 undefined uses of 5-11 valid uses of 5-7 Volatile data description of 5-5/5-6 atomic access and 5-11 VSEM instruction 18-2 VWCS instruction 18-2 W WADDR address type location of 10-12 numeric conversions and 10-18/10-19 WADDR_TO_BADDR routine 18-53/1
Index Special Characters $HIGH routine 17-6 $INT routine 17-6/17-7 $INTERROGATEHIO routine 18-30/18-31 $INTERROGATEIO routine 18-31/18-33 $INT_OV routine 18-29/18-30 $LADR routine 17-7 $LEN routine 17-8 $LOCATESPTHDR routine 18-33/18-34 $LOCKPAGE routine 18-34/18-35 $MOVEANDCXSUMBYTES routine 18-35/18-37 $MOVENONDUP routine 18-37/18-38 $OCCURS routine 17-9/17-10 $OFFSET routine 17-10/17-11 $OVERFLOW routine setting 20-21 syntax of 17-11/17-12 testing 20-26 $PROCADDR routine 18-38/18-39 $READBASELIMIT rout