HP pTAL
HP pTAL
HP pTAL
Manual
Abstract
This publication describes the syntax of pTAL, the Portable Transaction Application
Language for HP NonStop™ systems [TNS/R pTAL compiler (T9248) and TNS/E
EpTAL compiler (T0561)] for system and application programmers.
Product Version
pTAL D44
EpTAL H01
Supported Release Version Updates (RVUs)
This publication supports D44.00, G06.20, H06.08 and all subsequent D-series,
G-series, and H-series RVUs unless otherwise indicated by its replacement
publication.
1. Introduction to pTAL
pTAL and TAL Compatibility 1-1
EpTAL, pTAL, and TAL Compilers 1-2
pTAL Applications 1-3
pTAL Features 1-4
Procedures 1-4
Subprocedures 1-4
Private Data Area 1-4
Recursion 1-5
Parameters 1-5
Data Types 1-5
Data Grouping 1-5
Pointers 1-6
Data Operations 1-6
Bit Operations 1-6
Built-in Routines 1-6
Compiler Directives 1-6
Modular Programming 1-6
System Services 1-6
System Procedures 1-7
pTAL and the CRE 1-7
Hewlett-Packard Company—523746-006
i
Contents 2. Language Elements
2. Language Elements
Character Set 2-2
Keywords 2-2
Delimiters 2-4
Operators 2-5
Base Address Symbols 2-7
Indirection Symbols 2-7
Declarations 2-8
Identifiers 2-8
Variables 2-10
Scope 2-10
Constants 2-12
Statements 2-12
3. Data Representation
Data Types 3-1
Specifying Data Types 3-3
Data Type Aliases 3-4
Operations by Data Type 3-4
Address Types 3-5
Storing Addresses in Variables 3-7
Converting Between Address Types and Numeric Data Types 3-7
Converting Between Address Types 3-7
Using Indexes to Access Array Elements 3-9
Incrementing and Decrementing Addresses (Stepping Pointers) 3-10
Constants 3-12
Character String 3-12
STRING Numeric 3-14
INT Numeric 3-15
INT(32) Numeric 3-16
FIXED Numeric 3-17
REAL and REAL(64) Numeric 3-19
Constant Lists 3-21
Constant List Alignment Specification 3-22
4. Data Alignment
Misalignment Tracing Facility 4-1
Misalignment Handling 4-3
5. Expressions
Data Types of Expressions 5-2
Operator Precedence 5-3
Arithmetic Expressions 5-5
Signed Arithmetic Operators 5-6
Scaling of FIXED Operands 5-7
Using FIXED(*) Variables 5-8
Unsigned Arithmetic Operators 5-8
Bitwise Logical Operators 5-10
Using Bitwise Logical Operators and INT(32) Operands 5-10
Comparing Addresses 5-11
Extended Addresses 5-12
Nonextended Addresses 5-12
Constant Expressions 5-14
Conditional Expressions 5-15
NOT, OR, and AND Operators 5-17
Relational Operators 5-18
Special Expressions 5-20
Assignment 5-20
CASE 5-21
IF 5-23
Group Comparison 5-24
Bit Operations 5-31
Bit Extractions 5-31
Bit Shifts 5-33
7. Simple Variables
Declaring Simple Variables 7-1
Specifying Simple Variable Address Types 7-3
Initializing Simple Variables With Numbers 7-4
Initializing Simple Variables With Character Strings 7-4
Examples 7-4
8. Arrays
Declaring Arrays 8-2
Declaring Read-Only Arrays 8-6
Using Constant Lists in Array Declarations 8-8
Read-Only Arrays 8-8
Nonstring Arrays 8-9
9. Structures
Structure Layout 9-3
Overview of Structure Alignment 9-4
Structures Aligned at Odd-Byte Boundaries 9-5
Overview of Field Alignment 9-5
SHARED2 9-6
SHARED8 9-6
PLATFORM 9-7
AUTO 9-7
Differences Between PLATFORM and AUTO 9-8
Field and Base Alignment 9-8
Base Alignment 9-9
Structure Alignment Examples 9-9
Array Alignment in Structures 9-13
Structure Alignment 9-15
Substructure Alignment 9-16
Alignment Considerations for Substructures 9-19
FIELDALIGN Clause 9-20
FIELDALIGN Compiler Directive 9-20
SHARED2 Parameter 9-20
SHARED8 Parameter 9-22
Alignment of Fields 9-24
Optimizing Structure Layouts 9-24
Structure Length 9-26
Alignment of UNSIGNED(17-31) Fields 9-27
Reference Alignment With Structure Pointers 9-27
REFALIGNED Clause 9-28
Default Reference Alignment 9-29
REFALIGNED(2) 9-29
REFALIGNED(8) 9-31
Code Generation for Structure References 9-32
STRUCTALIGN (MAXALIGN) Attribute 9-32
9. Structures (continued)
VOLATILE Attribute 9-33
Declaring Definition Structures 9-33
Declaring Template Structures 9-35
Declaring Referral Structures 9-38
Declaring Simple Variables in Structures 9-40
Declaring Arrays in Structures 9-40
Declaring Substructures 9-42
Definition Substructures 9-42
Referral Substructures 9-45
Declaring Filler 9-46
Declaring Simple Pointers in Structures 9-48
Using Simple Pointers 9-49
Assigning Addresses to Pointers in Structures 9-50
Declaring Structure Pointers in Structures 9-51
Declaring Redefinitions 9-53
Simple Variable 9-54
Array 9-55
Definition Substructure 9-56
Referral Substructure 9-59
Simple Pointer 9-61
Structure Pointer 9-63
10. Pointers
Overview of Pointer Declaration 10-2
Declaring VOLATILE Pointers 10-4
Simple 10-4
Structure 10-5
Address Types 10-5
BADDR and WADDR 10-9
SGBADDR, SGWADDR, SGXBADDR, and SGXWADDR
(System Globals) 10-9
PROCADDR (Procedures, Procedure Pointers, and Procedure Entry Points)
10-10
EXTADDR 10-11
Declaring Simple Pointers 10-12
Initializing Simple Pointers 10-14
12. Statements
Using Semicolons in Statements 12-2
Compound Statements 12-2
ASSERT 12-3
Assignment 12-4
Pointer Assignment 12-6
Assigning Numbers to FIXED Variables 12-7
Assigning Character Strings 12-7
Examples 12-8
Bit-Deposit Assignment 12-9
CALL 12-10
CASE 12-12
Empty CASE 12-12
CASE (continued)
Labeled CASE 12-13
Unlabeled CASE 12-15
DO-UNTIL 12-17
DROP 12-19
Dropping Labels 12-19
Dropping Temporary Variables 12-20
FOR 12-20
Nested 12-21
Standard 12-21
Optimized 12-22
GOTO 12-23
Local 12-23
Nonlocal 12-24
GOTO and Target Statements With Different Trapping States 12-24
IF 12-26
Testing Address Types 12-27
Testing Hardware Indicators 12-27
Move 12-28
Destination Shorter Than Source 12-32
$FILL8, $FILL16, and $FILL32 Statements 12-33
RETURN 12-34
Functions 12-35
Procedures and Subprocedures 12-36
Condition Codes 12-37
SCAN and RSCAN 12-40
Determining What Stopped a Scan 12-42
Extended Pointers 12-42
Crossing Variable Boundaries 12-43
P-Relative Arrays 12-43
USE 12-45
WHILE 12-45
A. Syntax Summary
Data Types A-1
Constants A-1
Character String A-2
STRING Numeric A-2
INT Numeric A-2
INT(32) Numeric A-2
FIXED Numeric A-3
REAL and REAL(64) Numeric A-3
Constant List A-3
Expressions A-4
Arithmetic A-4
Conditional A-5
Assignment A-5
CASE A-5
IF A-5
Group Comparison A-6
Bit Extraction A-6
Bit Shift A-6
Declarations A-7
LITERAL A-7
DEFINE A-7
Simple Variable A-8
Array A-8
Read-Only Array A-9
Structures A-9
Redefinition A-16
Pointer A-21
Equivalenced Variable A-22
Procedure and Subprocedure A-28
Examples (continued)
Example 5-11. Checking a Bit for a Nonzero Value 5-32
Example 5-12. Arithmetic Left Shift 5-34
Example 6-1. Literal Declarations 6-2
Example 6-2. DEFINE Declarations 6-5
Example 6-3. STRUCT and DEFINE Macro Items With the Same Name 6-5
Example 6-4. Parenthesized and Nonparenthesized DEFINE Bodies 6-6
Example 6-5. Fewer Actual Parameters Than Formal Parameters 6-7
Example 6-6. No Actual Parameters 6-7
Example 6-7. More Actual Parameters Than Formal Parameters 6-7
Example 6-8. Commas in an Actual Parameter 6-7
Example 6-9. Parentheses in an Actual Parameter 6-8
Example 6-10. Assignment Statement Using DEFINE Macro Identifier 6-8
Example 6-11. Incrementing and Decrementing Utilities 6-8
Example 6-12. Filling an Array With Zeros 6-8
Example 6-13. Checking a Condition Code 6-9
Example 7-1. Declaring Simple Variables Without Initializing Them 7-5
Example 7-2. Declaring and Initializing Simple Variables 7-5
Example 7-3. Effect of fpoint on FIXED Simple Variables 7-5
Example 7-4. Initializing Simple Variables With Constants and Variables* 7-6
Example 7-5. Declaring Simple VOLATILE Variables 7-6
Example 7-6. PROCADDR and PROCPTR 7-6
Example 8-1. Declaring Arrays With Various Bounds 8-4
Example 8-2. Declaring Arrays and Initializing Them With Constants 8-4
Example 8-3. Declaring Arrays and Initializing Them With Constant Lists 8-5
Example 8-4. Initializing Arrays 8-5
Example 8-5. Array With Positive fpoint 8-5
Example 8-6. Array With Negative fpoint 8-5
Example 8-7. Read-Only Array Declaration With Indirection Symbol 8-7
Example 8-8. Declaring and Initializing a Read-Only Array 8-7
Example 8-9. Declaring Read-Only Arrays With Constant Lists 8-8
Example 8-10. Declaring Nonstring Arrays With Constant Lists 8-9
Example 9-1. Arrays Within Structures 9-13
Example 9-2. SHARED2: 2-Byte Alignment 9-14
Example 9-3. SHARED8: 4-Byte Alignment 9-14
Example 9-4. 8-Byte Alignment and 4-Byte Alignment 9-15
Example 9-5. SHARED8 Structures With Different Base Alignments 9-15
Example 9-6. Well-Aligned Structure With Well-Aligned Substructure 9-16
Example 9-7. SHARED8 Structures With SHARED2 Substructures 9-17
Examples (continued)
Example 9-8. SHARED2 Structures With SHARED8 Substructure 9-17
Example 9-9. SHARED8 Structure With SHARED2 Substructure 9-18
Example 9-10. Combining SHARED2 and SHARED8 Structures 9-18
Example 9-11. AUTO Field Alignment in Structure (Error) 9-19
Example 9-12. FIELDALIGN(SHARED2) and REFALIGNED(2) Directives 9-21
Example 9-13. Byte Offsets (Decimal) of Fields of a SHARED2 Structure 9-22
Example 9-14. Filler Forcing Alignment in a SHARED8 Structure 9-24
Example 9-15. Structure With SHARED2 Field Alignment 9-25
Example 9-16. Structure With SHARED8 Field Alignment 9-25
Example 9-17. Optimized Structure With SHARED8 Field Alignment 9-25
Example 9-18. Structures That Need Filler 9-26
Example 9-19. Structure Field Crossing an Even-Byte Address (Error) 9-26
Example 9-20. Structure That Needs Filler 9-26
Example 9-21. SHARED8 Structure With Misaligned UNSIGNED Fields 9-27
Example 9-22. SHARED8 Structure With Correctly Aligned UNSIGNED Fields 9-27
Example 9-23. REFALIGNED Clause With Structure Pointers 9-28
Example 9-24. REFALIGNED Clause 9-28
Example 9-25. Default Reference Alignment 9-29
Example 9-26. REFALIGNED(2) 9-30
Example 9-27. REFALIGNED(8) 9-31
Example 9-28. VOLATILE Attribute 9-33
Example 9-29. Template Structure Declaration 9-37
Example 9-30. Template Structure With STRUCTALIGN(MAXALIGN) 9-37
Example 9-31. Referral Structure That References a Template Structure 9-39
Example 9-32. Simple Variables Within a Structure 9-40
Example 9-33. Arrays Within a Structure 9-41
Example 9-34. Using a Zero-Length Array to Initialize a Structure 9-42
Example 9-35. Declaring Definition Substructures 9-44
Example 9-36. Declaring a Referral Substructure 9-46
Example 9-37. Filler Byte Declarations 9-47
Example 9-38. Filler Bit Declaration 9-47
Example 9-39. Simple Pointers Within a Structure 9-49
Example 9-40. Assigning Addresses to Pointers in Structures 9-50
Example 9-41. Assigning Addresses to Pointers in Structures 9-51
Example 9-42. Declaring a Structure Pointer Within a Structure 9-53
Example 9-43. Simple Variable Redefinition 9-55
Example 9-44. Array Redefinition 9-56
Example 9-45. Definition Substructure Redefinition 9-58
Examples (continued)
Example 9-46. Definition Substructure Redefinition 9-59
Example 9-47. Referral Substructure Redefinition 9-60
Example 9-48. Simple Pointer Redefinition 9-62
Example 9-49. Structure Pointer Redefinition 9-64
Example 10-1. Declaring VOLATILE Simple Pointers 10-4
Example 10-2. Declaring VOLATILE Structure Pointers 10-5
Example 10-3. Determining Address Types 10-7
Example 10-4. BADDR and WADDR 10-9
Example 10-5. SGBADDR, SGWADDR, SGXBADDR, and SGXWADDR 10-9
Example 10-6. PROCADDR 10-10
Example 10-7. CBADDR and CWADDR 10-11
Example 10-8. EXTADDR Declarations 10-11
Example 10-9. Declaring But Not Initializing a Simple Pointer 10-15
Example 10-10. Declaring and Initializing a Simple Pointer 10-15
Example 10-11. Declaring and Initializing a STRING Simple Pointer 10-15
Example 10-12. Declaring and Initializing Simple Pointers 10-15
Example 10-13. Declaring and Initializing a Simple Pointer, Using $XADR 10-16
Example 10-14. Declaring and Initializing an Extended Simple Pointer 10-16
Example 10-15. Declaring and Initializing a Structure Pointer, Using $OFFSET 10-18
Example 10-16. Declaring and Initializing a STRING Structure Pointer 10-18
Example 10-17. Declaring and Initializing a Local Structure Pointer 10-19
Example 10-18. Declaring and Initializing a Local STRING Structure Pointer 10-19
Example 10-19. Declaring and Initializing a Local STRING Structure Pointer 10-19
Example 10-20. System Global Pointer Declaration 10-20
Example 11-1. Declaring Equivalenced Variables 11-3
Example 11-2. Equivalenced Pointers 11-4
Example 11-3. Memory Usage for Nonstructured Equivalenced Variables 11-7
Example 11-4. Read-Only Pointer 11-12
Example 11-5. Equivalenced Objects of Unequal Length 11-14
Example 11-6. REFALIGNED Clause for Equivalenced Simple Pointers 11-15
Example 11-7. Equivalencing PROCADDR and PROCPTR Variables 11-15
Example 11-8. Declaring Equivalenced Structures 11-18
Example 11-9. Structure Variants 11-20
Example 11-10. Structure Variants 11-20
Example 11-11. Memory Usage for Structured Equivalenced Variables
(Incorrect) 11-21
Example 11-12. Memory Usage for Structured Equivalenced Variables
(Correct) 11-21
Examples (continued)
Example 11-13. FIELDALIGN Clause in Structured Equivalenced Variables 11-22
Example 11-14. Equivalenced Simple Variable Declaration 11-24
Example 11-15. Equivalenced Definition Structure Declaration 11-25
Example 11-16. Equivalenced Referral Structure Declaration 11-26
Example 11-17. Equivalenced Simple Pointer Declaration 11-28
Example 11-18. Equivalenced Structure Pointer Declaration 11-29
Example 12-1. Null Compound Statement 12-3
Example 12-2. Compound Statement 12-3
Example 12-3. ASSERTION Directive and ASSERT Statement 12-4
Example 12-4. Assignment Statements 12-8
Example 12-5. Assignment Statements Equivalent to a Constant List 12-8
Example 12-6. Assignment Statement With Assignment Expressions 12-8
Example 12-7. CALL Statement 12-12
Example 12-8. Empty CASE Statement 12-12
Example 12-9. Labeled CASE Statement 12-14
Example 12-10. Labeled CASE Statement 12-15
Example 12-11. Unlabeled CASE Statement 12-16
Example 12-12. Unlabeled CASE Statement 12-17
Example 12-13. Unlabeled CASE Statement Assigning Text to Array 12-17
Example 12-14. DO-UNTIL Statement 12-18
Example 12-15. DO-UNTIL Statement 12-18
Example 12-16. DO-UNTIL Statement With Hardware Indicator 12-19
Example 12-17. DO-UNTIL Statement With GOTO Statement 12-19
Example 12-18. Nested FOR Statement 12-21
Example 12-19. Standard FOR Statement 12-22
Example 12-20. Standard and Optimized FOR Statements 12-22
Example 12-21. Local GOTO Statement 12-23
Example 12-22. Nonlocal GOTO Statement 12-24
Example 12-23. Local GOTO and Target Statements That Have Different Trapping
States 12-24
Example 12-24. Nonlocal GOTO and Target Statements That Have Different Trapping
States 12-25
Example 12-25. IF Statement 12-26
Example 12-26. MOVE Statement Copying to an Array 12-31
Example 12-27. MOVE Statement Copying Bracketed and Unbracketed
Constants 12-31
Example 12-28. MOVE Statement Copying From One Structure to Another 12-31
Example 12-29. MOVE Statement Copying a Substructure 12-32
Examples (continued)
Example 12-30. MOVE Statement With Destination Shorter Than Source 12-32
Example 12-31. FILL16 Statement 12-33
Example 12-32. RETURN Statements Nested in an IF Statement 12-35
Example 12-33. RETURN Statement That Returns a Value and a Condition
Code 12-35
Example 12-34. Testing a Condition Code 12-35
Example 12-35. RETURN Statement in a Procedure 12-36
Example 12-36. RETURN Statement in a Procedure That Returns a Condition
Code 12-37
Example 12-37. Procedure Without RETURNSCC 12-37
Example 12-38. Procedure With RETURNSCC 12-37
Example 12-39. Function Without RETURNSCC 12-38
Example 12-40. Function With RETURNSCC 12-38
Example 12-41. Condition Code Returned by Function Called by CALL
Statement 12-39
Example 12-42. Condition Code Based on Numeric Value 12-39
Example 12-43. Condition Code That Is Independent of the Function’s Value 12-40
Example 12-44. Invalid Function That Attempts to Return an Explicit Condition
Code 12-40
Example 12-45. SCAN UNTIL Statement 12-42
Example 12-46. Determining What Stopped a Scan 12-42
Example 12-47. Extended Pointers in SCAN and RSCAN Statements 12-42
Example 12-48. Scanning Adjacent Fields Within a Structure 12-43
Example 12-49. Scanning Data in a P-Relative Array 12-44
Example 12-50. Scanning Data in a P-Relative Array 12-44
Example 12-51. WHILE Statement 12-46
Example 12-52. WHILE Statement 12-46
Example 13-1. OVERFLOW_TRAPS Compiler Directive and Procedure
Attribute 13-2
Example 13-2. ENABLE_OVERFLOW_TRAPS and DISABLE_OVERFLOW_TRAPS
Block Attributes 13-3
Example 13-3. Assignments After Which You Can Test Condition Codes 13-7
Example 13-4. Hardware Indicators in DO-UNTIL Statements 13-9
Example 13-5. Hardware Indicators in WHILE Statements 13-9
Example 13-6. Testing a Hardware Indicator Set in a Calling Procedure 13-15
Example 13-7. Returning the Value of $OVERFLOW in a Reference
Parameter 13-16
Example 14-1. Procedure Declaration 14-4
Example 14-2. EXTENSIBLE Procedures as Actual Parameters 14-9
Examples (continued)
Example 14-3. Function With Value and Reference Formal Parameters 14-15
Example 14-4. Reference Structure as a Formal Reference Parameter 14-15
Example 14-5. Using a Referral STRUCT as a Formal Parameter 14-16
Example 14-6. Procedures 14-18
Example 14-7. FORWARD Declaration for a Procedure 14-18
Example 14-8. Function Subprocedure 14-22
Example 14-9. Procedure Entry-Point Identifiers 14-23
Example 14-10. FORWARD Declarations for Entry Points 14-24
Example 14-11. Subprocedure Entry-Point Identifiers 14-25
Example 14-12. PROCPTRs as Variables and Formal Parameters 14-30
Example 14-13. PROCPTR in a Structure 14-31
Example 14-14. PROCPTRs in Structure 14-31
Example 14-15. Code That Uses the Structure in Example 14-14 on
page 14-31 14-31
Example 14-16. PROCPTRs as Formal Parameters 14-32
Example 14-17. Assignments to PROCPTRs 14-33
Example 14-18. Assignments to PROCPTRs 14-34
Example 14-19. Dynamically Selected Procedure Call 14-35
Example 14-20. Dynamically Selected Procedure Call 14-36
Example 14-21. IF Statements Identified by Labels 14-37
Example 15-1. Built-In Routine With Address Parameter 15-2
Example 15-2. Built-In Routine With Address Output Parameter 15-3
Example 15-3. $ATOMIC_ADD Routine 15-5
Example 15-4. $ATOMIC_AND Routine 15-6
Example 15-5. $ATOMIC_DEP Routine 15-7
Example 15-6. $ATOMIC_GET Routine 15-8
Example 15-7. $ATOMIC_OR Routine 15-9
Example 15-8. $ATOMIC_PUT Routine 15-10
Example 15-9. $ABS Routine 15-23
Example 15-10. $ALPHA Routine 15-24
Example 15-11. $ASCIITOFIXED Routine 15-25
Example 15-12. $AXADR Routine 15-26
Example 15-13. $BADDR_TO_EXTADDR Routine 15-27
Example 15-14. $BADDR_TO_WADDR Routine 15-27
Example 15-15. $BITLENGTH Routine 15-28
Example 15-16. $BITOFFSET Routine 15-29
Example 15-17. $CARRY Routine 15-30
Example 15-18. $CHECKSUM Routine 15-32
Examples (continued)
Example 15-19. $COMP Routine 15-32
Example 15-20. $COUNTDUPS Routine 15-34
Example 15-21. $DBL Routine 15-35
Example 15-22. $DBLL Routine 15-35
Example 15-23. $DBLR Routine 15-36
Example 15-24. $DFIX Routine 15-37
Example 15-25. $EFLT Routine 15-37
Example 15-26. $EFLTR Routine 15-38
Example 15-27. $EFLTR Routine 15-39
Example 15-28. $EXECUTEIO Routine 15-41
Example 15-29. $EXTADDR_TO_BADDR Routine 15-41
Example 15-30. $EXTADDR_TO_WADDR Routine 15-42
Example 15-31. $FILL8 Procedure 15-43
Example 15-32. $FIX Routine 15-44
Example 15-33. $FIXD Routine 15-45
Example 15-34. $FIXEDTOASCII Routine 15-46
Example 15-35. $FIXEDTOASCIIRESIDUE Routine 15-47
Example 15-36. $FIXI Routine 15-48
Example 15-37. $FIXL Routine 15-48
Example 15-38. $FIXR Routine 15-49
Example 15-39. $FLT Routine 15-50
Example 15-40. $FLTR Routine 15-50
Example 15-41. $HIGH Routine 15-52
Example 15-42. $IFIX Routine 15-53
Example 15-43. $INT Routine 15-54
Example 15-44. $INT Routine 15-54
Example 15-45. Difference Between $INT and $INT_OV 15-55
Example 15-46. $INTERROGATEHIO Routine 15-56
Example 15-47. $INTERROGATEIO Routine 15-58
Example 15-48. $INTR Routine 15-59
Example 15-49. $LEN Routine 15-59
Example 15-50. $LEN Routine 15-60
Example 15-51. $LEN Routine 15-60
Example 15-52. $LFIX Routine 15-61
Example 15-53. $LMAX Routine 15-61
Example 15-54. $LMIN Routine 15-62
Example 15-55. $LOCATESPTHDR Routine 15-63
Example 15-56. $LOCKPAGE Routine 15-64
Examples (continued)
Example 15-57. $MAX Routine 15-64
Example 15-58. $MIN Routine 15-65
Example 15-59. $MOVEANDCXSUMBYTES Routine 15-66
Example 15-60. $MOVENONDUP Routine 15-68
Example 15-61. $NUMERIC Routine 15-68
Example 15-62. $OCCURS Routine With Nonstructure Arrays 15-70
Example 15-63. $OCCURS Routine With Structure Arrays 15-71
Example 15-64. $OCCURS Routine With Template Structure Arrays 15-71
Example 15-65. $OFFSET Routine 15-72
Example 15-66. $OFFSET Routine 15-72
Example 15-67. $OFFSET Routine Applied to a Template Structure 15-73
Example 15-68. Parameters Passed Conditionally and Unconditionally 15-74
Example 15-69. Parameters Omitted Conditionally and Unconditionally 15-75
Example 15-70. Parameters Passed Conditionally 15-75
Example 15-71. $OPTIONAL Routine for a Front-End Interface 15-75
Example 15-72. $OVERFLOW Routine 15-77
Example 15-73. $PARAM Routine 15-77
Example 15-74. $POINT Routine 15-78
Example 15-75. $READBASELIMIT Routine 15-79
Example 15-76. $READCLOCK Routine 15-80
Example 15-77. $READSPT Routine 15-81
Example 15-78. $READTIME Routine 15-81
Example 15-79. $SCALE Routine 15-82
Example 15-80. Using the $SCALE Routine to Maintain Precision 15-83
Example 15-81. $SGBADDR_TO_EXTADDR Routine 15-83
Example 15-82. $SGBADDR_TO_SGWADDR Routine 15-84
Example 15-83. $SGWADDR_TO_EXTADDR Routine 15-85
Example 15-84. $SGWADDR_TO_SGBADDR Routine 15-85
Example 15-85. $SPECIAL Routine 15-86
Example 15-86. $STACK_ALLOCATE Routine 15-87
Example 15-87. $TRIGGER Routine 15-88
Example 15-88. $TYPE Routine 15-89
Example 15-89. $UDBL Routine 15-90
Example 15-90. $UDIVREM16 Routine 15-91
Example 15-91. $UDIVREM32 Routine 15-92
Example 15-92. $UNLOCKPAGE Routine 15-93
Example 15-93. $WADDR_TO_BADDR Routine 15-94
Example 15-94. $WADDR_TO_EXTADDR Routine 15-94
Examples (continued)
Example 15-95. $WRITEPTE Routine 15-95
Example 15-96. $XADR Routine 15-96
Example 16-1. Compiler Command Lines 16-2
Example 16-2. Naming a Compilation Unit 16-13
Example 16-3. Declaring a Named Data Block 16-13
Example 16-4. Data Block and Variable With the Same Name 16-13
Example 16-5. Declaring a Private Data Block 16-14
Example 16-6. Declaring Unblocked Data 16-14
Example 17-1. Compilation Commands With Compiler Directives 17-2
Example 17-2. Pushing and Popping a Directive Stack 17-5
Example 17-3. DEFINETOG, IF, and ENDIF Directives 17-7
Example 17-4. DEFINETOG, IFNOT, and ENDIF Directives Directive 17-7
Example 17-5. SETTOG, IF, and ENDIF Directives 17-7
Example 17-6. SETTOG, IFNOT, and ENDIF Directives 17-7
Example 17-7. SETTOG, RESETTOG, IF, and ENDIF Directives 17-8
Example 17-8. MYPROG Source File for Example 17-9 Through
Example 17-12 17-10
Example 17-9. Saving Global Data Declarations and Data Initializations 17-10
Example 17-10. Retrieving Global Data Declarations and Data Initializations 17-11
Example 17-11. Checking the Syntax of Global Data Declarations 17-11
Example 17-12. Recompiling MYPROG After Correcting Errors 17-11
Example 17-13. Original SAVEGLOBALS Compilation Source File 17-12
Example 17-14. New GLOBALS Source File 17-12
Example 17-15. Corrected SAVEGLOBALS Compilation Source File 17-13
Example 17-16. DEFEXPAND Directive 17-27
Example 17-17. FIXERRS Macro 17-32
Example 17-18. ERRORFILE Directive 17-32
Example 17-19. ERRORS Directive 17-33
Example 17-20. GP_OK, NOGP_OK, PUSHGP_OK, and POPGP_OK
Directive 17-39
Example 17-21. IF Directive Without Matching ENDIF Directive 17-41
Example 17-22. IF Directive With Matching ENDIF Directive 17-42
Example 17-23. INNERLIST and NOINNERLIST Directives 17-43
Example 17-24. Listing Source Code But Not System Declarations 17-45
Example 17-25. File for OPTIMIZEFILE Directive 17-48
Example 17-26. OVERFLOW_TRAPS Compiler Directive 17-50
Example 17-27. PAGE Directive 17-51
Example 17-28. PRINTSYM Directive 17-52
Examples (continued)
Example 17-29. ROUND Directive 17-56
Example 17-30. SECTION Directive 17-58
Example 17-31. SOURCE Directive Specifying System Procedure
Declarations 17-63
Example 17-32. Procedure That Calls Procedures Specified by SOURCE
Directive 17-64
Example 17-33. SOURCE Directive 17-64
Example 17-34. SOURCE Directive 17-64
Example 17-35. SOURCE Directive 17-64
Example 17-36. SUPPRESS Directive 17-66
Example 17-37. SYMBOLS Directive 17-67
Example 17-38. SYNTAX Directive 17-68
Example 17-39. SYNTAX Directive 17-68
Example B-1. Disk File Name B-2
Example B-2. DEFINE Names B-6
Example D-1. C Procedure Extracting Two pTAL Return Values from a 64-Bit Value
(Works Only on TNS/R Systems—Not Recommended) D-2
Example D-2. C Procedure Extracting Only the Traditional Function Value from a 64-
Bit Value (Works Only on TNS/R Systems) D-3
Example D-3. Migrating a pTAL Procedure With Two Return Values to TNS/E
(Works on TNS/R and TNS/E Systems) D-3
Figures
Figure 5-1. Parentheses’ Effect on Operator Precedence 5-4
Figure 5-2. Ending Address After Comparing INT Strings 5-27
Figure 5-3. Ending Address After Comparing Strings of Data Type STRING and
INT 5-28
Figure 9-1. Alignment of SHARED8 Structure With Base Alignment of 8 9-10
Figure 9-2. Well-Aligned and Misaligned SHARED8 Structures With Base Alignment
of 8 9-11
Figure 9-3. Alignment of a SHARED8 Structure With Base Alignment of 4 9-12
Figure 9-4. Well-Aligned and Misaligned SHARED8 Structures With Base Alignment
of 4 9-13
Figure 11-1. Indirect Array 11-8
Figure 11-2. Equivalenced Simple Variables 11-10
Figure 11-3. The Object and Address Types of a Pointer 11-13
Figure 11-4. Equivalenced Simple Pointer Declaration 11-14
Figure 11-5. Equivalenced Definition Structure for CISC Architecture 11-19
Figure 16-1. Compiling and Linking pTAL Programs 16-1
Figures (continued)
Figure 16-2. Creating a Loadfile on TNS/E for TNS/E 16-8
Figure 16-3. Creating Loadfiles on TNS/R for TNS/R 16-9
Figure 16-4. Creating a Loadfile on TNS for TNS/R 16-10
Figure 16-5. Producing Hybrid Loadfiles 16-11
Tables
Table i. Related Manuals xxxiv
Table ii. System Manuals xxxiv
Table iii. Programming Manuals xxxiv
Table iv. Program Development Manuals xxxv
Table 1-1. EpTAL, pTAL, and TAL Compiler Characteristics 1-2
Table 1-2. HP NonStop Operating Systems 1-2
Table 2-1. Special Characters 2-2
Table 2-2. Reserved Keywords 2-3
Table 2-3. Nonreserved Keywords 2-3
Table 2-4. Delimiters 2-4
Table 2-5. Operators 2-5
Table 2-6. Base Address Symbols 2-7
Table 2-7. Indirection Symbols 2-7
Table 2-8. Identifier Classes 2-9
Table 2-9. Variable Types 2-10
Table 3-1. Storage Units 3-1
Table 3-2. Data Types 3-1
Table 3-3. Operations by Data Type 3-4
Table 3-4. Data Types and Their Address Types 3-5
Table 3-5. Valid Address Conversions 3-9
Table 4-1. TNS/R Native Atomic Misalignment Handling Methods 4-3
Table 5-1. Precedence of Operators 5-3
Table 5-2. Operands in Arithmetic Expressions 5-5
Table 5-3. Arithmetic Expressions 5-6
Table 5-4. Signed Arithmetic Operators 5-6
Table 5-5. Signed Arithmetic Operand and Result Types 5-6
Table 5-6. Unsigned Arithmetic Operators 5-8
Table 5-7. Unsigned Arithmetic Operand and Result Types 5-9
Table 5-8. Bitwise Logical Operators 5-10
Table 5-9. Valid Address-Type Comparisons 5-11
Table 5-10. Valid Address Expressions 5-13
Table 5-11. Conditional Expressions 5-16
Tables (continued)
Table 5-12. Conditions in Conditional Expressions 5-16
Table 5-13. Results of NOT, OR, and AND Operators 5-17
Table 5-14. Signed Relational Operators 5-18
Table 5-15. Unsigned Relational Operators 5-19
Table 5-16. Special Expressions 5-20
Table 5-17. Bit Operations 5-31
Table 5-18. Bit-Shift Operators 5-34
Table 9-1. Kinds of Structures 9-1
Table 9-2. Structure Items 9-3
Table 9-3. Base Alignment and Field Alignment Relationships 9-9
Table 9-4. Field Alignment of Substructures 9-19
Table 9-5. Variable Alignment 9-22
Table 9-6. Data Accessed by Simple Pointers 9-49
Table 9-7. Addresses in Simple Pointers 9-50
Table 9-8. Addresses in Structure Pointers 9-53
Table 10-1. Address Types 10-6
Table 10-2. Object Data Types and Their Addresses 10-7
Table 11-1. Equivalenced Variables 11-1
Table 11-2. Equivalenced Variable Terminology 11-1
Table 11-3. Valid Equivalenced Variable Declarations 11-2
Table 11-4. Data Types for Equivalenced Variables 11-13
Table 12-1. Summary of Statements 12-1
Table 13-1. Hardware Indicators 13-1
Table 14-1. Formal Parameter Specification 14-14
Table 15-1. Built-In Routines for Atomic Operations 15-4
Table 15-2. pTAL Privileged Routines 15-11
Table 15-3. Built-In Type-Conversion Routines 15-12
Table 15-4. Built-In Address-Conversion Routines 15-14
Table 15-5. Built-In Character-Test Routines 15-14
Table 15-6. Built-In Minimum and Maximum Routines 15-15
Table 15-7. Built-In Arithmetic Routines 15-15
Table 15-8. Built-In Carry and Overflow Routines 15-15
Table 15-9. Built-In FIXED-Expression Routines 15-15
Table 15-10. Built-In Variable-Characteristic Routines 15-16
Table 15-11. Built-In Procedure-Parameter Routines 15-16
Table 15-12. Miscellaneous Built-In Routines 15-16
Table 15-13. Built-In Routines for Nonatomic Operations 15-17
Table 15-14. $OCCURS for Nonstructure Arrays 15-69
Tables (continued)
Table 15-15. $OCCURS for Structure Arrays and Arrays Within Structures 15-70
Table 16-1. Completion Codes 16-6
Table 17-1. Compiler Directives by Category 17-14
Table 17-2. Compiler Directives by Name 17-17
Table 17-3. Data Block Names 17-21
Table 18-1. pTAL Cross Compiler Platforms 18-1
Abstract
This publication describes the syntax of pTAL, the Portable Transaction Application
Language for HP NonStop™ systems [TNS/R pTAL compiler (T9248) and TNS/E
EpTAL compiler (T0561)] for system and application programmers.
Product Version
pTAL D44
EpTAL H01
Supported Release Version Updates (RVUs)
This publication supports D44.00, G06.20, H06.08 and all subsequent D-series,
G-series, and H-series RVUs unless otherwise indicated by its replacement
publication.
Document History
Part Number Product Version Published
115327 pTAL D40 December 1995
523746-001 pTAL D40 May 2003
523746-002 pTAL D44 September 2003
523746-005 pTAL D44, EpTAL H01 July 2005
523746-006 pTAL D44, EpTAL H01 November 2006
Topics:
• Audience on page xxxiii
• Additional Information on page xxxiii
• Notation Conventions on page xxxvii
Audience
This manual is intended for system programmers and application programmers familiar
with NonStop systems.
Additional Information
• Table i, Related Manuals, on page xxxiv
• Table ii, System Manuals, on page xxxiv
• Table iii, Programming Manuals, on page xxxiv
• Table iv, Program Development Manuals, on page xxxv
Notation Conventions
• Hypertext Links on page xxxvii
• Syntax Diagram Conventions on page xxxvii
• Notation for Messages on page xli
• Change Bar Notation on page xlii
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 xxxiii.
«item5»
VST406.vsd
To use a railroad diagram, follow the direction of the arrows and specify syntactic items
as indicated by the diagram pieces:
Diagram Piece Meaning
Type KEYWORD as shown. You can type letters in uppercase or
KEYWORD
lowercase.
VST412.vsd
item Replace item with a value that fits its description, which follows the
syntax diagram.
VST413.vsd
item2
VST407.vsd
item1
item2
VST408.vsd
item
Specify item one or more times, separating occurrences
with commas.
,
VST409.vsd
n
VST742.vsd
Note. To refer to a particular railroad diagram or figure when giving feedback to HP, use the
number at the bottom right corner of that railroad diagram or figure (for example, VST742.vsd).
ns
$ volume
VST420.vsd
ns ns
" RETURN^SORT^ERRORS "
RETURN_SORT_ERRORS_
VST185.vsd
VST410.vsd
VST411.vsd
VST184.vsd
Bold Text. Bold text in an example indicates user input entered at the terminal. For
example:
ENTER RUN CODE
?123
CODE RECEIVED: 123.00
The user must press the Return key after typing the input.
Nonitalic text. Nonitalic letters, numbers, and punctuation indicate text that is displayed or
returned exactly as shown. For example:
Backup Up.
lowercase italic letters. Lowercase italic letters indicate variable items whose values are
displayed or returned. For example:
p-register
process-name
[ ] Brackets. Brackets enclose items that are sometimes, but not always, displayed. For
example:
BLOCK = BEGIN [: block_attribute ]
declarations
END;
A group of items enclosed in brackets is a list of all possible items that can be
displayed, of which one or none might actually be displayed. The items in the list might
be arranged either vertically, with aligned brackets on each side of the list, or
horizontally, enclosed in a pair of brackets and separated by vertical lines. For
example:
LANGUAGE [ UNSPECIFIED | C | PASCAL | FORTRAN ]
{ } Braces. A group of items enclosed in braces is a list of all possible items that can be
displayed, of which one is actually displayed. The items in the list might be arranged
either vertically, with aligned braces on each side of the list, or horizontally, enclosed in
a pair of braces and separated by vertical lines. For example:
BLOCK_ATTRIBUTE = { ENABLE_OVERFLOW_TRAPS | DISABLE_OVERFLOW_TRAPS }
| Vertical Line. A vertical line separates alternatives in a horizontal list that is enclosed in
brackets or braces. For example:
Transfer status: { OK | Failed }
% Percent Sign. A percent sign precedes a number that is not in decimal notation. The %
notation precedes an octal number. The %B notation precedes a binary number. The
%H notation precedes a hexadecimal number. For example:
%005400
%B101111
%H2F
You can compile pTAL source programs using either the pTAL compiler or the EpTAL
compiler.
The compilers in Table 1-1 on page 1-2 execute under control of the HP NonStop
operating systems in Table 1-2 on page 1-2.
This manual indicates when pTAL behaves differently on TNS/E and TNS/R
architectures. When no architecture is specifically mentioned, the syntax works the
same way on TNS/E and TNS/R architectures.
pTAL Applications
The pTAL language is appropriate for writing applications where optimal performance
has high priority, for example:
• Systems software
° Conversion routines that allow data transfer between HP software and other
applications
pTAL Features
• Procedures on page 1-4
• Subprocedures on page 1-4
• Private Data Area on page 1-4
• Recursion on page 1-5
• Parameters on page 1-5
• Data Types on page 1-5
• Data Grouping on page 1-5
• Pointers on page 1-6
• Data Operations on page 1-6
• Bit Operations on page 1-6
• Built-in Routines on page 1-6
• Compiler Directives on page 1-6
• Modular Programming on page 1-6
Procedures
Each pTAL program contains one or more procedures. A procedure is a discrete
sequence of declarations and statements that performs a specific task. A procedure is
callable from anywhere in the program.
Each procedure executes in its own environment and can contain local variables that
are not affected by the actions of other procedures. When a procedure calls another
procedure, the operating system saves the caller’s environment and restores that
environment when the called procedure returns control to the caller.
Subprocedures
A procedure can contain subprocedures, callable only from within the same procedure.
A subprocedure can have sublocal variables that are not affected by the actions of
other subprocedures. When a subprocedure calls another subprocedure, the caller’s
environment remains in place. The operating system saves the location in the caller to
which control is to return when the called subprocedure terminates.
Recursion
Because each activation of a procedure or subprocedure has its own data area, a
procedure or subprocedure can call itself or can call another procedure that in turn
calls the original procedure.
Parameters
A procedure or subprocedure can have optional or required parameters. The same
procedure or subprocedure can process different sets of variables sent by different
calls to it.
Data Types
A pTAL program can declare and refer to the following types of data:
Data Type Description
STRING 8-bit integer byte
INT, INT(16) 16-bit integer word
INT(32) 32-bit integer doubleword
FIXED, FIXED(0), INT(64) 64-bit integer quadrupleword
FIXED(-19 to -1) Fixed-point quadrupleword
FIXED(1 to 19) Fixed-point quadrupleword
REAL, REAL(32) 32-bit floating-point doubleword
REAL(64) 64-bit floating-point quadrupleword
UNSIGNED(n) n-bit field, where 1 <= n <= 31
BADDR 32-bit byte address
WADDR 32-bit 2-byte address
CBADDR 32-bit byte code word address
CWADDR 32-bit 2-byte code word address
SGBADDR 16-bit SG-relative byte address
SGWADDR 16-bit SG-relative 2-byte address
SGXBADDR 32-bit SG-relative 2-byte address
SGXWADDR 32-bit SG-relative 2-byte address
EXTADDR 32-bit byte address
PROCADDR 32-bit code byte address
Data Grouping
A pTAL program can declare and use groups of related variables, such as arrays and
structures (records).
Pointers
A pTAL program can declare pointers (variables that can contain addresses) and use
them to access locations throughout memory. You can store addresses in pointers
when you declare them or later in your program.
Data Operations
A pTAL program can copy a contiguous group of words or bytes and compare one
group with another. It can scan a series of bytes for the first byte that matches (or fails
to match) a given character.
Bit Operations
A pTAL program can perform bit deposits, bit extractions, and bit shifts.
Built-in Routines
A pTAL program can use built-in routines to convert data types and addresses, test for
an ASCII character, or determine the length, offset, type, or number of occurrences of
a variable.
Compiler Directives
You can use directives to control a compilation. You can, for example, check the syntax
in your source code or control the content of compiler listings.
Modular Programming
You can divide a large pTAL program into modules, compile them separately, and then
link the resulting object files into a new object file.
System Services
Your program can ignore many things such as the presence of other running programs
and whether your program fits into memory. For example, programs are loaded into
memory for you and absent pages are brought from disk into memory as needed.
System Procedures
The file system treats all devices as files, including disk files, disk packs, terminals,
printers, and programs running on the system. File-system procedures provide a
file-access method that lets you ignore the peculiarities of devices. Your program can
refer to a file by the file’s symbolic name without knowing the physical address or
configuration status of the file.
Your program can call system procedures that activate and terminate programs
running on any processor on the system, and can also call system procedures that
monitor the operation of a running program or processor. If the monitored program
stops or a processor fails, your program can determine this fact.
For more information about system procedures see:
• Guardian Procedure Calls Reference Manual
• Guardian Programmer’s Guide
Character Set
pTAL supports the complete ASCII character set, which includes:
• Uppercase and lowercase alphabetic characters (A through Z.)
• Numeric characters (0 through 9)
• Special characters
Keywords
Keywords have predefined meanings to the compiler when used as shown in the
syntax diagrams in this manual.
Keyword Type Description
Reserved Reserved by the compiler. Do not use reserved keywords (shown in
Table 2-2 on page 2-3) for your identifiers.
Nonreserved You can use nonreserved keywords anywhere identifiers are allowed
except as noted in the Restrictions column of Table 2-3 on page 2-3.
Delimiters
Delimiters are symbols that begin, end, or separate fields of information. Delimiters tell
the compiler how to handle the fields of information.
Operators
Operators specify operations, such as arithmetic or assignments, that you want to
perform on data items.
Indirection Symbols
Indirection symbols determine the address types of variables. Use indirection symbols
when declaring formal parameters to cause them to be passed by reference (rather
than by value).
Declarations
Declarations allocate storage and associate identifiers with declarable objects in a
program; that is:
• Variables
• LITERALs and DEFINEs (see Section 6, LITERALs and DEFINEs)
• Procedures (see Section 14, Procedures, Subprocedures, and Procedure Pointers)
• Labels (see Labels in Procedures on page 14-37)
• Entry points (see Entry-Point Declarations on page 14-22)
Topics:
• Identifiers on page 2-8
• Variables on page 2-10
• Scope on page 2-10
Identifiers
Identifiers must conform to these rules:
• Identifiers can have up to 132 characters. You can limit the identifier to 31
characters by setting the DO_TNS_SYNTAX on page 17-28.
• Identifiers begin with an alphabetic character, an underscore (_), or a
circumflex (^).
• Identifiers contain alphabetic characters, numeric characters, underscores, or
circumflexes.
• Identifiers contain lowercase and uppercase alphabetic characters. The compiler
treats all characters as uppercase.
• Identifiers cannot be reserved keywords (see Table 2-2 on page 2-3).
• Identifiers can be nonreserved keywords, except as noted in Table 2-3 on
page 2-3.
In addition to the preceding rules, HP recommends that you:
• Use underscores rather than circumflexes to separate words in identifiers (for
example, use Name_Using_Circumflexes rather than
Name^Using^Circumflexes). This guideline reflects international character-set
standards, which allow the character printed for the circumflex to vary by country.
• Do not end identifiers with an underscore. The trailing underscore is reserved for
identifiers supplied by the operating system (such as
Name_Using_Trailing_Underscore_).
Each identifier belongs to an identifier class. The compiler determines the identifier
class based on how you declare the identifier.
.
Variables
A variable is a symbolic representation of data. It can be a single-element variable or a
multiple-element variable. You use variables to store data that can change during
program execution.
Before you can access data stored in a variable you must either:
• Initialize the variable with a value when you declare the variable
• Assign a value to the variable after you declare the variable
.
Scope
Every declared item in a pTAL program has a scope that determines where in the
program it is visible (after the point of declaration).
Scope Declared in a ... Visible ...
Global Program Everywhere in the program
Local Procedure Only in the procedure that declares it (including the
subprocedures of that procedure)
Sublocal Subprocedure Only in the subprocedure that declares it
Formal parameters of procedures and subprocedures have local and sublocal scope,
respectively.
Variables that have different scopes can have the same name, but they are different
variables.
Example 2-4. Global and Local Variable With the Same Name
int(32) i; ! This i is global
proc p;
begin
int i; ! This i is local to procedure p, different
! from global variable i, and makes access to
! global variable i impossible ("hides" it).
i := i + 1D; ! ERROR: local variable i is INT(16)
end;
For local and sublocal variables, the compiler generates code to evaluate and store an
initialization expression. For example, for the expression
int k := i * j;
if i, j, and k are local or sublocal variables, the compiler generates code to multiply i
by j and store the product in k.
For global variables, the compiler does not generate such initialization code. Initial
values assigned to global variables are determined by the linker.
Constants
A constant is a value you can store in a variable, declare as a LITERAL, or use as part
of an expression. Constants can be numbers or character strings. The following are
examples of constants:
Constant Type Example
Character string "abc"
Numeric 654
You can specify numeric constants in binary, octal, decimal, or hexadecimal base,
depending on the data type of the item. The default number base in pTAL is decimal.
The following are example constants in each number base:
Number Base Example
Decimal 47
Binary %B101111
Octal %57
Hexadecimal %H2F
Statements
A statement specifies operations to be performed on declared objects. Statements are
discussed in Section 12, Statements, and summarized in Table 12-1 on page 12-1.
Topics:
• Data Types on page 3-1
• Address Types on page 3-5
• Constants on page 3-12
Data Types
When you declare a variable, you specify its data type, which determines:
• Its storage unit
• The values that you can assign to it
• The operations that you can perform on it
• Its address type
Topics:
• Specifying Data Types on page 3-3
• Data Type Aliases on page 3-4
• Operations by Data Type on page 3-4
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
*
VST214.vsd
width
is a constant expression that specifies the width, in bits, of the variable. The value
of width must be appropriate for the data type (see Example 3-1 on page 3-4):
Data Type Value of width
INT (16)* 16
INT (32) 32
INT (64)* 64
REAL(32)* 32
REAL(64) 64
UNSIGNED(n ) In the range 1 through 31
* Data type alias (see Data Type Aliases on page 3-4)
fpoint
is the implied fixed-point (decimal-point) setting. fpoint is an integer in the range
-19 through 19. The default fpoint is 0 (no decimal places).
A positive fpoint specifies the number of places to the right of the decimal point:
FIXED(3) x := 0.642F; ! Stored as 642
A negative fpoint specifies a number of places to the left of the decimal point.
When the value is stored, it is truncated leftward from the decimal point by the
specified number of digits. When the value is accessed, zeros replace the
truncated digits:
FIXED(-3) y := 642945F; ! Stored as 642; accessed as 642000
*(asterisk)
prevents scaling of the initialization values (for an explanation of scaling, see
Scaling of FIXED Operands on page 5-7).
The data type of a variable also determines which built-in routines you can use with the
variable (see Section 15, Built-In Routines).
Address Types
Every identifier that you declare has both a data type and an address type. The data
type describes the data item itself. The address type describes the address of the data
item. If you declare a pointer to the data item, the value that you assign to the pointer
must be of that address type.
You cannot explicitly declare the address type of a pointer. When you declare a pointer,
the compiler determines its address type.
You can compare addresses using the relational operators described in Table 2-5 on
page 2-5.
Topics:
• Storing Addresses in Variables on page 3-7
• Converting Between Address Types and Numeric Data Types on page 3-7
• Converting Between Address Types on page 3-7
• Using Indexes to Access Array Elements on page 3-9
• Incrementing and Decrementing Addresses (Stepping Pointers) on page 3-10
• Computing the Number of Bytes Between Addresses on page 3-11
• Comparing Addresses to Addresses on page 3-11
• Comparing Addresses to Constants on page 3-11
• Comparing PROCADDRs and PROCPTRs on page 3-11
• Testing a Pointer for a Nonzero Value on page 3-12
The compiler generates code for implicit conversions for the following operations:
• Block moves and compares
The compiler automatically converts an address type if required for the source or
destination pointer in a block move or block compare instruction.
• Call-by-reference actual parameters
The compiler automatically converts the address type of an actual parameter to the
address type of a formal parameter if the conversion could not cause data loss. For
example:
You can subtract an integer value from any address type except PROCADDR. The
address must be on the left side of the subtraction operator and the integer must be on
the right.
You must use signed operators for operations on EXTADDRs and unsigned operators
for all other address types.
If you increment or decrement a pointer, the number that you add to, or subtract from,
a byte address (such as BADDR) is the number of bytes to move the pointer. Similarly,
the number that you add to a word address (such as WADDR) is the number of 16-bit
words to move the pointer, not the number of 32-bit words.
If you step a byte address (such as BADDR), the number you specify is added to, or
subtracted from, the address in the pointer.
If you step a word address (such as WADDR), the address is incremented
decremented by twice the number you specify, because addresses on TNS/R and
TNS/E architecture are represented as byte addresses.
Constants
• Character String on page 3-12
• STRING Numeric on page 3-14
• INT Numeric on page 3-15
• INT(32) Numeric on page 3-16
• FIXED Numeric on page 3-17
• REAL and REAL(64) Numeric on page 3-19
• Constant Lists on page 3-21
• Constant List Alignment Specification on page 3-22
Character String
A character string constant consists of one or more ASCII characters stored in a
contiguous group of bytes.
VST001.vsd
string
is a sequence of one or more ASCII characters enclosed in quotation mark
delimiters. If a quotation mark is a character within the sequence of ASCII
characters, use two quotation marks (in addition to the quotation mark delimiters).
The compiler does not upshift lowercase characters.
Each character in a character string requires one byte of contiguous storage. The
maximum length of a character string you can specify differs for initializations and for
assignments.
Initializations
You can initialize simple variables or arrays of any data type with character strings.
When you initialize a simple variable, the character string can have the same number
of bytes as the simple variable or fewer. This example declares an INT variable and
initializes it with a character string:
INT chars := "AB";
When you initialize an array, the character string can have up to 127 characters and
must fit on one line. If a character string is too long for one line, use a constant list
(described Constant Lists on page 3-21) to break the character string into smaller
character strings.
Assignments
You can assign character strings to STRING, INT, and INT(32) variables, but not to
FIXED, REAL, or REAL(64) variables.
In assignment statements, a character string can contain at most four characters,
depending on the data type of the variable:
Number of Bytes in String Data Types to Which String Can Be Assigned
1 STRING, INT
2 STRING, INT
3 INT(32)
4 INT(32)
STRING Numeric
Representation Unsigned 8-bit integer
Range 0 through 255
integer
base
VST002.vsd
base
indicates a number base as follows:
Octal %
Binary %b
Hexadecimal %h
integer
is one or more of the following digits:
Decimal 0 through 9
Octal 0 through 7
Binary 0 or 1
Hexadecimal 0 through 9, A through F (not case-sensitive)
INT Numeric
Representation Signed or unsigned 16-bit integer
Range (unsigned) 0 through 65,535
Range (signed) -32,768 through 32,767
integer
+ base
VST027.vsd
base
indicates a number base as follows:
Octal %
Binary %b
Hexadecimal %h
integer
is one or more of the following digits:
Decimal 0 through 9
Octal 0 through 7
Binary 0 or 1
Hexadecimal 0 through 9, A through F (not case-sensitive)
The system stores signed integers in two’s complement notation. It obtains the
negative of a number by inverting each bit position in the number, and then adding 1.
2 is stored as 0000000000000010
-2 is stored as 1111111111111110
INT(32) Numeric
Representation Signed or unsigned 32-bit integer
Range -2,147,483,648 through 4,294,967,295
ns
integer D
ns
+ base %D
VST028.vsd
base
indicates a number base as follows:
Octal %
Binary %b
Hexadecimal %h
integer
is one or more of the following digits:
Decimal 0 through 9
Octal 0 through 7
Binary 0 or 1
Hexadecimal 0 through 9, A through F (not case-sensitive)
D
%D
are suffixes that specify INT(32) constants:
Decimal D
Octal D
Binary D
Hexadecimal %D
For readability, always specify the % in the %D hexadecimal suffix to prevent the suffix
from being confused with the integer part of the constant. The following format, where
a space replaces the % in the %D suffix, is allowed but not recommended:
-%H99FF29 D
The system stores signed integers in two’s complement notation (see INT Numeric on
page 3-15).
FIXED Numeric
Representation Signed 64-bit fixed-point number
Range -9,223,372,036,854,775,808 through +9,223,372,036,854,775,807
integer
+ base
-
F
. fraction %F
VST005.vsd
base
indicates a number base as follows:
Octal %
Binary %B
Hexadecimal %H
integer
is one or more of the following digits:
Decimal 0 through 9
Octal 0 through 7
Binary 0 or 1
Hexadecimal 0 through 9, A through F
fraction
is one or more decimal digits. fraction is legal only for decimal base.
F
%F
are suffixes that specify FIXED constants:
Decimal F
Octal F
Binary F
Hexadecimal %F
For readability, always specify the % in the %F hexadecimal suffix to prevent the suffix
from being confused with the integer part of the constant. The following format, where
a space replaces the % in the %F suffix, is allowed but not recommended:
-%H99FF29 F
The system stores a FIXED number in binary notation. When the system stores a
FIXED number, it scales the constant as dictated by the declaration or expression.
Scaling means the system multiplies or divides the constant by powers of 10 to move
the decimal.
For information about scaling of FIXED values in expressions, see Section 5,
Expressions. For information about scaling of FIXED values in declarations, see
Section 7, Simple Variables.
integer . fraction
+
-
E exponent
L +
-
VST006.vsd
integer
is one or more decimal digits that compose the integer part.
fraction
is one or more decimal digits that compose the fractional part.
E
specifies the floating-point constant REAL.
L
specifies the floating-point constant REAL(64).
exponent
is one or two decimal digits that compose the exponential part.
Examples of REAL and REAL(64) numeric constants, showing the integer part, the
fractional part, the E or L suffix, and the exponent part:
Decimal Value REAL REAL(64)
0 0.0E0 0.0L0
2 2.0e0 2.0L0
0.2E1 0.2L1
20.0E-1 20.0L-1
-17.2 -17.2E0 -17.2L0
-1720.0E-2 -1720.0L-2
The system stores the number in binary scientific notation in the form:
x * 2y
x is a value of at least 1 but less than 2. Because the integer part of x is always 1, only
the fractional part of x is stored.
The exponent can be in the range -256 through 255 (%377). The system adds 256
(%400) to the exponent before storing it as y. Thus, the value stored as y is in the
range 0 through 511 (%777), and the exponent is y minus 256.
If the value of the number to be represented is zero, the sign is 0, the fraction is 0, and
the exponent is 0.
The system stores the parts of a floating-point constant as follows:
Data Type Sign Bit Fraction Exponent
REAL <0> <1:22> <23:31>
REAL(64) <0> <1:54> <55:63>
Constant Lists
A constant list is a list of one or more constants. You can use constant lists in:
• initializations of array declarations that are not contained in structures
• group comparison expressions
• move statements
repetition-constant-list
[ repetition-constant-list ]
FIELDALIGN-clause constant-list-seq
VST621.vsd
repetition-constant-list
[ constant-list-seq ]
repetition-factor *
VST008.vsd
repetition-factor
is an INT constant that specifies the number of times constant-list-seq
occurs.
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, as described for each data type on preceding pages.
FIELDALIGN-clause
FIELDALIGN ( SHARED2 )
SHARED8
VST065.vsd
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. For more information about constant list alignment, see Constant List
Alignment Specification on page 3-22.
SHARED2
specifies that the base of the structure and each field in the structure must
begin at an even byte address except STRING fields, which can begin at any
byte address, and UNSIGNED fields.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must be begin at an address that is an integral multiple of the width of
the field.
INT(32) c[0:4];
["abcd", 1D, 3D, "XYZ", "a" "b"
%20D]; c[0]
!Mixed constant list "c" "d"
c[1] 1D
c[2] 3D
"X" "Y"
c[3]
"Z" 0
c[4] %20D
VST331.vsd
Topics:
• Misalignment Tracing Facility on page 4-1
• Misalignment Handling on page 4-3
When a misaligned address causes an exception that RVUs prior to G06.17 would
have rounded down, the tracing facility traces the exception.
Note. The tracing facility does not count and trace every misaligned address, only those that
cause round-down exceptions. Other accesses that use misaligned addresses without
rounding them down do not cause exceptions and are not counted or traced. Also, only a
periodic sample of the counted exceptions are traced by means of their own EMS event
messages.
Misalignment Handling
Misalignment handling is determined by the following SCF attributes, which are set
system-wide (that is, for all processors in the node) by the persons who configure the
system:
• MISALIGNLOG
• TNSMISALIGN (applies only to programs running in TNS mode or TNS
accelerated mode, and therefore, does not apply to pTAL programs)
• NATIVEATOMICMISALIGN
MISALIGNLOG enables or disables the tracing facility (see Misalignment Tracing
Facility on page 4-1).
NATIVEATOMICMISALIGN applies to atomic routines in programs running in TNS/R
native mode; that is, the pTAL and TAL routines whose names begin with “$ATOMIC_”
For normal, nonatomic access in TNS/R native mode, the system uses the operand’s
full address (never rounded down) to complete the operation.
For normal, nonatomic access in TNS/R native mode, the system uses the operand’s
full address (never rounded down) to complete the operation.
Table 4-1 on page 4-3 lists and describes the possible settings for
NATIVEATOMICMISALIGN. Each setting represents a different misalignment handling
method. For more information about NATIVEATOMICMISALIGN, see the SCF
Reference Manual for the Kernel Subsystem.
The method that you choose does not apply to every misaligned address, only to those
that would have been rounded down in earlier RVUs.
Topics:
• Data Types of Expressions on page 5-2
• Operator Precedence on page 5-3
• Arithmetic Expressions on page 5-5
• Signed Arithmetic Operators on page 5-6
• Unsigned Arithmetic Operators on page 5-8
• Comparing Addresses on page 5-11
• Constant Expressions on page 5-14
• Conditional Expressions on page 5-15
• Special Expressions on page 5-20
• Bit Operations on page 5-31
° Puts a STRING operand in the right byte of a 16-bit word and sets the left byte
to 0, with no sign extension.
° Puts an UNSIGNED(1-16) operand in the right bits of a 16-bit word and sets
the unused left bits to 0, with no sign extension. For example, for an
UNSIGNED(2) operand, the system fills the 14 leftmost bits of the word with
zeros.
• An INT(32) expression can include INT(32) and UNSIGNED(17-31) operands. The
system treats UNSIGNED(17-31) operands as if they were 32-bit values. The
system places an UNSIGNED(17-31) operand in the right bits of a doubleword and
sets the unused left bits to 0, with no sign extension. For example, for an
UNSIGNED(29) operand, the system fills the three leftmost bits of the doubleword
with zeros.
In all other cases, if the data types do not match, use the type transfer functions
described in Section 15, Built-In Routines.
Operator Precedence
Operators in expressions can be arithmetic (signed, unsigned, or logical) or conditional
(relational, signed or unsigned). Within an expression, the compiler evaluates the
operators in the order of precedence. Within each level of precedence, the compiler
evaluates the operators from left to right.
You can use parentheses to override the precedence of operators. You can nest the
parenthesized operations. The compiler evaluates nested parenthesized operations
outward starting with the innermost level.
c * (a + b) c * ( (a + b) / d) (a OR b) AND c
Result Result
Result
VST003.vsd
Arithmetic Expressions
An arithmetic expression is a sequence of operands and arithmetic operators that
computes a single numeric value of a specific data type.
operand
+ arithmetic-operator operand
-
VST010.vsd
+
-
are unary plus and minus operators. The default is unary plus.
operand
is one of the elements in Table 5-2 on page 5-5.
arithmetic-operator
is one of the following:
Signed arithmetic operator +, -, *, /
Unsigned arithmetic operator '+', '-', '*', '/', '\'
Logical operator LOR, LAND, XOR
A condition code cannot appear inside an arithmetic expression; for example, the
following is not valid in pTAL:
a := <; !Illegal
In Table 5-5 on page 5-6, the order of the data types is interchangeable.
To retain precision when you divide operands that have nonzero fixed-points, use the
routine $SCALE on page 15-82.
In Table 5-7 on page 5-9, the order of the operand types in each combination is
interchangeable except in the last case.
Topics:
• Bitwise Logical Operators on page 5-10
• Using Bitwise Logical Operators and INT(32) Operands on page 5-10
The Bit Operations column in Table 5-8 on page 5-10 shows the bit-by-bit operations
that occur on 16-bit values. Each 1-bit operand pair results in a 1-bit result. The bit
operands are commutative.
Comparing Addresses
pTAL rules for comparing address types are more restrictive than the rules for
comparing nonaddress types.
Topics:
• Extended Addresses on page 5-12
• Nonextended Addresses on page 5-12
Extended Addresses
The following rules apply when you compare extended addresses (EXTADDRs):
• Use signed relational operators to compare extended addresses. Unsigned
operators are not valid.
• If you compare an extended address to a constant, the constant must be a 32-bit
integer.
Nonextended Addresses
The following rules apply when you compare nonextended addresses:
• Use unsigned relational operators ( '<', '=', '>', '<=', '<>', '>='), a signed equality
operator (=), or a signed inequality operator (<>) to compare nonextended
addresses. The signed and unsigned equality operators produce the same results.
Similarly, the signed and unsigned inequality operators produce the same results.
• Do not compare nonextended addresses using signed operators that test for
greater than or less than (<, <=, >, >=).
Valid comparisons:
INT .p, .q;
IF @p = 0 THEN ...
IF @p <> 0 THEN ...
IF @p = @q THEN ...
Both operands must have the same address type:
STRING .s;
BADDR .b;
IF @s = b THEN ... ! OK: @s is BADDR, b is BADDR
IF @s = @b THEN ... ! ERROR: @s is BADDR, @b is WADDR
Constant Expressions
A constant expression is an arithmetic expression that contains only constants,
LITERALs, or DEFINEs as operands.
You can use a constant expression anywhere a single constant is allowed.
Conditional Expressions
A conditional expression is a sequence of conditions and relational operators that
establishes the relationship between values. You can use conditional expressions to
direct program flow.
condition
NOT AND
OR
VST996.vsd
NOT
is an operator that produces a true state if condition has the value false:
Value of a Value of NOT a
True False
False True
condition
is an expression whose value is either true or false.
AND
is an operator that produces a true state if both its operands have the value true:
Value of a Value of b Value of a AND b
True True True
True False False
False True False
False False False
OR
is an operator that produces a true state if at least one of its operands has the
value true:
Value of a Value of b Value of a AND b
True True True
True False True
False True True
False False False
Topics:
• NOT, OR, and AND Operators on page 5-17
• Relational Operators on page 5-18
Topics:
• Evaluating NOT, OR, and AND Operations on page 5-17
• NOT, OR, and AND Operators and Condition Codes on page 5-18
Relational Operators
• Signed Relational Operators on page 5-18
• Unsigned Relational Operators on page 5-19
A condition code reflects the value of the most recently evaluated root operator.
Used with no operands, signed and unsigned operators are equivalent. The result
returned by such a relational operator is:
Relational
Operator Result Returned
< or '<' True if CCL
> or '>' True if CCG
= or '=' True if CCE
<> or '<>' True if not CCE
<= or '<=' True if CCL or CCE
>= or '>=' True if CCE or CCG
Special Expressions
Special expressions allow you to perform specialized arithmetic or conditional
operations.
Assignment
The assignment expression assigns the value of an expression to a variable.
variable := expression
VST012.vsd
variable
is the identifier of a variable in which to store the result of expression
(variable can have an optional bit-deposit field).
expression
is an expression of the same data type as variable. The result of expression
becomes the result of the assignment expression. expression is either:
• An arithmetic expression
• A conditional expression (excluding a relational operator with no operands), the
result of which has data type INT.
Examples of assignment expressions:
1. This example decrements a. As long as a- 1 is not 0, the condition is true and the
THEN clause is executed:
IF (a := a - 1) THEN ... ;
2. This example shows the assignment form used as an index. It decrements a and
accesses the next array element:
IF array[a := a - 1] <> 0 THEN ... ;
3. This example mixes the assignment form with a relational form. It assigns the
value of b to a, then checks for equality with 0:
IF (a := b) = 0 THEN ... ;
CASE
The CASE expression selects one of several expressions.
END
OTHERWISE expression-2 ;
VST013.vsd
selector
is an arithmetic expression [INT or INT(32)] that selects the expression to evaluate.
expression-1
is an expression of any data type. If you specify more than one expression-1,
their data types must be compatible.
expression-2
is an expression whose data type is compatible with the data type of
expression-1. It is evaluated if selector does not select an expression-1.
If you omit the OTHERWISE clause and an out-of-range case occurs, results are
unpredictable.
All expressions in the CASE statement must have compatible data types:
• Every data type is compatible with itself.
• String and unsigned (1-16) data types are compatible with INT
• Unsigned (17-32) data types are compatible with INT(32)
• All fixed-point data types are compatible with each other; however, if
expression-1 and expression-2 are differently scaled fixed-point
expressions, the data type of the IF expression is the data type of the fixed-point
expression whose scale factor is largest. The smaller operand is implicitly scaled to
match the type of the IF expression. For example, these return statements are
equivalent:
int i; int i;
fixed(2) f2; fixed(2) f2;
fixed(3) f3; fixed(3) f3;
fixed(3) proc p; fixed(3) proc p;
begin begin
return if i then f2 return if i then $scale(f2,1);
else f3; else f3;
end end
The compiler numbers the instances of expression-1 consecutively, starting with 0.
If selector matches the compiler-assigned number of an expression-1, that
expression-1 is evaluated and becomes the result of the CASE expression. If
selector does not match a compiler-assigned number, expression-2 is
evaluated.
You can nest CASE expressions. CASE expressions resemble unlabeled CASE
statements except that CASE expressions select expressions rather than statements.
Example 5-4 on page 5-22 selects an expression based on the value of a and assigns
it to x:
IF
The IF expression selects one of two expressions, usually for assignment to a variable.
VST014.vsd
condition
is either:
• A conditional expression
• An INT arithmetic expression. If the result of the arithmetic expression is not 0,
the condition is true. If the result is 0, condition is false.
expression-1
expression-2
are expressions of any data type, but their data types must be compatible:
• Every data type is compatible with itself.
• String and unsigned (1-16) data types are compatible with INT
• Unsigned (17-32) data types are compatible with INT(32)
• All fixed-point data types are compatible with each other; however, if
expression-1 and expression-2 are differently scaled fixed-point
expressions, the data type of the CASE expression is the data type of the
fixed-point expression whose scale factor is largest. For example, these return
statements are equivalent:
int i; int i;
fixed(-2) f2; fixed(-2) f2;
fixed(-3) f3; fixed(-3) f3;
fixed(-4) f4; fixed(-4) f4;
fixed(-2) proc p; fixed(-2) proc p;
begin begin
return case i of return case i of
begin begin
f3; $scale(f3,1);
f2; f2;
otherwise f4 otherwise $scale(f4,2)
end end
end end
If condition is true, the result of the expression-1 becomes the result of the
overall IF expression.
If condition is false, the result of expression-2 becomes the result of the overall
IF expression.
HP pTAL Reference Manual—523746-006
5- 23
Expressions Group Comparison
You can nest IF expressions within an IF expression or within other expressions. The
IF expression resembles the IF on page 12-26 except that the IF expression:
• Requires the ELSE clause
• Contains expressions, not statements
Examples of IF expressions:
1. This example assigns an arithmetic expression to var based on the condition
length > 0:
var := IF length > 0 THEN 10 ELSE 20;
2. This example nests an IF expression (in parentheses) within another expression:
var * index + (IF index > limit THEN var * 2 ELSE var * 3)
3. This example nests an IF expression within another IF expression:
var := IF length < 0 THEN -1
ELSE IF length = 0 THEN 0
ELSE 1;
Group Comparison
The group comparison expression compares a variable with a variable or constant.
With PVU T9248AAD, you can compare any variable up to the current maximum
allowed size for any object of 127.5 megabytes.
var-1 relational-operator
constant-list
-> next-addr
VST015.vsd
var-1
is the identifier of a variable, with or without an index, that you want to compare to
var-2, constant, or constant-list. var-1 can be a simple variable, array,
simple pointer, structure, structure data item, or structure pointer, but not a read-
only array.
HP pTAL Reference Manual—523746-006
5- 24
Expressions Group Comparison
relational-operator
is one of the following operators:
Signed relational operator <, =, >, <=, >=, <>
Unsigned relational operator '<', '=', '>', '<=', '>=', '<>'
All comparisons are unsigned whether you use a signed or unsigned operator.
var-2
is the identifier of a variable, with or without an index, to which var-1 is
compared. var-2 can be a simple variable, array, read-only array, simple pointer,
structure, structure item, or structure pointer.
count
is a unsigned INT arithmetic expression that defines the number of units in var-2
to compare. When count-unit is not present, the units compared are:
var-2 Data Type Units Compared
Simple variable, array, simple pointer STRING Bytes
(including those declared in structures) INT Words
INT(32) or REAL Doublewords
FIXED or REAL(64) Quadruplewords
Structure Not applicable Words
Substructure Not applicable Bytes
Structure pointer STRING Bytes
INT Words
count-unit
is BYTES, WORDS, or ELEMENTS. count-unit changes the meaning of
count to the following:
BYTES Compares count bytes; however, if var-1 and var-2 both
have word addresses, BYTES implicitly generates a word
comparison for (count +1)/2 words.
WORDS Compares count words.
ELEMENTS Compares count elements. The elements compared depend on
the nature of var-2 and its data type as follows:
var-2 Data Type Units Compared
Simple variable, array, STRING Bytes
simple pointer (including INT Words
those declared in INT(32) or REAL Doublewords
structures) FIXED or REAL(64) Quadruplewords
Structure Not applicable Structure
(For structure pointers, occurrences
STRING and INT have
meaning only in group
comparison expressions
and move statements.)
Substructure Not applicable Substructure
occurrences
Simple variable, array, STRING Bytes
simple pointer (including INT Words
those declared in INT(32) or REAL Doublewords
structures) FIXED or REAL(64) Quadruplewords
constant
is a number, a character string, or a LITERAL to which var-1 is compared.
If you enclose a simple numeric constant in brackets ([ ]) and if the destination has
a byte address or is a STRING structure pointer, the system compares a single
byte regardless of the size of constant. If you do not enclose constant in
brackets or if the destination has a word address or is an INT structure pointer, the
system compares a word, doubleword, or quadrupleword as appropriate for the
size of constant.
constant-list
is a list of one or more constants, which are concatenated and compared to
var-1. Specify constant-list in the form shown in Section 3, Data
Representation.
next-addr
is a variable to contain the address of the first byte or word in var-1 that does not
match the corresponding byte or word in var-2. The compiler returns a 16-bit or
32-bit address as described in the following subsection.
pTAL programs access all data using byte addresses. pTAL uses the low-order bit of
addresses; therefore, when you use an odd-byte address to access a 16-bit word that
you have declared with .EXT, you access the data beginning at the odd-byte address.
You can use group comparisons for:
• Changing the Data Type of the Data on page 5-27
• Testing Group Comparisons on page 5-29
X Y
VST131.vsd
Figure 5-3 on page 28 is the same as Figure 5-2 on page 5-27 except that in
Figure 5-3 on page 5-28, y is a 2-byte STRING array. The IF statement, therefore,
compares x to y on a byte-by-byte basis. Because the first (upper) bytes of x and y
are equal, the comparison continues to the second byte.
Because the second byte of x is “B”, but the second byte of y is “C”, the conditional
expression is false. In Figure 5-3 on page 5-28, therefore, the IF statement stores in p
the address of the second (lower) byte of x.
Figure 5-3. 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; ! Assign "BC" to q
END;
X Y
VST132.vsd
After an element comparison, next-addr might point into the middle of an element,
rather than to the beginning of the element, because next-addr always refers to the
first byte or 16-bit word (as appropriate) that differs.
Example 5-5 on page 5-30 compares two arrays and then tests the condition code
setting to see if the value of the element in d_array that stopped the comparison is
less than the value of the corresponding element in s_array.
When you compare array elements (as in Example 5-5 on page 5-30), the ELEMENTS
keyword is optional but provides clearer source code.
To compare structure or substructure occurrences, you must specify the ELEMENTS
keyword in the group comparison expression, as in Example 5-6 on page 5-30.
Bit Operations
You can access individual bits or groups of bits in a STRING or INT variable.
Topics:
• Bit Extractions on page 5-31
• Bit Shifts on page 5-33
Bit Extractions
int-expression
VST016.vsd
int-expression
is an INT(32) expression.
left-bit
is an INT constant in the range 0 through 15 that specifies the bit number of either:
• The leftmost bit of the bit-extraction field
• The only bit (if right-bit is the same value as left-bit or is omitted)
If int-expression is a STRING value, left-bit must be in the range 8
through 15. (In a string value, bit 8 is the leftmost bit and bit 15 is the rightmost bit.)
right-bit
is an INT constant that specifies the rightmost bit of the bit field. If int-
expression is a STRING value, right-bit must be in the range 8 through 15.
right-bit must be equal to or greater than left-bit. To access a single bit,
omit right-bit or specify the same value as left-bit.
You can perform bit extractions and deposits on 16-bit and 32-bit items. pTAL reports
an error, however, if you attempt to reference bits outside of the bits declared in the
variable’s declaration.
Example 5-10 on page 5-32 assigns bits 4 through 7 of the sum of two numbers to
RESULT. The parentheses cause the numbers to be added before the bits are
extracted.
Bit Shifts
A bit shift operation shifts a bit field a specified number of positions to the left or to the
right within a variable without altering the variable. RISC and Itanium architectures do
not include a signed left-shift operation, so pTAL compiles a signed left shift (for
example, i << 8) as an unsigned left shift (i '<<' 8).
dbl-expression
VST017.vsd
int-expression
is an INT arithmetic expression. int-expression can contain STRING, INT, or
UNSIGNED(1-16) operands. The bit shift occurs within a word.
dbl-expression
is an INT(32) arithmetic expression. dbl-expression can contain INT(32) or
UNSIGNED(17-31) operands. The bit shift occurs within a doubleword.
shift-operator
is one of the operators described in Table 5-1 on page 5-3.
positions
is an INT expression that specifies the number of bit positions to shift the bit field.
A value greater than 31 gives undefined results.
The shift count must be less than the number of bits in the shifted value; therefore, you
can shift an INT value up to 15 bits left or right, and an INT(32) value up to 31 bits left
or right.
The compiler reports an error if the shift count is a constant and its value is greater
than the number of bits in the value to shift.
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.
• If CHECKSHIFTCOUNT is disabled (you specify NOCHECKSHIFTCOUNT), and a
dynamic shift count is equal to or greater than the number of bits in the value being
shifted, program operation is undefined.
The compiler implements arithmetic left shifts as unsigned left shifts (and warns you
when it does this).
Most programs do not need to perform signed left shifts. If your program does require
an arithmetic left shift, use the functions in Example 5-12 on page 5-34 to perform
signed left-shift operations.
Declaring Literals
A LITERAL declaration specifies one or more identifiers and associates each with a
constant value. Each identifier in a LITERAL declaration is known as a LITERAL.
LITERAL identifier
= constant
VST018.vsd
identifier
is the LITERAL identifier. Literal identifiers make the source code more readable.
For example, identifiers such as BUFFER_LENGTH and TABLE_SIZE are more
meaningful than their respective constant values of 80 and 128.
constant
is one of the following:
• A character string of 1 to 4 characters.
• Any of the following numeric constant expressions whose value is not the
address of a global variable (global variables are relocatable during linking):
° FIXED(n)
° INT
° INT(32)
° REAL
° REAL(64)
° UNSIGNED(n)
If you omit any constants, the compiler supplies the omitted numeric constants. The
compiler uses unsigned arithmetic to compute the constants it supplies:
• If you omit the first constant in the declaration, the compiler supplies a zero.
• If you omit a constant that follows an INT constant, the compiler supplies an INT
constant that is one greater than the preceding constant. If you omit a constant that
follows a constant of any data type except INT, an error message results.
You access a LITERAL constant by using its identifier in declarations and statements.
The compiler does not allocate storage for LITERAL constants. It substitutes the
constant at each occurrence of the identifier.
Declaring DEFINEs
A DEFINE declaration associates an identifier (and optional parameters) with text.
DEFINE item-list ;
VST019.vsd
item-list
identifier = define-body #
param-list
VST995.vsd
identifier
is the identifier of the DEFINE.
param-list
( param-name )
VST994.vsd
param-name
is the identifier of a formal parameter. You can specify up to 31 formal
parameters. An actual parameter can be up to 500 bytes. A formal
parameter cannot be a pTAL reserved word.
define-body
specifies all characters between the = and # delimiters. define-body can
span multiple source lines. Enclose character strings in quotation marks ("). To
use # as part of the define-body rather than as a delimiter, enclose the # in
quotation marks or embed the # in a character string.
DEFINE declaration requirements:
• If a DEFINE and a formal parameter have the same identifier, the formal parameter
has priority during expansion.
• A DEFINE must not reference itself.
• A DEFINE declaration must not appear within a DEFINE body; that is, do not nest
a DEFINE within a DEFINE.
• To ensure proper grouping and order of evaluation of expressions in the DEFINE
body, use parentheses around each DEFINE parameter used in an expression.
• Within the DEFINE body, place any compound statements within a BEGIN-END
block.
• Directives appearing within a DEFINE body are evaluated immediately; they are
not part of the DEFINE itself.
• Expanded DEFINEs must produce correct pTAL constructs. To list the expanded
DEFINEs in the compiler listing, specify the DEFEXPAND directive before the
DEFINE declarations.
When a STRUCT item and a DEFINE have the same name, the compiler issues a
warning when the STRUCT item is referenced. In Example 6-3 on page 6-5, DEFINE
myname accesses the structure item1 named in the DEFINE body. The compiler
issues a warning because 2 is assigned to mystruct.yrname, not to
mystruct.myname.
Example 6-3. STRUCT and DEFINE Macro Items With the Same Name
PROC myproc MAIN;
BEGIN
DEFINE myname = item1#,
yrname = item2#;
STRUCT mystruct;
BEGIN
INT item1;
INT item2;
INT yrname; ! Structure item has same
END; ! identifier as a DEFINE
mystruct.myname := 1; ! OK: 1 is assigned to mystruct.item1
mystruct.yrname := 2; ! Compiler issues warning;
! 2 is assigned to mystruct.yrname,
! not to mystruct.item2
! More code
END;
Calling DEFINEs
You call a DEFINE by using its identifier in a statement. The invocation can span
multiple lines.
If you call a DEFINE within an expression, make sure the expression evaluates as you
intend. For instance, if you want the DEFINE body to be evaluated before it becomes
part of the expression, enclose the DEFINE body in parentheses.
If a DEFINE has formal parameters and you pass no actual parameters to the DEFINE,
you must specify an empty actual parameter list. You can include commas between the
list delimiters, but need not, as in Example 6-6 on page 6-7.
Example 6-10 on page 6-8 shows a DEFINE declaration that has one formal parameter
and an assignment statement that uses the DEFINE identifier, passing a parameter
of 3.
Example 6-13 on page 6-9 displays a message, checks the condition code, and
assigns an error if one occurs.
type
VOLATILE
identifier ;
:= initialization
,
VST622.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is one of the following data types:
• BADDR
• CBADDR
• CWADDR
• EXTADDR
• INT
• INT(32)
• FIXED
• FIXED (fpoint )
• PROCADDR
• REAL
• REAL
• REAL(64)
• SGBADDR
• SGWADDR
• SGXBADDR
• SGXWADDR
• STRING
• UNSIGNED (width )
• WADDR
fpoint
For the FIXED data type, fpoint is the implied fixed-point setting. fpoint is
an integer in the range -19 through 19. If you omit fpoint, the default fpoint is
0 (no decimal places).
A positive fpoint specifies the number of decimals to the right of the decimal
point. A negative fpoint specifies a number of integers to the left of the
decimal point.
fpoint can also be an asterisk (*).
width
For INT, REAL, and UNSIGNED data types, the value in parentheses is a
constant expression specifying the width, in bits of the variable. The constant
expression can include LITERALs and DEFINEs. The result of the constant
expression must be one of the following values:
Data Type Prefix width in bits
INT 16, 32, or 64
REAL 32 or 64
UNSIGNED a value in the range 1 through 31
(simple variable, parameter, or function result)
UNSIGNED (array) 1, 2, 4, or 8
identifier
is the identifier of the simple variable, specified in the form described in Section 2,
Language Elements.
initialization
is an expression that represents the value to store in identifier. The default
number base is decimal. The kind of expression you can specify depends on the
scope of the simple variable:
• For a global simple variable, use a constant expression.
• For a local or sublocal simple variable, use any arithmetic expression including
variables.
You can initialize simple variables of any data type except UNSIGNED. For more
information about initializing a simple variable, see the following subsections.
Examples
• Example 7-1, Declaring Simple Variables Without Initializing Them, on page 7-5
• Example 7-2, Declaring and Initializing Simple Variables, on page 7-5
• Example 7-3, Effect of fpoint on FIXED Simple Variables, on page 7-5
• Example 7-4, Initializing Simple Variables With Constants and Variables*, on
page 7-6
• Example 7-5, Declaring Simple VOLATILE Variables, on page 7-6
• Example 7-6, PROCADDR and PROCPTR, on page 7-6
Declaring Arrays
An array declaration associates an identifier with a set of elements of the same data
type. The data type of an array can be one of the pTAL address types.
type identifier
range ;
. := initialization
.EXT
.SG
.SGX
VST021.vsd
type
is one of the following:
• BADDR
• CBADDR
• CWADDR
• EXTADDR
• FIXED (fpoint )
• INT
• INT(32)
• FIXED
• PROCADDR
• REAL
• REAL
• REAL(64)
• SGBADDR
• SGWADDR
• SGXBADDR
• SGXWADDR
• STRING
• UNSIGNED (width )
• WADDR
width
is a constant expression specifying the width, in bits, of the variable.
fpoint
is the implied fixed point of the FIXED variable.
identifier
is the array name.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767)
that specifies the index (relative to the zeroth element) of the first array
element you want allocated.
upper-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767)
that specifies the index (relative to the zeroth element) of the last array element
you want allocated.
For arrays declared outside of structures, upper-bound must be equal to or
larger than lower-bound.
Here are some examples of bounds:
STRING a_array [0:2];
INT b_array [0:19];
UNSIGNED(1) flags [0:15];
initialization
is a constant or a constant list of values to assign to the array elements, beginning
with the lower-bound element. (Constant lists are described in Section 3, Data
Representation.) If you specify fewer initialization values than the number of
elements, the values of uninitialized elements are undefined. You cannot initialize
extended indirect local arrays or UNSIGNED arrays.
Specify initialization values that are appropriate for the data type of the array. For
example, if the decimal setting of an initialization value differs from the fpoint of
a FIXED array, the system scales the initialization value to match the fpoint. If
the initialization value is scaled down, some precision is lost.
Examples:
• Example 8-1, Declaring Arrays With Various Bounds, on page 8-4
• Example 8-2, Declaring Arrays and Initializing Them With Constants, on page 8-4
• Example 8-3, Declaring Arrays and Initializing Them With Constant Lists, on
page 8-5
• Example 8-4, Initializing Arrays, on page 8-5
• Example 8-5, Array With Positive fpoint, on page 8-5
• Example 8-6, Array With Negative fpoint, on page 8-5
• Example 8-7, Read-Only Array Declaration With Indirection Symbol, on page 8-7
Example 8-3. Declaring Arrays and Initializing Them With Constant Lists
INT c_array[0:5] := [1,2,3,4,5,6]; ! Constant list
STRING buffer[0:102] := [ "A constant list can consist ",
"of several character string constants, ",
"one to a line, separated by commas." ];
INT(32) mixed[0:3] := ["abcd", 1D, %B0101011D, %20D]; ! Mixed constant list
LITERAL len = 80; ! Length of array
STRING buffer[0:len - 1] := len * [" "]; ! Repetition factor
FIXED f[0:35] := 3*[2*[1F,2F], 4*[3F,4F]]; ! Repetition factors
LITERAL cr = %15,
lf = %12;
STRING err_msg[0:9] := [cr, lf, "ERROR", cr, lf, 0]; ! Constant list
type identifier =
range
'p' := initialization ;
,
VST022.vsd
type
is any data type described in Declaring Arrays on page 8-2 except UNSIGNED.
The data type of a read-only array cannot be an address type.
identifier
is the identifier of the read-only array.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767)
that specifies the index (relative to the zeroth element) of the first array
element you want allocated. The default value is 0.
upper-bound
is an INT or INT(32) constant expression (in the range -32,768 through 32,767)
that specifies the index (relative to the zeroth element) of the last array element
you want allocated. The default value is the number of elements initialized
minus one.
'p'
specifies a read-only array.
initialization
is a constant list to assign to the array elements. You must initialize read-only
arrays when you declare them. (Constant lists are described in Section 3, Data
Representation.)
Specify initialization values that are appropriate for the data type of the array. For
example, if the decimal setting of an initialization value differs from the fpoint of
a FIXED array, the system scales the initialization value to match the fpoint. If
the initialization value is scaled down, some precision is lost.
The compiler reports a warning if a read-only array declaration specifies an indirection
symbol (see Table 2-7, Indirection Symbols, on page 2-7).
Read-Only Arrays
The number of bits in the initialization string must equal the number of bits in the read-
only array.
If the read-only-array declaration does not specify array bounds, the number of bits in
the initialization string must be an integral multiple of the number of bits in the array’s
base type.
Nonstring Arrays
You can specify an initialization string when you declare an array:
INT .a[0:3] := [0,1,2,3];
The length of the initialization string must be less than or equal to the length of the
array.
The TNS/E instructions setjmp() and longjmp() require data to be aligned on 16-
byte boundaries. To ensure that this data is aligned on 16-byte boundaries, you must
declare it in a template structure using STRUCTALIGN (MAXALIGN).
Topics:
• Structure Layout on page 9-3
• Overview of Field Alignment on page 9-5
• Field and Base Alignment on page 9-8
• Array Alignment in Structures on page 9-13
• Structure Alignment on page 9-15
• Substructure Alignment on page 9-16
• Alignment Considerations for Substructures on page 9-19
• FIELDALIGN Clause on page 9-20
• FIELDALIGN Compiler Directive on page 9-20
• SHARED2 Parameter on page 9-20
• SHARED8 Parameter on page 9-22
• Reference Alignment With Structure Pointers on page 9-27
• STRUCTALIGN (MAXALIGN) Attribute on page 9-32
Structure Layout
The structure layout (or body) is a BEGIN-END block that contains declarations of
structure items.
You can nest substructures within structures (that is, you can declare a substructure
within a substructure within a substructure, and so on) as deeply as the pTAL stack
allows (approximately 60 levels). The structure and each substructure has a BEGIN-
END level depending on the level of nesting.
The syntax for declaring each structure item is described after the syntax for declaring
structures. The following rules apply to all structure items:
• You can declare the same identifier in different structures and substructures, but
you cannot repeat an identifier at the same BEGIN-END level.
• You cannot initialize a structure item when you declare it. After you have declared
it, however, you can assign a value to it by using an assignment statement or move
statement.
• You can control how the compiler aligns a structure in memory and the fields of a
structure within a structure by using the FIELDALIGN clause or FIELDALIGN
compiler directive.
Definition structure and template structure declarations can optionally include a
FIELDALIGN clause. You cannot specify a FIELDALIGN clause on a referral
structure declaration.
• If you declare a structure pointer and assign the address of a structure to it or use
a reference parameter to address structure data you can specify a REFALIGNED
clause to ensure that the structure is well-aligned.
Topics:
• Overview of Structure Alignment on page 9-4
• Structures Aligned at Odd-Byte Boundaries on page 9-5
• Accessing data is somewhat slower if the data is not well-aligned and you
reference the data using a pointer that specifies REFALIGNED(2).
• Accessing data is significantly slower if the data is not well-aligned, but pTAL
generates code that functions as if the data is well-aligned. In this case, your
program traps to the millicode exception handler, which completes the data access
and returns to your program.
To comply with these guidelines, some structures require that you explicitly add filler to
ensure that:
• Each field begins at an address that is a multiple of its length.
• The total length of a structure is a multiple of the widest field in the structure.
If more than one program uses the same source file, you might want to include a
FIELDALIGN clause on every structure declaration in the source file. This ensures that
the field alignment of every structure is consistent across all programs that compile the
source file.
If you do not specify a FIELDALIGN clause, each structure will use the current setting
of the FIELDALIGN compiler directive, which might be different for different
compilations.
Topics:
• SHARED2 on page 9-6
• SHARED8 on page 9-6
• PLATFORM on page 9-7
• AUTO on page 9-7
• Differences Between PLATFORM and AUTO on page 9-8
SHARED2
FIELDALIGN(SHARED2) directs the compiler to allocate the structure’s fields. Specify
FIELDALIGN(SHARED2) when:
• Your process is limited by the available stack space in TAL programs.
• You want the structure to hold data (for example, interprocess messages, memory,
or files) that is shared by processes or applications running on a combination of
TAL-compiled processes and RISC and Itanium architectures.
For more information, see FIELDALIGN Clause on page 9-20 and SHARED2
Parameter on page 9-20.
SHARED8
FIELDALIGN(SHARED8) directs the compiler to allocate the structure’s fields for
optimal performance in pTAL. Specify FIELDALIGN(SHARED8) when:
• You want optimal performance in pTAL.
• The fields you reference in the structure are well-aligned.
• All processes that share the data can use SHARED8 alignment.
• You want the structure to hold data (for example, interprocess messages, memory,
or files) that is shared by processes or applications that are composed of both
pTAL and TAL code.
In TAL, access to SHARED8 components is as efficient as access to SHARED2
components, but SHARED8 components usually require more space than
SHARED2 components.
For more information, see FIELDALIGN Clause on page 9-20 and SHARED8
Parameter on page 9-22.
PLATFORM
FIELDALIGN(PLATFORM) directs the compiler to allocate the structure’s fields
according to a layout that is consistent across different programming languages
running on a given architecture. (PLATFORM field alignment is not consistent across
different architectures.) The data might be shared among modules written in different
programming languages, in one of these ways:
• Running within a single process
• Running in separate processes, all of which are either pTAL, TAL, or C/C++, but
not a combination of these
pTAL allocates the fields of a PLATFORM structure according to the rules used by the
native mode HP C compiler for PLATFORM layouts; that is:
• Each field begins at an address that is an integral multiple of the length of the field.
That is, pTAL allocates 1-byte, 2-byte, 4-byte, and 8-byte fields at addresses that
are integral multiples of one, two, four, and eight, respectively.
• UNSIGNED fields are not necessarily aligned to byte boundaries. They can share
1-byte, 2-byte, and 4-byte containers with other items. An UNSIGNED field,
however, cannot span an address that is an integral multiple of four. If an
UNSIGNED item would span a 4-byte address boundary, the compiler allocates the
UNSIGNED field beginning at the next 4-byte boundary.
• The alignment of a structure or substructure is the alignment of its widest field,
unless the structure or substructure contains an UNSIGNED field, in which case,
the alignment of the structure or substructure is at least four.
• The compiler adds bytes, as needed, to the end of a PLATFORM structure or
substructure such that the length of the structure or substructure is an integral
multiple of its widest field.
AUTO
FIELDALIGN(AUTO) directs the compiler to align structure fields for optimal access on
the architecture on which the object file will be run. Specify AUTO only for structures
whose data exists solely within a process. Use PLATFORM to share data across
processes.
Use AUTO field alignment for a structure that you use only locally—that is, only within
a process—not between processes that run on different architectures. (AUTO field
alignment is not consistent across different architectures and compilers.)
A structure’s layout can be different in pTAL, TAL, and C/C++ if the structure describes
data that is used only within a process and only for the duration of the process. In this
case, you can specify AUTO as the FIELDALIGN parameter.
Specify FIELDALIGN(AUTO) for structures that are not used to exchange data
between processes.
Do not assume that fields of an AUTO structure are contiguous in memory. The
compilers insert filler where required for optimal alignment.
Pointer fields and nonpointer fields in structures declared with AUTO field alignment
can be any address type or data type, respectively.
TAL, pTAL, and C lay out AUTO structures differently.
Base Alignment
The base alignment of a structure is the alignment of the widest field in the structure.
The base alignment determines where the structure can be located in memory and be
well-aligned. A structure is well-aligned when the memory address at which it is located
is an integral multiple of its base alignment.
VST007.vsd
Figure 9-2 on page 9-11 shows which fields of s1 are misaligned if the base of the
structure in memory is not at an integral multiple of its base alignment. Only structures
whose base is at an even-byte address are shown. Accessing structures whose base
is at an odd-byte offset produces undefined results. For more information, see
Overview of Structure Alignment on page 9-4.
VST009.vsd
VST997.vsd
Figure 9-4 on page 9-13 shows which fields are misaligned if s2 is allocated at an
address other than a 4-byte address.
VST114.vsd
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. For alignment values of structure fields, see Table 9-3
on page 9-9. The alignment of a field that is a substructure is the alignment of the
widest field contained in the substructure.
If the alignment of the widest field in a SHARED8 structure is 2, the structure must
begin at a 2-byte address, and the structure’s base alignment is 2. If the alignment of
the widest field in the structure is four bytes, for example an INT(32), the structure
must begin at a 4-byte address. If the alignment of the widest field in the structure is
eight bytes, for example an FIXED field, the structure must begin at an 8-byte address.
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.”
For SHARED8 structures, you must ensure that every field begins at an appropriate
address and that the end of the structure includes filler, if necessary, so that the total
length of the substructure is an integral multiple of its widest field.
The following rules apply to substructures:
• A definition substructure that does not specify a FIELDALIGN clause inherits the
field alignment of its containing structure or substructure.
• The base alignment of a substructure is the alignment of the widest field of the
substructure.
• Begin the base of a substructure at an offset that is an integral multiple of the
substructure’s alignment, relative to the start of its containing structure or
substructure. If the substructure is a definition substructure and both the structure
and substructure have SHARED8 field alignment, the substructure must be well
aligned.
When you design routines that return addresses to their callers, return addresses that
are well-aligned whenever possible.
The compiler always generates conservative code. In Example 9-9 on page 9-18,
references to s3.s4.j do not cause traps because, although s3 is SHARED8, the
offset of s3.s4.j is not a multiple of 4. For each reference pTAL determines whether
the referenced field is well-aligned. References to fields in s4 using the pointer p4—for
example, p4.j—do not cause traps because the field alignment of s4 is SHARED2
and the compiler generates conservative code for such references.
The compiler pads SHARED2 structures and substructures with an extra byte if the
end of the last field in the structure or substructure ends at an odd-byte address,
unless the structure has 1-byte alignment—that is, all fields in the structure or
substructure are STRINGs or UNSIGNED(1-8).
STRING fields in structures can begin at any byte offset.
FIELDALIGN Clause
You use a FIELDALIGN clause in a structure declaration to specify how you want pTAL
to align the fields in the structure. Fields can be aligned for:
Access FIELDALIGN Clause
Exclusive, optimized for best resource utilization on each FIELDALIGN(AUTO)
architecture
Shared between pTAL and TAL programs FIELDALIGN(SHARED2)
Shared by program modules written in different programming FIELDALIGN(PLATFORM)
languages and running on the same architecture
Shared between TNS, TNS/R, and TNS/E architecture with FIELDALIGN(SHARED8)
optimal performance on TNS/R and TNS/E architecture
SHARED2 Parameter
Since the SHARED2 parameter is included with both the FIELDALIGN clause and the
FIELDALIGN compiler directive, the following information relates to both usages:
• In a SHARED2 structure, all fields must begin at an even-byte address except
STRING fields, which can begin at any byte address, and UNSIGNED fields, which
can begin at any bit address except as follows:
SHARED8 Parameter
Since the SHARED8 parameter is included with both the FIELDALIGN clause and the
FIELDALIGN compiler directive, the following information relates to both usages:
• The structure must begin at an address that is an integral multiple of the width of
the widest field in the structure. Thus:
• For compatibility with TAL, pTAL requires you to explicitly declare filler items to
optimally align a SHARED8 structure’s fields for RISC and Itanium 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 compiler listing
shows where each structure requires filler. You must add filler:
° Before a field if the field’s offset from the beginning of the structure is not an
integral multiple of the field’s width (see Table 9-3 on page 9-9)
° If the total length of the structure or substructure would not be an integral
multiple of the structure or substructure’s widest field
• If the data type of a field in a SHARED8 structure is an address type, the type must
be EXTADDR, SGBADDR, or SGWADDR, as shown in the following example:
STRUCT s FIELDALIGN(SHARED8);
BEGIN
EXTADDR x; ! OK: EXTADDR field
INT.EXT i; ! OK: EXTADDR pointer
INT.SG j; ! OK: SGWADDR pointer
STRING.s; ! ERROR: BADDR pointer is not valid
END;
Topics:
• Alignment of Fields on page 9-24
• Optimizing Structure Layouts on page 9-24
• Structure Length on page 9-26
• Alignment of UNSIGNED(17-31) Fields on page 9-27
Alignment of Fields
If a field in a SHARED8 structure is not well-aligned, you must explicitly declare filler to
force the field to be well-aligned.
The first filler item (FILLER 2) forces b to begin at a 4-byte address. The second filler
item (FILLER 5) forces d to begin at an 8-byte address. The third filler item
(BIT_FILLER 11) forces h to begin at a 4-byte address.
Structures that specify SHARED8 field alignment, however, require you to explicitly
declare filler items to force fields to be well-aligned, as previously described. You might
be able to reduce the size of a structure if you can arrange its fields to minimize the
number of filler items required.
In Example 9-16 on page 9-25, the structure s2 has the same fields as s1 in
Example 9-15 on page 9-25, but s2 has SHARED8 field alignment and includes filler
items where required. Offsets are shown in bytes. s2 is 32 bytes.
s2 has SHARED8 field alignment, and uses 14 more bytes than s1. If the order of the
fields within the structure is not important; however, you can rearrange the fields so
that the structure contains fewer bytes, as shown in Example 9-17 on page 9-25.
By rearranging the order of the fields, s3 requires 24 bytes, rather than the 32 bytes
required by s2, even though the information in s3 and s2 is the same. s3 uses only
six more bytes than s1.
Structure Length
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 9-20 on page 9-26, u1 starts at the beginning of the structure. u2,
therefore, would begin at a 10-bit offset from the beginning of s. Because u2 is 16 bits,
the last ten bits of u2 would be allocated in a second word, which would cause u2 to
cross an even-byte address; therefore, you must explicitly declare filler to force u2 to
begin at the next even-byte offset from the beginning of s.
You must explicitly declare filler to force u to begin at the next 4-byte offset from the
beginning of s.
The same syntax and semantics of fields and pointer fields declared with a
REFALIGNED clause is the same as that of variables and pointers declared with a
REFALIGNED clause, respectively.
Topics:
• REFALIGNED Clause on page 9-28
• Default Reference Alignment on page 9-29
• REFALIGNED(2) on page 9-29
• REFALIGNED(8) on page 9-31
• Code Generation for Structure References on page 9-32
REFALIGNED Clause
In a SHARED2 or SHARED8 structure, you can include only pointers whose address
type is SGBADDR, SGWADDR, or EXTADDR. Pointers whose address type is any
other type are 16 bits in TAL, but 32 bits in pTAL.
Similarly, if the data type of a nonpointer field in a SHARED2 and SHARED8 structure
is an address type, its type must be SGBADDR, SGWADDR, or EXTADDR.
REFALIGNED(2)
When a structure pointer specifies REFALIGNED(2), the base of the structure might or
might not be well-aligned for RISC and Itanium access. When you reference the
pointer in an expression, pTAL generates conservative code that might not be as
optimal as the code it generates when you specify REFALIGNED(8).
When you use a structure pointer in an executable statement, the field to which the
pointer refers might not be well-aligned. For example, if you are accessing a structure
whose address was passed as a parameter to a procedure, you might not know
whether the field is well-aligned. Although the fields of the structure are well-aligned
from the base of the structure, the base of the structure might not be well-aligned in
memory.
Similarly, if you reference a field in a structure that is stored at an arbitrary address on
a heap, you might not know in advance whether the fields in the structure are well
aligned.
The field alignment of s_templ is SHARED8. Pointers p1, p3, p4, and p5 use
s_templ to define the layout of the structures they reference. p2 uses the global
definition structure s to define its layout.
REFALIGNED(8)
When the reference alignment specified for a structure pointer is 8, the code generated
by pTAL for each reference to the pointer assumes that the base of the structure and
the fields in the structure are well-aligned in memory. If the field alignment of a
structure is SHARED8—or is declared AUTO and the program is compiled by pTAL to
run on RISC and Itanium architecture—and the base of the structure is well-aligned,
references to the pointer will execute with optimal performance in both pTAL and TAL.
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. Each such reference in your program will cause a trap to
the millicode exception handler, which accesses the field your program is referencing
and then returns to your program. Your program’s behavior is not affected by having to
access the field from the exception handler except that its performance for each such
trap is significantly degraded.
pTAL generates conservative code for references to a pointer that specifies
REFALIGNED(8) if it detects that a trap would occur if it generated optimal code.
For the assignment i32 := p1.i, pTAL generates fast code to access the field
described by t1 because the declaration of pointer p1 specifies REFALIGNED(8). If
the field is not well-aligned, your program will run significantly slower because each
reference to elements of p1 will trap to the millicode exception handler to resolve each
memory access.
For the assignment i32 := p2.i, pTAL generates conservative code to access the
field described by t2 because the field might not be well-aligned. The compiler might
generate extra instructions to access the field.
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 is based on t2 (which, in turn, incorporates t1, which is
SHARED2), the reference alignment of p3 is 8 because t2 is SHARED8. The access
uses optimal code because, even though substructure s has SHARED2 alignment, its
containing structure has SHARED8 alignment, and pTAL can determine that the offset
of p3.s.i is well-aligned.
VOLATILE Attribute
The VOLATILE attribute specifies that the value of this variable must be maintained in
memory, not in a register. Each reference to a VOLATILE data item causes the data
item to be read or written to memory even when code is optimized. Based on the order
of reads and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
You can specify the VOLATILE attribute on any field except a substructure.
The syntax and semantics of VOLATILE fields and VOLATILE pointer fields is the
same as those of VOLATILE variables and pointers, respectively.
.EXT
.SG
.SGX
structure-layout ;
range field-alignment
VST624.vsd
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the new referral structure.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth structure occurrence) of the first
structure occurrence you want to allocate. Each occurrence is one copy of the
structure.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth structure occurrence) of the last
structure occurrence you want to allocate. For a single-occurrence structure,
omit both bounds or specify the same value for both bounds.
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.
If you do not specify a FIELDALIGN clause on a structure declaration, pTAL
uses the current value of the FIELDALIGN compiler directive. The default value
of the FIELDALIGN directive is AUTO.
If you specify a FIELDALIGN (NODEFAULT) compiler directive, you must
specify a FIELDALIGN clause on every definition structure and template
structure.
SHARED2
specifies that the base of the structure and each field in the structure must
begin at an even-byte address except STRING fields.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must be begin at an address that is an integral multiple of the width of
the field.
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
is not the same behavior as the AUTO attribute has 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.
structure-layout
is the identifier of a previously declared structure or structure pointer that provides
the structure layout for this structure.
STRUCT identifier ( * )
STRUCTALIGN ( MAXALIGN )
structure-layout ;
field-alignment
VST625.vsd
identifier
is the identifier of the template structure.
(*)
is the symbol for a template structure.
STRUCTALIGN (MAXALIGN)
causes each definition structure that uses this template to be aligned on a 16-byte
boundary (for more information, see STRUCTALIGN (MAXALIGN) Attribute on
page 9-32).
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.
If you do not specify a FIELDALIGN clause on a structure declaration, pTAL
uses the current value of the FIELDALIGN compiler directive. The default value
of the FIELDALIGN directive is AUTO.
If you specify a FIELDALIGN (NODEFAULT) compiler directive, you must
specify a FIELDALIGN clause on every definition structure and template
structure.
SHARED2
specifies that the base of the structure and each field in the structure, except
STRING fields, must begin at an even-byte address.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must begin at an address that is an integral multiple of the width of
the field.
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
is not the same behavior as the AUTO attribute has 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.
A template structure has meaning only when you refer to it in the subsequent
declaration of a referral structure, referral substructure, or structure pointer. The
subsequent declaration allocates space for a structure whose layout is the same as the
template layout.
The declaration in Example 9-29 on page 9-37 associates an identifier with a template
structure layout but allocates no space for it.
.EXT
.SG
.SGX
range
VST025.vsd
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the new referral structure.
referral
is the identifier of a previously declared structure or structure pointer that provides
the structure layout for this structure.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth structure occurrence) of the first
structure occurrence you want to allocate. Each occurrence is one copy of the
structure.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth structure occurrence) of the last
structure occurrence you want to allocate. For a single-occurrence structure,
omit both bounds or specify the same value for both bounds.
The compiler allocates storage for the referral structure based on the following
characteristics:
• The addressing mode and number of occurrences specified in the new declaration
• The layout of the previous declaration
Structures declared in subprocedures must be directly addressed.
Structures always start on a word boundary.
Example 9-31 on page 9-39 declares a template structure and a referral structure that
references the template structure. The referral structure imposes its addressing mode
and number of occurrences on the layout of the template structure.
type identifier ;
VOLATILE ,
VST705.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is any data type described in Section 3, Data Representation.
identifier
is the identifier of the simple variable.
You cannot initialize a simple variable when you declare it inside a structure. You can
subsequently assign a value to the simple variable by using an assignment statement.
VST201.vsd
type
is any data type described in Section 3, Data Representation.
identifier
is the identifier of the array.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth array element) of the first array
element you want allocated. Both lower and upper bounds are required.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth array element) of the last array
element you want allocated. Both lower and upper bounds are required.
When you declare arrays inside a structure, the following guidelines apply:
• You cannot initialize arrays declared in structures. You can assign values to such
arrays only by using assignment statements.
• You cannot declare indirect arrays or read-only arrays in structures.
• You can specify array bounds of [n : n-1] in structures (for example, [6:5]).
Such an array is called a zero-length array. It is often used to initialize a structure,
as in Example 9-34 on page 9-42. This method of initialization allows you to name
something with the same address as the next “thing” in the list without allocating
data for it, similar to a union or equivalence.
Declaring Substructures
A substructure is a structure embedded within another structure or substructure. You
can declare substructures that have the following characteristics:
• Substructures must be directly addressed.
• Substructures have byte addresses, not word addresses.
• Substructures can be nested to a maximum of 64 levels.
• Substructures can have bounds of [n : n-1] (for example, [6:5]).
Topics:
• Definition Substructures on page 9-42
• Referral Substructures on page 9-45
Definition Substructures
A definition substructure describes a layout and allocates storage for it.
STRUCT identifier
structure-layout ;
field-alignment range
VST626.vsd
identifier
is the identifier of the definition substructure.
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.
If you do not specify a FIELDALIGN clause on a structure declaration, pTAL
uses the current value of the FIELDALIGN compiler directive. The default value
of the FIELDALIGN directive is AUTO.
If you specify a FIELDALIGN (NODEFAULT) compiler directive, you must
specify a FIELDALIGN clause on every definition structure and template
structure.
SHARED2
specifies that the base of the structure and each field in the structure must
begin at an even-byte address except STRING fields.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must be begin at an address that is an integral multiple of the width of
the field.
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
is not the same behavior as the AUTO attribute has 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.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the first
substructure occurrence you want allocated. Each occurrence is one copy of
the substructure.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the last
substructure occurrence you want allocated. For a single-occurrence
substructure, omit both bounds or specify the same value for both bounds.
structure-layout
is the same BEGIN-END block as for structures. It can contain declarations for
simple variables, arrays, substructures, filler bits, filler bytes, redefinitions, simple
pointers, and structure pointers. The size of one substructure occurrence is the
size of the layout, either in odd or even bytes. The total layout for one occurrence
of the encompassing structure must not exceed 32,767 bytes.
Referral Substructures
A referral substructure allocates storage for a substructure whose layout is the same
as the layout of a previously declared structure or structure pointer.
range
VST203.vsd
identifier
is the identifier of the referral substructure.
referral
is the identifier of a structure that provides the structure layout. You can specify any
previously declared structure (except the encompassing structure) or structure
pointer. If the previous structure has an odd-byte size, the compiler rounds the size
of the new substructure up so that it has an even-byte size.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth occurrence) of the first substructure
occurrence you want allocated. Each occurrence is one copy of the
substructure.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth occurrence) of the last substructure
occurrence you want allocated. For a single-occurrence substructure, omit both
bounds or specify the same value for both bounds.
Declaring Filler
A filler declaration allocates a byte or bit place holder in a structure.
FILLER constant-expression ;
BIT_FILLER
VST026.vsd
FILLER
allocates the specified number of byte place holders.
BIT_FILLER
allocates the specified number of bit place holders.
constant-expression
is a positive integer constant value that specifies a number of filler units in one of
the following ranges:
FILLER 0 through 32,767 bytes
BIT_FILLER 0 through 255 bits
You can declare filler bits and filler bytes, but you cannot access such filler locations.
If the structure layout must match a structure layout defined in another program, your
structure declaration need only include data items used by your program and can use
filler bits or bytes for the unused space.
The compiler allocates space for each byte or bit you specify in a filler declaration. If
the alignment of the next data item requires additional pad bytes or bits, the compiler
allocates those also.
See also the filler byte example in Definition Substructure on page 9-56.
type
VOLATILE
identifier
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
VST627.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is any data type except UNSIGNED. The data type determines how much data the
simple pointer can access at a time—a byte, word, doubleword, or quadrupleword.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the simple pointer.
REFALIGNED
specifies the base alignment of the structures that the structure pointer will
reference.
2
references a structure that might not be well-aligned.
8
indicates that the base of the structure and the fields in the structure are well
aligned in memory
Topics:
• Using Simple Pointers on page 9-49
• Assigning Addresses to Pointers in Structures on page 9-50
The addressing mode and data type determine the kind of address the simple pointer
can contain.
Example 9-41 on page 9-51 assigns the address of a structure to structure pointers
declared in another structure.
STRING
VOLATILE INT
identifier ( referral )
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
VST628.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
STRING
is the STRING attribute.
INT
is the INT attribute
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the structure pointer.
referral
is the identifier of a structure that provides the structure layout. You can specify any
previously declared structure (including the encompassing structure) or structure
pointer.
REFALIGNED
specifies the base alignment of the structures that the structure pointer will
reference.
2
references a structure that might not be well-aligned.
8
indicates that the base of the structure and the fields in the structure are well
aligned in memory
The addressing mode and STRING or INT attribute determine the kind of addresses a
structure pointer can contain, as described in Table 9-8 on page 9-53.
Declaring Redefinitions
A redefinition declares a new identifier and sometimes a new description for a previous
item in the same structure.
The following rules apply to all redefinitions in structures:
• The new item must be of the same length or shorter than the previous item.
• The new item and the previous item must be at the same BEGIN-END level of a
structure.
Additional rules are given in subsections that describe each kind of redefinition in the
following topics:
• Simple Variable on page 9-54
• Array on page 9-55
• Definition Substructure on page 9-56
• Referral Substructure on page 9-59
• Simple Pointer on page 9-61
• Structure Pointer on page 9-63
For information about redefinitions outside structures, see Section 11, Equivalenced
Variables.
Simple Variable
A simple variable redefinition associates a new simple variable with a previous item at
the same BEGIN-END level of a structure.
VST706.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is any data type except UNSIGNED.
identifier
is the identifier of the new simple variable.
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. You cannot specify an index with this identifier.
In a redefinition, the new item and the previous (nonpointer) item both must have a
byte address or both must have a word address. If the previous item is a pointer, the
data it points to must be word addressed or byte addressed to match the new item.
Example 9-43 on page 9-55 redefines the left byte of int_var as string_var.
Array
An array redefinition associates a new array with a previous item at the same BEGIN-
END level of a structure.
type
identifier = previous-identifier ;
range
VST030.vsd
type
is any data type except UNSIGNED.
identifier
is the identifier of the new array.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth element) of the first array element you
want allocated.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth element) of the last array element you
want allocated.
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. You cannot specify an index with this identifier.
In a redefinition, the new item and the previous (nonpointer) item both must have a
byte address or both must have a word address. If the previous item is a pointer, the
data it points to must be word addressed or byte addressed to match the new item.
Definition Substructure
A definition substructure redefinition associates a new definition substructure with a
previous item at the same BEGIN-END level of a structure.
STRUCT identifier
range field-alignment
= previous-identifier ; structure-layout ;
VST707.vsd
identifier
is the identifier of the new substructure.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the first
substructure occurrence you want allocated. Each occurrence is one copy of
the substructure.
upper-bound
is an INT constant expression (in the range −32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the last
substructure occurrence you want allocated.
To declare a single-occurrence substructure, omit both bounds or specify the
same value for both bounds.
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.
If you do not specify a FIELDALIGN clause on a structure declaration, pTAL
uses the current value of the FIELDALIGN compiler directive. The default value
of the FIELDALIGN directive is AUTO.
If you specify a FIELDALIGN (NODEFAULT) compiler directive, you must
specify a FIELDALIGN clause on every definition structure and template
structure.
SHARED2
specifies that the base of the structure and each field in the structure must
begin at an even byte address except STRING fields.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must be begin at an address that is an integral multiple of the width of
the field.
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
is not the same behavior as the AUTO attribute has 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.
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. No index is allowed with this identifier.
structure-layout
is the same BEGIN-END block as for structures. It can contain declarations for
simple variables, arrays, substructures, filler bits, filler bytes, redefinitions, simple
pointers, and structure pointers. The size of one substructure occurrence is the
size of the layout, either in odd or even bytes. The total layout for one occurrence
of the encompassing structure must not exceed 32,767 bytes.
If the previous item is a substructure and you omit the bounds or if either bound is 0,
the new substructure and the previous substructure occupy the same space and have
the same offset from the beginning of the structure.
Referral Substructure
A referral substructure redefinition associates a new referral substructure with a
previous item at the same BEGIN-END level of a structure.
= previous-identifier ;
range
VST208.vsd
identifier
is the identifier of the new substructure.
referral
is the identifier of a structure that provides the structure layout. You can specify any
previously declared structure (except the encompassing structure) or structure
pointer. If the previous structure has an odd-byte size, the compiler rounds the size
of the new substructure up so it has an even-byte size.
range
[ lower-bound : upper-bound ]
VST993.vsd
lower-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the first
substructure occurrence you want allocated. Each occurrence is one copy of
the substructure.
upper-bound
is an INT constant expression (in the range -32,768 through 32,767) that
specifies the index (relative to the zeroth substructure occurrence) of the last
substructure occurrence you want allocated.
To declare a single-occurrence substructure, omit both bounds or specify the
same value for both bounds.
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. No index is allowed with this identifier.
If the previous item is a substructure and you omit the bounds or if either bound is 0,
the new substructure and the previous substructure occupy the same space and have
the same offset from the beginning of the structure.
Simple Pointer
A simple pointer redefinition associates a new simple pointer with a previous item at
the same BEGIN-END level of a structure.
type identifier
VOLATILE .
.EXT
.SG
.SGX
REFALIGNED ( 2 )
8
= previous-identifier ;
VST708.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is any data type except UNSIGNED. The data type determines how much data the
simple pointer can access at a time—a byte, word, doubleword, or quadrupleword.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the new simple pointer.
REFALIGNED
specifies the base alignment of the structures that the structure pointer will
reference.
2
references a structure that might not be well-aligned.
8
indicates that the base of the structure and the fields in the structure are well
aligned in memory
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. No index is allowed with this identifier.
Structure Pointer
A structure pointer redefinition associates a new structure pointer with a previous item
at the same BEGIN-END level of a structure.
STRING identifier
VOLATILE INT .
.EXT
.SG
.SGX
( referral )
REFALIGNED ( 2 )
= previous-identifier ;
VST709.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
STRING
is the STRING attribute.
INT
is the INT attribute.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the new structure pointer.
referral
is the identifier of a structure that provides the structure layout. You can specify any
previously declared structure (including the encompassing structure) or structure
pointer.
REFALIGNED
specifies the base alignment of the structures that the structure pointer will
reference.
2
references a structure that might not be well-aligned.
8
indicates that the base of the structure and the fields in the structure are well
aligned in memory
previous-identifier
is the identifier of a simple variable, array, substructure, or pointer previously
declared in the same structure. No index is allowed with this identifier.
The addressing mode and STRING or INT attribute determine the kind of addresses a
structure pointer can contain, as described in Table 9-7 on page 9-50.
type
VOLATILE
identifier
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
;
:= initialization
VST676.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
Is one of the following data types depending on whether the pointer is a simple
pointer or a structure pointer:
• BADDR
• CBADDR
• CWADDR
• EXTADDR
• 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. fpoint can also be an
asterisk (*) as in:
FIXED(*) .f;
width
is a constant expression specifying the width, in bits, of the variable.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the pointer.
REFALIGNED
Specifies the alignment of the variables or structures that identifier
references.
2
specifies that the variables and structures identifier references are aligned as
they would be aligned in TAL (and might not be well aligned in pTAL).
8
specifies that the variables and structures are well aligned for use in pTAL.
For nonstructure pointers, the default for REFALIGNED is the value you specify in
the REFALIGNED on page 17-53.
initialization
is an expression representing a memory address. For more information about
operations on addresses, see Section 5, Expressions.
Simple
When you declare a VOLATILE simple pointer, the value of the pointer and the data
referenced by the pointer are treated as VOLATILE and are maintained in memory, not
in a register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads and
writes in the source code, VOLATILE also causes that precise order of memory
references to be preserved, again, when code is optimized.
Structure
When you declare a VOLATILE structure pointer, the compiler generates code that
maintains the value of the pointer in memory, not in a register. Each reference to a
VOLATILE data item causes the data item to be read or written to memory even when
code is optimized. Based on the order of reads and writes in the source code,
VOLATILE also causes that precise order of memory references to be preserved,
again, when code is optimized.
You must specify the VOLATILE attribute on each field that you want to be volatile.
Address Types
pTAL address types control the addresses you store into pointers. A 32-bit address can
reference data anywhere in memory with optimal performance. The hardware does not
require programs to specify an addressing type or memory storage area.
The compiler determines the address type of a pointer from the pointer declaration.
You cannot explicitly declare a pointer’s address type.
Address types are used primarily to describe the addresses that you assign to a
pointer, not the data your program is processing.
Only operations that are meaningful for addresses are valid on address types.
You cannot explicitly declare or change the address type of a pointer. pTAL determines
the address type based on the pointer declaration.
Every identifier you declare in a pTAL program has an object data type and an address
type. Table 10-2 on page 10-7 lists the address type for all pTAL constructs except
simple variables. The address type of a simple variable is the same as the address
type of a pointer to data of the same object data type as the simple variable.
Topics:
• BADDR and WADDR on page 10-9
• SGBADDR, SGWADDR, SGXBADDR, and SGXWADDR (System Globals) on
page 10-9
• PROCADDR (Procedures, Procedure Pointers, and Procedure Entry Points) on
page 10-10
• Subprocedures, Subprocedure Entry Points, Labels, and Read-Only Arrays
(CBADDR and CWADDR Address Types) on page 10-10
• EXTADDR on page 10-11
EXTADDR
An EXTADDR is 32 bits. You can store the address of any of your processes’ data in
an EXTADDR pointer.
type
VOLATILE
identifier
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
;
:= initialization
VST676.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is one of the following data types:
• BADDR
• CBADDR
• CWADDR
• EXTADDR
• FIXED [ (fpoint ) ]
• INT
• INT (16)
• INT (32)
• INT (64)
• PROCADDR
• REAL
• REAL (32)
• REAL
• REAL (32)
• REAL (64)
• SGBADDR
• SGWADDR
• SGXBADDR
• SGXWADDR
• STRING
• WADDR
fpoint
The implied fixed point of the FIXED variable. fpoint can also be an asterisk (*)
as in:
FIXED(*) .f;
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the pointer.
REFALIGNED
For simple pointers, the default for REFALIGNED is the value you specify in the
REFALIGNED on page 17-53.
2
specifies that the variables and structures that identifier references are aligned as
they would be aligned in TAL (and might not be well-aligned in pTAL).
8
specifies that the variables and structures are well-aligned for use in pTAL (and in
TAL, that they have more space).
For nonstructure pointers, the default for REFALIGNED is the value you specify in
the REFALIGNED on page 17-53.
initialization
An expression representing a memory address. For more information about
operations on addresses, see Section 5, Expressions.
The data type determines the size of data a simple pointer can access at a time.
The addressing mode and data type of the simple pointer determines the kind of
address the pointer can contain.
For information about data types and addresses, see Table 10-1 on page 10-6 and
Table 10-2 on page 10-7.
Furthermore, the kind of expression you can specify for the address depends on the
level at which you declare the pointer:
• At the global level, use a constant expression.
• At the local or sublocal level, you can use any arithmetic expression.
Expressions other than those in the preceding list can perform valid type conversions,
but the compiler recognizes only those in the preceding list and might diagnose others
as errors.
Simple pointers receive their initial values when you compile the source code. Local or
sublocal simple pointers receive their initial values at each activation of the
encompassing procedure or subprocedure.
STRING
VOLATILE INT
identifier ( referral )
.EXT
.SG
.SGX
;
:= initialization
VST677.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
STRING
is the STRING attribute.
INT
is the INT attribute, as INT, INT(32), or FIXED.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of the pointer.
referral
is the identifier of a previously-declared structure, structure template, or structure
pointer.
Specify referral only for pointers to structures.
initialization
is an expression representing a memory address. For more information about
operations on addresses, see Section 5, Expressions.
A standard STRING structure pointer can access only these structure items:
• Substructure
• STRING simple variable
• STRING array
The last declaration in Example 10-15 on page 10-18 shows a STRING structure
pointer initialized with the converted byte address of a substructure.
Example 10-16 on page 10-18 shows another way to access a STRING item in a
structure. You can convert the word address of the structure to a byte address when
you initialize the STRING structure pointer and then access the STRING item in a
statement.
The system global pointer declaration associates an identifier with a memory location
at which you store the address of a variable located in the system global data area.
type
.SG identifier ;
:= preset-address
,
VST020.vsd
type
is any data type except UNSIGNED; specifies the data type of the value to which
the pointer points.
.SG
is an indirection symbol (see Table 2-7 on page 2-7).
identifier
is the identifier of the pointer.
preset-address
is the address of a variable in the system global data area. The address is
determined by you or the system during system generation.
Topics:
• Declaring Equivalenced Variables on page 11-2
• Memory Allocation on page 11-4
• Declaring Nonstructure Equivalenced Variables on page 11-5
• Equivalencing PROCADDR Variables and PROCPTR Variables on page 11-15
• Declaring Equivalenced Definition Structures on page 11-16
• System Global Equivalenced Variable Declarations on page 11-22
You can index a variable that participates in an equivalenced declaration either as the
equivalenced variable or as the previous variable even if none of the variables in the
equivalenced group specify array bounds.
Memory Allocation
pTAL does not allocate memory for equivalenced variables. In the following example,
pTAL allocates memory only for base_previous:
INT base_previous;
INT equivalenced1 = base_previous;
INT equivalenced2 = equivalenced1;
An equivalenced variable is an alias for memory allocated for a previously declared
variable. The equivalenced declaration can specify different attributes; for example, a
different data type than those of the previous variable. In the following example, pTAL
allocates 32 bits for i. The equivalenced declaration for j references the memory
allocated for i, but specifies that the bits be treated as a REAL number:
INT(32) i;
REAL j = i;
If an equivalenced variable is a standard or extended pointer and the previous variable
is the implicit pointer of an indirect array or indirect structure, the equivalenced variable
is a read-only pointer. You can use the value of the pointer in an expression, but you
cannot store an address or other value into the pointer because doing so would be the
same as storing an address into the implicit pointer of the array or structure. You can,
however, use a pointer to read or write the data to which the pointer points.
VOLATILE
= previous-identifier
;
[ index ]
+ offset
-
VST629.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
If referral is present, must be STRING or INT; otherwise, type is any data
type except UNSIGNED.
identifier
is the identifier of the equivalenced variable to be made equivalent to previous-
identifier.
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-identifier
to which the equivalenced pointer or variable refers. Specify index only with
direct variables. index must end on a word boundary.
+
-
is the word or byte offset, relative to the base of previous-identifier, where
the equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
is an INT constant that specifies a word offset from previous-identifier,
which can be a direct or indirect variable. If previous-identifier is indirect,
the offset is from the location of the pointer, not from the location of the data
pointed to.
The following are valid equivalenced declarations:
INT a;
INT b = a;
INT(32) c[0:3];
INT d[0:7] = c;
Topics:
• Memory Usage for Nonstructured Equivalenced Variables on page 11-7
• Equivalenced Arrays on page 11-7
• Indirect Arrays on page 11-8
• Equivalenced Simple Variables on page 11-8
• Equivalenced Simple Pointers on page 11-10
Equivalenced Arrays
Use the lower-bnd1 and upper-bnd2 parameters as shown in the nonstructure
declaration syntax.
Indirect Arrays
Figure 11-1 on page 11-8 shows how pTAL implements indirect arrays. The compiler
allocates storage for the four elements of the array a, but not for a pointer to a.
References to a access the data directly not indirectly through a pointer.
A: 1000 10
1001 20
1002 30
1003 40
VST121.vsd
type
VOLATILE
identifier ( referral )
= previous-identifier
;
[ index ]
+ offset
-
VST004.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
If referral is present, type must be STRING or INT; otherwise, type is any
data type except UNSIGNED.
identifier
is the identifier of the simple equivalenced variable to be made equivalent to
previous-identifier.
previous-identifier
is the identifier of a previously declared simple variable.
index
is an INT constant that specifies an element offset from previous-identifier,
which must be a direct variable. The data type of previous-identifier
dictates the element size. The location represented by index must begin on a
word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT(32) a[0:9];
INT b = a+6
then b is placed in the first six bits of a.
offset
is an INT constant that specifies an element offset from previous-identifier,
which must be a direct variable. The data type of previous-identifier
dictates the element size. The location represented by index must begin on a
word boundary.
Equivalencing a simple variable to an indirect array or structure is not recommended. If
you do so, the simple variable is made equivalent to the location of the implicit pointer,
not the location of the data pointed to.
In Figure 11-2 on page 11-10, a STRING variable and an INT(32) variable are
equivalenced to an INT array.
VST302.vsd
type
VOLATILE
identifier ( referral )
.
.EXT = previous-identifier
.SG
.SGX ;
[ index ]
+ offset
-
VST630.vsd
VOLATILE
specifies that the value of this variable must be maintained in memory, not in a
register. Each reference to a VOLATILE data item causes the data item to be read
or written to memory even when code is optimized. Based on the order of reads
and writes in the source code, VOLATILE also causes that precise order of
memory references to be preserved, again, when code is optimized.
type
is any data type except UNSIGNED. The data type determines how much data the
simple pointer can access at a time (byte, word, doubleword, or quadrupleword).
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of a simple pointer to be made equivalent to previous-
identifier.
previous-identifier
is 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-identifier,
which must be a direct variable. The data type of previous-identifier
dictates the element size. The location represented by index must begin on a
word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT(32) a[0:9];
INT b = a+6
then b is placed in the first six bits of a.
offset
is an INT constant that specifies an element offset from previous-identifier,
which must be a direct variable. The data type of previous-identifier
dictates the element size. The location represented by index must begin on a
word boundary.
Topics:
• Using Equivalenced Simple Pointers on page 11-12
• REFALIGNED Clause for Equivalenced Simple Pointers on page 11-15
INT .EXT a;
12345
STRING .b;
"ABCDEFGHIJ"
VST124.vsd
The code in Figure 11-4 on page 11-14 declares an INT(32) simple pointer equivalent
to an INT simple pointer. Both contain a word address.
.
.
.
G[200]
VST307.vsd
pTAL does not verify that the lengths of the objects to which an equivalenced pointer
refers are equal. pTAL accepts the declaration in Example 11-5 on page 11-14
because the address types of both pointers are WADDR.
.EXT
.SG
.SGX
= previous-identifier
field-alignment
;
[ index ] structure-layout
+ offset
VST632.vsd
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
structure
is the identifier that the declaration creates.
referral
is the identifier of a previously declared structure, structure layout, or structure
pointer.
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
FIELDALIGN
specifies the memory alignment for the base of the structure and for fields
within the structure. For details about the FIELDALIGN clause, see Section 9,
Structures.
SHARED2
specifies that the base of the structure and each field in the structure must
begin at an even byte address except STRING fields.
SHARED8
specifies that the offset of each field in the structure from the base of the
structure must be begin at an address that is an integral multiple of the width of
the field.
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
is not the same behavior as the AUTO attribute has 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.
previous-identifier
is the name of a previously declared simple variable, direct array element,
structure, structure layout, structure pointer, or equivalenced variable.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT(32) a[0:9];
INT b = a+6
then b is placed in bytes 12 and 13 of a.
offset
is an INT constant that specifies a word offset. Specify offset only with indirect
variables. The offset is from the location of the pointer, not from the location of the
data pointed to.
structure-layout
is a BEGIN-END block that contains declarations. For more information about the
structure layout, See Section 9, Structures.
You must specify either referral or structure-layout but not both in an
equivalenced structure declaration.
You can specify a FIELDALIGN clause only if you specify structure-layout. You
cannot specify a FIELDALIGN clause for a referral structure.
The code in Figure 11-5 on page 11-19 declares an extended indirect definition
structure equivalent to a previously declared extended indirect structure.
xstr1 xstr1
. .
. .
. .
VST315.vsd
If the new structure is to occupy the same location as the previous variable, their
addressing modes must match. You can declare a direct or indirect structure
equivalent to the following previous variables:
New Structure Previous Variable
Direct structure Simple variable
Direct structure
Direct array
Standard indirect structure Standard indirect structure
Standard indirect array
Standard structure pointer
Extended indirect structure Extended indirect structure
Extended indirect array
Extended structure pointer
If the previous variable is a structure pointer, the new structure is really a pointer.
Topics:
• Structure Variants on page 11-20
• Memory Usage for Structured Equivalenced Variables on page 11-21
• FIELDALIGN Clause on page 11-22
Structure Variants
You use substructures to declare variant records in structures. pTAL does not detect
addresses that are redefined by equivalenced variant structures.
When you compile Example 11-9 on page 11-20, the compiler allocates 8 bytes, the
length of v1. Although v1 and v2 are different lengths and their fields have different
data types, the compiler does not report an error or a warning. You must ensure that
the variants are meaningful for your algorithms.
The structure in Example 11-10 on page 11-20 contains the same variants as the
structure in Example 11-9 on page 11-20, but the variants are in reverse order.
In Example 11-10 on page 11-20, v1 is 4 bytes, but v2 is 8 bytes. The compiler reports
a warning. Data that your program stores into s.v2.q overwrites the data in the
memory locations that follow s.
v2 is 8 bytes to maintain the alignment of variables in memory. For more information
about lengths of pTAL structures, see Section 9, Structures.
If you declare b and then declare a, pTAL does not report an error because a fits within
the four bytes already allocated for b, as in Example 11-12 on page 11-21.
FIELDALIGN Clause
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 optimized for TAL programs on TNS
architecture and the other optimized for pTAL programs on TNS/R or TNS/E
architecture. Declare the pTAL structure first.
In Example 11-13 on page 11-22, structures a and b declare the same fields, but a
specifies FIELDALIGN(SHARED8), the optimal alignment for pTAL, whereas b
specifies FIELDALIGN(SHARED2), the alignment for TAL. pTAL generates fast code
for references to a.i, but conservative code for references to b.i
For more information about using the FIELDALIGN clause, see Section 9, “Structures.”
type
identifier =
'SG' ;
[ index ]
+ offset
-
VST068.vsd
type
is any data type except UNSIGNED; specifies the data type of identifier.
identifier
is the identifier of a simple variable to be made equivalent to 'SG'.
'SG'
a symbol that denotes a 16-bit system global address.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
an equivalent INT values in the range 0 through 63.
.SG
.SGX
; structure-layout ;
[ index ]
+ offset
-
VST710.vsd
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of a definition structure to be made equivalent to 'SG'.
'SG'
denotes a 16-bit system global address.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
an equivalent INT values in the range 0 through 63.
structure-layout
a BEGIN-END block that contains declarations for structure items.
.SGX
.EXT
= 'SG' ;
[ index ]
+ offset
-
VST703.vsd
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of a referral structure to be made equivalent to 'SG'.
referral
is the identifier of a previously declared structure or structure pointer that is to
provide the layout for this structure.
'SG'
denotes a 16-bit system global address.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
an equivalent INT values in the range 0 through 63.
If you specify an indirection symbol (see Table 2-7, Indirection Symbols, on page 2-7),
the structure behaves like a structure pointer. If you do not specify an indirection
symbol, the structure has direct addressing.
.SGX
.EXT
;
[ index ]
+ offset
-
VST704.vsd
type
is any data type except UNSIGNED and specifies the data type of the value to
which the pointer points.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of a simple pointer to be made equivalent to 'SG'.
'SG'
denotes a 16-bit system global address.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word (16-bit) boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
an equivalent INT values in the range 0 through 63.
STRING . identifier
INT .SG
.SGX
.EXT
( referral ) = 'SG'
;
[ index ]
+ offset
-
VST711.vsd
STRING
is the STRING attribute.
INT
is the INT attribute.
.
.EXT
.SG
.SGX
are indirection symbols (see Table 2-7 on page 2-7).
identifier
is the identifier of a structure pointer to be made equivalent to 'SG'.
referral
is the identifier of a previously declared structure or structure pointer that is to
provide the layout for identifier.
'SG'
denotes a 16-bit system global address.
index
is an INT constant that specifies the offset of the element in previous-ident to
which the equivalenced pointer or variable refers. Specify index only with direct
variables. index must end on a word (16-bit) boundary.
+
-
is the word or byte offset, relative to the base of previous-ident, where the
equivalenced variable is placed. For example, if a and b are declared:
INT a[0:9];
INT b = a+5
then b is placed at a[5].
offset
an equivalent INT values in the range 0 through 63.
Table 10-1 on page 10-6 describes the kind of addresses a structure pointer can
contain depending on the STRING or INT attribute and addressing symbol.
In addition to the statements summarized in Table 12-1 on page 12-1, this section
describes:
• Using Semicolons in Statements on page 12-2
• Compound Statements on page 12-2
Compound Statements
A compound statement is a BEGIN-END block that groups statements to form a single
logical statement.
BEGIN END
statement ;
VST034.vsd
BEGIN
indicates the start of the compound statement.
statement
is a statement described in this section.
; (semicolon)
is a statement separator that is required between successive statements. A
semicolon before an END that terminates a compound statement is optional and
represents a null statement.
END
indicates the end of the compound statement.
You can use compound statements anywhere you can use a single statement. You can
nest them to any level in statements such as IF, DO, FOR, WHILE, or CASE.
ASSERT
The ASSERT statement conditionally calls the procedure specified in the active
directive ASSERTION on page 17-19.
VST035.vsd
assert-level
is an integer in the range 0 through 32,767.
If assert-level is greater than or equal to the assertion-level specified in
the active ASSERTION directive and if condition is true, the program calls the
procedure specified in the active ASSERTION directive.
condition
is a conditional expression (see Conditional Expressions on page 5-15).
To use the ASSERT statement and the ASSERTION directive together for debugging
or error-handling:
1. Put an ASSERTION directive in the source code, specifying an assertion-
level and an error-handling procedure.
2. Put an ASSERT statement at each place where you want to execute the error-
handling procedure when an error occurs. In each ASSERT statement, specify:
Assignment
The assignment statement assigns a value to a previously declared variable.
variable := expression
VST012.vsd
variable
is the identifier of a simple variable, array element, simple pointer, structure
pointer, or structure data item, with or without a bit deposit field and/or index. To
update a pointer’s content, prefix the pointer identifier with @.
expression
is either:
• An arithmetic expression of the same data type as variable
• A conditional expression, which always has an INT result
expression can be a bit extraction value or an identifier prefixed with @ (the
address of a variable). expression cannot be a constant list.
In general, the data types of variable and expression must match. To
convert the data type of expression to match the data type of variable, use a
type-transfer routine, described in Section 15, Built-In Routines.
The following rules apply to assignment statements:
• The data type of the expression on the right side of an assignment statement must
be compatible with the data type of the destination on the left side of the
assignment statement.
• You cannot store a value into the implicit pointer of an indirect array or indirect
structure.
• You cannot store a value into the implicit pointer of an equivalenced variable that
references the data of an indirect array or indirect structure.
• Do not depend on whether the left side or the right side of an assignment
statement is evaluated first.
• Address types must match.
• pTAL disallows all assignments of unlike data types except the following:
When an INT variable is assigned to a STRING variable, the upper 8 bits of the
INT variable are not retained in any way in the STRING variable. Thus, the
comparison of i1 to i2 in the final statement of the following code 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 8 bits. The upper 8 bits of I1 are not
transferred to s in the assignment statement s := i1.
INT i1 := %HFFFF,
i2;
STRING s;
i2 := i1; ! Copy i1 to i2
s := i1; ! Assign 16-bit INT to 8-bit STRING
i1 := s; ! Assign 8-bit STRING to 16-bit INT
IF i1 = i2 THEN; ! i1 (%HFF) is not equal to i2 (%HFFFF)
° UNSIGNED(17-31) variables are syntactically and semantically equivalent to
INT(32) variables. Thus, UNSIGNED(17-31) variables are valid anywhere
INT(32) variables are valid:
INT(32) i;
UNSIGNED(31) u;
INT j;
i := u; ! OK: No bits are lost in assignment
u := i; ! WARNING: Most significant bit of i could
! be lost
u := j; ! ERROR: INT and UNSIGNED(17-31) are not
! assignment-compatible
Topics:
• Pointer Assignment on page 12-6
• Assigning Numbers to FIXED Variables on page 12-7
• Assigning Character Strings on page 12-7
• Examples on page 12-8
Pointer Assignment
The result of applying an @ operator to a variable or pointer is an address whose data
type is one of the pTAL address types.
In an assignment statement, one of the following must be true:
• Both operands are the same address type.
• Neither operand is an address type.
You can use type-conversion built-in routines to convert some address types to other
address types. For more information:
Topic See ...
Type-conversion built-in routines Section 15, Built-In Routines
Converting addresses Section 5, Expressions
Pointers Section 10, Pointers
Examples
Assignment statements can assign character strings but not constant lists, so in
Example 12-5 on page 12-8, the three assignment statements together store the same
value as the one constant list in the declaration.
In Example 12-6 on page 12-8, the first assignment statement (which contains
assignment expressions) is equivalent to the three separate assignments that follow it.
Bit-Deposit Assignment
The bit deposit form of the assignment statement lets you assign a value to an
individual bit or to a group of sequential bits.
: right-bit
:= expression
VST037.vsd
variable
is the identifier of a STRING or INT variable, but not an UNSIGNED(1-16) variable.
variable can be the identifier of a simple variable, array element, or simple
pointer (inside or outside a structure).
left-bit
is an INT constant that specifies the leftmost bit of the bit deposit field.
For STRING variables, specify a bit number in the range 8 through 15. Bit 8 is the
leftmost bit in a STRING variable; bit 15 is the rightmost bit.
right-bit
is an INT constant specifying the rightmost bit of the bit deposit field. right-bit
must be equal to or greater than left-bit.
For STRING variables, specify a bit number in the range 8 through 15. Bit 8 is the
leftmost bit in a STRING variable; bit 15 is the rightmost bit.
expression
is an INT arithmetic or conditional expression, with or without a bit field
specification.
The bit deposit field is on the left side of the assignment operator (:=). The bit deposit
assignment changes only the bit deposit field. If the value on the right side has more
bits than the bit deposit field, the system ignores the excess high-order bits when
making the assignment.
Specify the variable/bit-field construct with no intervening spaces as shown:
myvar.<0:5>
Do not use bit deposit fields to pack data. Instead, declare an UNSIGNED variable and
specify the appropriate number of bits in the bit field.
Examples:
1. The bit deposit assignment sets bits 3 through 7 of the word designated by x:
INT x;
x.<3:7> := %B11111;
2. The bit deposit assignment replaces bits <10> and <11> with zeros:
INT old := -1; ! old = %b1111111111111111
old.<10:11> := 0; ! old = %b1111111111001111
3. The bit deposit assignment sets bit <8>, the leftmost bit of strng, to 0:
STRING strng := -1; ! strng = %b11111111
strng.<8> := 0; ! strng = %b01111111
4. The value %577 is too large to fit in bits <7:12> of var. The system truncates
%577 to %77 before performing the bit deposit:
INT var := %125252; ! var = %b1010101010101010
var.<7:12> := %577; ! %77 = %b0000000101111111
! var = %b1010101111111010
5. The bit deposit assignment replaces bits <7:8> of new with bits <8:9> of old:
INT new := -1; ! new = %b1111111111111111
INT old := 0; ! old = %b0000000000000000
new.<7:8> := old.<8:9>; ! new = %b1111111001111111
CALL
The CALL statement calls a procedure, subprocedure, or entry-point identifier and
optionally passes parameters to it.
In pTAL, a procedure’s formal and actual parameters either 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 under
Converting Between Address Types on page 3-7.
identifier
CALL ( )
param-name
param-pair
,
VST038.vsd
identifier
is the identifier of a previously declared procedure, subprocedure, or entry-point
identifier.
param-name
is a variable identifier or an expression that defines an actual parameter to pass to
a formal parameter declared in identifier.
param-pair
is an actual parameter pair to pass to a formal parameter pair declared in
identifier. param-pair has the form:
string : length
VST039.vsd
string
is an expression of the type STRING . or STRING .EXT.
length
is an INT expression that specifies the length, in bytes, of string.
Use the CALL statement to call procedures and subprocedures (but usually not
functions).
To call functions, you usually use their identifiers in expressions. If you call a function
by using a CALL statement, the caller does not use the returned value of the function.
Actual parameters are value or reference parameters and are optional or required
depending on the formal parameter specification in the called procedure or
subprocedure declaration (described in Section 14, Procedures, Subprocedures, and
Procedure Pointers). A value parameter passes the content of a location; a reference
parameter passes the address of a location.
In a CALL statement to a VARIABLE procedure or subprocedure or to an
EXTENSIBLE procedure, you can omit optional parameters in two ways:
• You can omit parameters or parameter pairs unconditionally. Use an empty comma
for each omitted parameter or parameter pair up to the last specified parameter or
parameter pair. If you omit all parameters, you can specify an empty parameter list
(parentheses with no commas) or you can omit the parameter list altogether.
• You can omit parameters or parameter pairs conditionally. Use the $OPTIONAL
built-in routine as described in Section 15, Built-In Routines.
After the called procedure or subprocedure completes execution, control returns to the
statement following the CALL statement that calls the procedure or subprocedure.
CASE
The CASE statement executes a choice of statements based on a selector value.
Normally, you use labeled CASE statements. Labeled CASE statements are described
first, followed by unlabeled CASE statements.
If a case index does not match any alternative, an instruction trap occurs.
Topics:
• Empty CASE on page 12-12
• Labeled CASE on page 12-13
• Unlabeled CASE on page 12-15
Empty CASE
pTAL does not allow empty CASE statements. A CASE statement include at least one
alternative, even if there are no statements specified for that alternative.
Labeled CASE
The labeled CASE statement executes a choice of statements when the value of the
selector matches a case label associated with those statements.
END
OTHERWISE -> ;
statement-2
VST041.vsd
selector
is an INT or INT (32) value arithmetic expression that uniquely selects the case-
alternative for the program to execute.
case-alternative
associates one or more case-label s or one or more ranges of case-label s
with one or more statement s. The statement s of a case-alternative are
executed if selector equals an associated case-label. Each case-
alternative has the form:
case-label ->
lower-case-label .. upper-case-label
,
statement-1
;
VST042.vsd
case-label
a signed INT constant or LITERAL. Each case-label must be unique in the
CASE statement.
lower-case-label
is the smallest value in an inclusive range of signed INT constants or
LITERALs.
upper-case-label
is the largest value in an inclusive range of signed INT constants or LITERALs.
statement-1
is any statement described in this section.
OTHERWISE
specifies an optional sequence of statements to execute if selector does not
select any case-alternative. If no OTHERWISE clause is present and
selector does not match a case-alternative, a run-time error occurs.
Always include an OTHERWISE clause, even if it contains no statements.
statement-2
is any statement described in this section.
A CASE statement must have at least one alternative.
If you omit the OTHERWISE clause and selector is out of range (negative or
greater than n), the a divide-by-zero instruction trap occurs.
A CASE index matches an alternative identified by the keyword OTHERWISE if and
only if the case index does not match any other alternative and OTHERWISE is an
alternative.
Unlabeled CASE
The unlabeled CASE statement executes a choice of statements, based on an
inclusive range of implicit selector values, from 0 through n, with one statement for
each value.
CASE selector OF
BEGIN ;
statement-1
END
OTHERWISE ;
statement-2
VST040.vsd
selector
is an INT or INT (32) arithmetic expression that selects the statement to execute.
statement-1
is any statement described in this section. Include a statement-1 for each value
in the implicit selector range, from 0 through n. If a selector has no action,
specify a null statement (semicolon with no statement). If you include more than
one statement-1 for a value, you must use a compound statement.
OTHERWISE
indicates the statement to execute for any case outside the range of selector
values. If the OTHERWISE clause consists of a null statement, control passes to
the statement following the unlabeled CASE statement.
statement-2
is any statement described in this section. Include a statement-2 for each value
in the implicit selector range, from 0 through n. If a selector has no action,
specify a null statement (semicolon with no statement). If you include more than
one statement-2 for a value, you must use a compound statement.
The compiler numbers each statement in the BEGIN clause consecutively, starting
with 0. If the selector matches the compiler-assigned number of a statement, that
statement is executed. For example, if the selector is 0, the first statement
executes; if the selector is 4, the fifth statement executes. Conversely, if the
selector does not match a compiler-assigned number, the OTHERWISE
statement, if any, executes.
The index of an unlabeled CASE statement and the selector of a labeled CASE
statement can be INT(32) expressions.
If you omit the OTHERWISE clause and selector is out of range (negative or
greater than n), a divide-by-zero instruction trap occurs.
Example 12-13 on page 12-17 selectively moves one of several messages into an
array.
DO-UNTIL
The DO-UNTIL statement is a posttest loop that repeatedly executes a statement until
a specified condition becomes true.
DO UNTIL condition
statement
VST046.vsd
statement
is any statement described in this section.
condition
is either:
• A conditional expression
• An INT, INT(32), or FIXED arithmetic expression. If the result of the arithmetic
expression is not 0, condition is true. If the result is 0, condition is false.
If condition is false, the DO-UNTIL statement continues to execute. If
condition is true, the statement following the DO-UNTIL statement executes.
A DO-UNTIL statement always executes at least once (unlike the WHILE on
page 12-45).
In Example 12-14 on page 12-18, the DO-UNTIL statement loops through array_a,
testing the content of each element until an alphabetic character occurs.
In Example 12-15 on page 12-18, the DO-UNTIL statement loops through array_a,
assigning a 0 to each element until all the elements contain a 0.
The conditional expression cannot reference hardware indicators (<, <=, =, <>, >, >=,
'<', '<=', '=', '<>', '>', '>=', $OVERFLOW, and $CARRY). Only IF statements can test
hardware indicators. For more information, see Section 13, Hardware Indicators.
To use a hardware indicator’s value to control a DO-UNTIL loop, save the hardware
indicator’s value and either test the saved value (as in Example 12-16 on page 12-19)
or execute an explicit GOTO statement to exit the loop (as in Example 12-17 on
page 12-19). Hardware indicators cannot appear in the conditional expression of a DO-
UNTIL statement.
DROP
The DROP statement removes either a label (from the symbol table) or a temporary
variable that was created by the statement USE on page 12-45.
DROP identifier
,
VST047.vsd
identifier
is the identifier of either a label or a temporary variable.
Dropping Labels
You can drop a label only if you have already declared the label or used it to label a
statement. Before you drop a label, be sure there are no further references to the label.
If a GOTO statement refers to a dropped label, a run-time error occurs. After you drop
a label, you can, however, use the identifier to label a statement preceding the GOTO
statement that refers to the label.
FOR
The FOR statement is a pretest loop that repeatedly executes a statement while
incrementing or decrementing an index automatically.
DO
BY step statement
VST048.vsd
index
is a value that increments or decrements automatically.
In Standard on page 12-21, index is the identifier of an INT or INT(32) simple
variable, array element, simple pointer, or structure data item.
In Optimized on page 12-22, index is the identifier of an index register you have
reserved with the USE on page 12-45.
initial-value
is an arithmetic expression (such as 0) that initializes index. If index is INT,
initial-value is INT. If index is INT(32), initial-value is INT(32).
TO
increments index each time the loop executes until index is greater than or
equal to limit, at which point the loop stops.
DOWNTO
decrements index each time the loop executes until index is less than or equal
to limit, at which point the loop stops.
limit
is an arithmetic expression that terminates the loop. If index is INT, initial-
value is INT. If index is INT(32), initial-value is INT(32).
step
is an arithmetic expression by which to increment or decrement index each time
the loop executes. If index is INT, then step is INT; otherwise, index is
INT(32). The default is 1.
statement
is any statement described in this section.
The FOR statement tests index at the beginning of each iteration of the loop. If
index exceeds limit on the first test, the loop never executes.
Topics:
• Nested on page 12-21
• Standard on page 12-21
• Optimized on page 12-22
Nested
You can nest FOR statements to any level.
The nested FOR statement in Example 12-18 on page 12-21 uses multiples as a
two-dimensional array. It fills the first row with multiples of 1, the next row with multiples
of 2, and so on.
Standard
For index, standard FOR statements specify an INT or INT(32) variable. Standard
FOR statements execute as follows:
• When the looping terminates, index is greater than limit if:
• limit and step are recomputed at the start of each iteration of the statement.
The standard FOR statement in Example 12-19 on page 12-22 uses the DOWNTO
clause to reverse a string from "BAT" to "TAB".
Optimized
For index, an optimized FOR statement specifies a temporary variable created by the
statement USE on page 12-45. Optimized FOR statements execute faster than
standard FOR statements because limit is computed only once, at the start of the first
iteration of the statement.
GOTO
The GOTO statement unconditionally transfers control to a labeled target statement.
GOTO label-name
VST049.vsd
label-name
is the label that precedes the target statement (see Labels in Procedures on
page 14-37).
A GOTO statement can be either local or nonlocal.
Topics:
• Local on page 12-23
• Nonlocal on page 12-24 (not recommended)
• GOTO and Target Statements With Different Trapping States on page 12-24
Local
If the GOTO statement and the target statement are in the same procedure or in the
same subprocedure, the GOTO statement is local.
Nonlocal
Note. Nonlocal GOTO statements are are inefficient and not recommended.
Example 12-23. Local GOTO and Target Statements That Have Different Trapping
States
proc p nooverflow_traps;
begin
subproc s overflow_traps;
begin
goto L1; ! Illegal trapping states differ
end;
L1:
end;
If a GOTO statement and the target statement are in different BEGIN-END blocks:
• You must declare the target label in a LABEL declaration in the containing
procedure.
Note. LABEL is an invalid data type for a formal parameter. You cannot pass a label as an
actual parameter.
• 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.
• A GOTO statement in a BEGIN-END block that does not specify a block-level
trapping attribute cannot branch to a label in a BEGIN-END block in which a block-
level trapping attribute is specified.
The compiler uses attributes on BEGIN-END blocks to determines whether a GOTO
within one BEGIN-END block can branch to a label in another BEGIN-END block.
For more information, see Section 13, Hardware Indicators.
Example 12-24. Nonlocal GOTO and Target Statements That Have Different
Trapping States
PROC p OVERFLOW_TRAPS;
BEGIN
INT i := 0;
label_a: ! Overflow traps are enabled at label_a
i := i + 1;
IF i < 10 THEN
GOTO label_a ! OK: Traps enabled here and at label_a
ELSE
BEGIN:ENABLE_OVERFLOW_TRAPS
GOTO label_a; ! OK: Branch from block with traps
IF i <> 1 THEN ! specified
BEGIN
label_b: ...
END;
END;
BEGIN:DISABLE_OVERFLOW_TRAPS
GOTO label_b; ! ERROR: Cannot branch between blocks
END; ! that have different trapping states
BEGIN
GOTO label_b; ! ERROR: Cannot branch from a BEGIN-END
END; ! block that does not specify a trapping
END; ! attribute to a BEGIN-END block that
! does
IF
The IF statement conditionally selects one of two statements to execute.
IF condition THEN
statement-1
ELSE
statement-2
VST050.vsd
condition
is either:
• A conditional expression whose value has 16 bits
• An INT, INT(32), or FIXED arithmetic expression. If the result of the arithmetic
expression is not 0, condition is true. If the result is 0, condition is false.
statement-1
specifies the statement to execute if condition is true. statement-1 can be
any statement described in this section. If you omit statement-1, no action
occurs for the THEN clause.
statement-2
specifies the statement to execute if condition is false. statement-2 can be
any statement described in this section.
If the condition is true, statement-1 executes. If the condition is false,
statement-2 executes. If no ELSE clause is present, the statement following the IF
statement executes.
Example 12-25 on page 12-26 compares two arrays.
° INT
° STRING
° UNSIGNED(1-16)
• All address-typed variables except:
° CBADDR
° CWADDR
° PROCADDR
Move
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. With
PVU T9248AAD, you can move any variable up to the current maximum allowed size
for any object on a TNS/R platform of 127.5 megabytes.
A value parameter cannot be the target of a move statement.
destination :=
=:
&
constant
[ constant ]
constant-list
-> next-addr
VST051.vsd
destination
the identifier, with or without an index, of the variable to which the copy operation
begins. It can be a simple variable, array, simple pointer, structure, structure data
item, or structure pointer, but not a read-only array.
':='
specifies a left-to-right sequential move. It starts copying data from the leftmost
item in source.
'=:'
specifies a right-to-left sequential move. It starts copying data from the rightmost
item in source.
source
the identifier, with or without an index, of the variable from which the copy
operation begins. It can be a simple variable, array, read-only array, simple pointer,
structure, structure data item, or structure pointer.
count
is an unsigned INT arithmetic expression that defines the number of units in
source to copy. If you omit count-unit, the units copied (depending on the
nature of the source variable) are:
Source Variable Data Type Units Copied
Simple variable, array, simple pointer STRING Bytes
(including structure item) INT Words
INT(32) or REAL Doublewords
FIXED or REAL(64) Quadruplewords
Structure Not applicable Words
Substructure Not applicable Bytes
Structure pointer STRING Bytes
INT Words
count-unit
is the value BYTES, WORDS, or ELEMENTS. count-unit changes the meaning
of count from that described previously to the following:
BYTES Copies count bytes. If both source and destination have
word addresses, BYTES generates a word move for
(count + 1) / 2 words.
WORDS Copies count words. (WORDS is 16 bits)
ELEMENTS Copies count elements as follows (depending on the nature of
the source variable):
Source Variable Data Type Units Copied
Simple variable STRING Bytes
Array INT Words
INT(32) or REAL Doublewords
Simple pointer FIXED or REAL(64) Quadruplewords
(including structure
item)
Structure Not applicable Structure occurrences
Substructure Not applicable Substructure
occurrences
Structure Pointer STRING Structure occurrences
(STRING and INT INT
have meaning only
in group
comparison
expressions and
move statements.)
constant
is a numeric constant, a character string constant, or a LITERAL to copy.
If you enclose constant in brackets ([ ]) and if destination has a byte
address or is a STRING structure pointer, the system copies constant as a
single byte regardless of the size of constant. If you do not enclose constant
in brackets or if destination has a word address or is an INT structure pointer,
the system copies a word, doubleword, or quadrupleword as appropriate for the
size of constant.
constant-list
is a list of constants to copy. Specify constant-list in the form shown in
Section 3, Data Representation.
next-addr
is a variable to contain the location in destination that follows the last item
copied. The compiler returns a 16-bit or 32-bit address as described in “Usage
Considerations” that follows.
&
is the concatenation operator. It lets you move more than one source or
constant-list, each separated by the concatenation operator.
The following rules apply to using MOVE statements:
• A value parameter cannot be the target of a move statement.
• The compiler reports a warning if it can determine that there are more bytes in the
source of the move than in the destination of the move (see Destination Shorter
Than Source on page 12-32).
• Built-in routines, $FILL8, $FILL16, and $FILL32, fill an array with repetitions of the
same 8-bit, 16-bit, or 32-bit data, respectively (see $FILL8, $FILL16, and $FILL32
Statements on page 12-33).
Example 12-26 on page 12-31 copies spaces into the first five elements of an array
and then uses next-addr as destination to copy dashes into the next five
elements.
Example 12-27 on page 12-31 contrasts copying a bracketed constant with copying an
unbracketed constant. A bracketed constant copies a single byte regardless of the size
of the constant. An unbracketed constant copies words, doublewords, or
quadruplewords depending on the size of the constant.
For more information, see $FILL8, $FILL16 and, $FILL32 in Section 15, Built-In
Routines.
Variables (including structure data items) are byte addressed or word addressed as
follows:
Byte addressed • STRING simple variables
• STRING arrays
• Variables to which STRING simple pointers point
• Variables to which STRING structure pointers point
• Substructures
Word addressed • INT, INT(32), FIXED, REAL, or REAL(64) simple variables
• INT, INT(32), FIXED, REAL, or REAL(64) arrays
• Variables to which INT, INT(32), FIXED, REAL, or REAL(64)
simple pointers point
• Variables to which INT structure pointers point
• Structures
After a move, next-addr might point to the middle of an element, rather than to the
beginning of the element. If destination is word addressed and source is byte
addressed and you copy an odd number of bytes, next-addr will not point to an
element boundary.
RETURN
A RETURN statement causes a procedure or function 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.
• The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
result-expression and a cc-expression and has the procedure attribute
RETURNSCC on page 14-8. The reason for this warning is in Appendix D, RETURN,
RETURNSCC, and C/C++ on TNS/E.
RETURN
cc-expression
result-expression
, cc-expression
VST052.vsd
cc-expression
is an INT expression whose numeric value specifies the condition code value to
return to the caller:
Value of cc-expression The condition code is set to ...
Less than 0 Less than (<)
Equal to 0 Equal (=)
Greater than 0 Greater than (>)
result-expression
is an arithmetic or conditional expression that a function must return to the caller.
result-expression must be of the same return type as the data type specified
in the function header. The data type of a conditional expression is always INT.
Specify result-expression only when returning from a function.
If result-expression is any type except FIXED or REAL(64), a function can
return both result-expression and cc-expression.
Topics:
• Functions on page 12-35
• Procedures and Subprocedures on page 12-36
• Condition Codes on page 12-37
Functions
Every function must include at least one RETURN statement. The compiler does not
verify that every path through a function’s code includes a RETURN statement;
therefore, a function can reach the end of its code without executing a RETURN
statement. If this happens, the function returns zero.
Functions that return a condition code that is not based on the value returned by the
function must specify explicitly the condition code value to return to the function’s
caller.
Example 12-33. RETURN Statement That Returns a Value and a Condition Code
INT PROC p (i);
INT i;
BEGIN
RETURN i, i - max_val; ! Return a value and a condition code
END;
If you call a function, rather than calling it in an expression, you can test the returned
condition code, as Example 12-34 on page 12-35 does.
The procedure in Example 12-36 on page 12-37 returns a condition code that indicates
whether an add operation overflows.
Condition Codes
A procedure (but not a function) returns a condition code only if the procedure
declaration includes the RETURNSCC attribute. The compiler reports an error if a
procedure attempts to test the condition code after calling a procedure that does not
specify RETURNSCC.
Example 12-38 on page 12-37 is similar to Example 12-37 on page 12-37, but is
syntactically correct because p specifies RETURNSCC and returns a condition code
value.
Functions that do not specify RETURNSCC return a condition code that is based on
the numeric value returned by the function, regardless of the nature of the expression
in the RETURN statement.
Functions can return a condition code that is independent of the value returned by the
function, as follows:
• The function declaration must specify the RETURNSCC attribute.
• Each RETURN statement in the function must specify the value of the condition
code.
Note. The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
traditional function value and a condition code value. For details, see Appendix D, RETURN,
RETURNSCC, and C/C++ on TNS/E.
Note. The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
traditional function value and a condition code value. For details, see Appendix D, RETURN,
RETURNSCC, and C/C++ on TNS/E.
Note. The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
traditional function value and a condition code value. For details, see Appendix D, RETURN,
RETURNSCC, and C/C++ on TNS/E.
RSCAN UNTIL
-> next-addr
VST053.vsd
SCAN
indicates a left-to-right search.
RSCAN
indicates a right-to-left search.
variable
is the identifier, with or without an index, of a variable at which to start the scan.
The following restrictions apply:
• The variable can be a simple variable, array, read-only array, simple pointer,
structure pointer, structure, or structure data item.
• The variable can be of any data type but UNSIGNED.
• The variable cannot have extended indirection.
WHILE
specifies that the scan continues until a character other than test-char occurs
or until a 0 occurs. A scan stopped by a character other than test-char resets
$CARRY. A scan stopped by a 0 sets $CARRY.
UNTIL
specifies that the scan continues either until test-char occurs or until a 0
occurs. A scan stopped by test-char resets the hardware carry bit. A scan
stopped by a 0 sets the hardware carry bit.
test-char
is an INT arithmetic expression whose value is a maximum of eight significant bits
(one byte). A larger value might cause execution errors.
next-addr
is a 16-bit variable to contain the 16-bit byte address of the character that stopped
the scan, regardless of the data type of identifier.
Delimit the scan area with zeros; otherwise, a scan operation might continue to pass all
valid data if either:
• A SCAN UNTIL operation does not find a zero or the test character.
• A SCAN WHILE operation does not find a zero or a character other than the test
character.
To delimit the scan area, you can specify zeros as follows:
INT .buffer[-1:10] := [0," John James Jones ",0];
Example 12-45 on page 12-42 converts the word address of an INT array to a byte
address. The assignment statement stores the resulting byte address in a STRING
pointer. The SCAN statement then scans the bytes in the array until it finds a comma.
Topics:
• Determining What Stopped a Scan on page 12-42
• Extended Pointers on page 12-42
• Crossing Variable Boundaries on page 12-43
• P-Relative Arrays on page 12-43
If $CARRY is true after a SCAN UNTIL, the test character did not occur. If $CARRY is
true after SCAN WHILE, a character other than the test character did not occur.
To determine the number of multibyte elements processed, divide (next-addr '-' byte
address of identifier ) by the number of bytes per element using unsigned
arithmetic.
For more information about $CARRY, see Section 13, Hardware Indicators.
Extended Pointers
P-Relative Arrays
The address type of pointers in a SCAN statement that scans a P-relative array must
be CBADDR or CWADDR.
When the SCAN statement in Example 12-49 on page 12-44 completes, t_start
points to the first character in the third message, and t_end points immediately after
the last character in the third message. The object data type of t_start and t_end is
STRING; therefore, their address type is BADDR.
In Example 12-50 on page 12-44, the data type of t_start and of t_end is
CBADDR. The object data type of s is STRING. Its address type is CBADDR, not
BADDR; therefore, you can subtract @s from t_start because the data types of
both are CBADDR.
USE
The USE statement creates a temporary variable.
USE identifier
,
VST056.vsd
identifier
is the name of the temporary variable being created.
A temporary variable that the USE statement creates:
• Is equivalent to a variable declared INT
• Is usually kept in a register
• Exists until either:
WHILE
The WHILE statement is a pretest loop that repeatedly executes a statement while a
specified condition is true.
WHILE condition DO
statement
VST057.vsd
condition
is either:
• A conditional expression
• An INT, INT(32), or FIXED arithmetic expression. If the result of the arithmetic
expression is not 0, condition is true. If the result is 0, condition is false.
statement
is any pTAL statement.
The WHILE statement tests the condition before each iteration of the loop. If the
condition is false before the first iteration, the loop never executes.
The WHILE statement in Example 12-52 on page 12-46 increments index until a
nonalphabetic character occurs.
Topics:
• Managing Overflow Traps on page 13-1
• Hardware Indicators After Assignments on page 13-3
• Hardware Indicators in Conditional Expressions on page 13-8
• Nesting Condition Code Tests on page 13-12
• Using Hardware Indicators Across Procedures on page 13-14
The directives and attributes active when a pTAL statement is compiled determine the
overflow trapping state of the code that the compiler generates for that statement. A
procedure does not inherit the trapping state of its caller.
BEGIN
: ENABLE_OVERFLOW_TRAPS
DISABLE_OVERFLOW_TRAPS
VST682.vsd
$OVERFLOW
After every assignment statement, the compiler generates code that tests for overflow
if either:
• Overflow traps are enabled
• All of the following conditions are true:
$CARRY
You can test $CARRY if the root operator is one of the following:
• Signed integer addition or subtraction
INT i, j, k;
i := j + k; ! $CARRY can be tested after this statement
i := j - k; ! $CARRY can be tested after this statement
• Unsigned integer addition or subtraction
INT i, j, k;
i := j '+' k; ! $CARRY can be tested after this statement
i := j '-' k; ! $CARRY can be tested after this statement
• Unary minus
INT i;
i := -i; ! $CARRY can be tested after this statement
Condition Codes
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.
Topics:
• When Condition Codes Are Accessible on page 13-5
• When Condition Codes Are Not Accessible on page 13-5
° A 1-byte item:
STRING s;
INT i;
i := s; ! Condition code is not accessible
° A call to a built-in routine (for a list of these, see Table 15-1 on page 15-4):
i := $ABS(i); ! Condition code is not accessible
° An expression whose value is an address type (for example, WADDR or
EXTADDR):
INT i;
INT .p;
@p := @i; ! Right side is a WADDR value;
! condition code is not accessible
° An expression whose value is a floating-point data type [REAL or REAL(64)]:
REAL r := 1.0E0;
r := r + 1.0E0; ! Right side is a floating-point number;
! condition is code not accessible
° A constant or constant expression:
INT a;
a := 2 << 3; ! Right side is a constant expression;
! condition is code not accessible
• None of the exceptions in When Condition Codes Are Not Accessible on page 13-5
apply
° A STRING variable:
STRING s;
s := "a"; ! Condition code is not accessible
° An UNSIGNED(n) variable:
UNSIGNED(12) u;
u := %HFFF; ! Condition code is not accessible
° A global variable:
INT g;
PROC p;
BEGIN
INT i := 0;
g := i; ! Condition code is not accessible
END;
° A pointer:
INT .p;
INT i := 0;
p := i; ! Condition code is not accessible
° A variable containing indexing, field selection, or bit selection:
STRUCT s;
BEGIN
INT f;
END;
INT a[0:9];
INT i;
s.f := i; ! Field selection: condition code is
! not accessible
a[9] := i; ! Index: condition code is not accessible
i.<3:5> := a; ! Bit Selection: condition code is
! not accessible
Both the statement preceding the WHILE statement and the last statement in the
WHILE statement must set the condition code indicator. See Example 13-5 on
page 13-9.
You cannot:
• Reference a hardware indicator in an expression other than in the conditional
expression of an IF statement
INT i;
i := IF < THEN -i ELSE i; !ERROR: invalid in IF expression
• Assign the value of a hardware indicator to a variable in an assignment statement
INT i;
i := >; ! ERROR: invalid in assignment statement
• Pass a hardware indicator as an actual parameter to a procedure
INT i;
CALL p( < ); ! ERROR: invalid as parameter
The first statement in an IF statement’s THEN clause or ELSE clause (or both) can, in
turn, be an IF statement that tests the condition code established by the conditional
expression of the containing IF statement. In this case, the root operator in the
containing IF statement’s conditional expression must be either:
• A relational operator
i := i + 1;
IF i >= 0 THEN ! OK: >= is a relational operator
IF > THEN ...
• An expression that consists only of a condition code
i := i + 1;
IF >= THEN ! OK: >= is a condition code
IF > THEN...
An IF statement that tests a hardware indicator cannot be labeled.
Procedure Declarations
A procedure is a program unit that is callable from anywhere in the program. You
declare a procedure as follows:
PROC identifier
type public-name-spec
parameter-list proc-attribute
,
proc-body ;
param-spec ; EXTERNAL
FORWARD
VST058.vsd
type
specifies that the procedure is a function that returns a result and indicates the
data type of the returned result. type can be any data type described in
Section 3, Data Representation.
identifier
is the procedure identifier to use in the compilation unit.
public-name-spec
VST209.vsd
public-name
is the procedure name to use in the linker, not in the compilation unit. The
default public-name is identifier . public-name must conform to the
identifier rules of the language in which the external procedure is written. For all
languages except HP C, the compiler upshifts public-name automatically.
If a procedure declaration includes public-name-spec, it must also include
EXTERNAL on page 14-4.
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. The
actual parameter is the identifier of a STRING array or simple pointer
declared inside or outside a structure.
length
is the identifier of a directly addressed INT simple variable. The actual
parameter is an INT expression that specifies the length of string, in
bytes.
proc-attribute
is a procedure attribute, as described in Procedure Attributes on page 14-5.
param-spec
specifies the parameter type of a formal parameter and whether it is a value or
reference parameter, as described in Formal Parameter Specification on
page 14-10.
proc-body
is a BEGIN-END block that contains local declarations and statements, as
described in Procedure Body on page 14-17.
FORWARD
specifies that the procedure body is declared later in the compilation.
EXTERNAL
specifies that the procedure body is either declared in another compilation unit or
later in this compilation unit.
Procedure Attributes
Procedures can have the following attributes:
MAIN
INTERRUPT
RESIDENT
CALLABLE
PRIV
VARIABLE
EXTENSIBLE
( count )
RETURNSCC
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
LANGUAGE C
COBOL
FORTRAN
PASCAL
UNSPECIFIED
VST635.vsd
MAIN
causes the procedure to execute first when you run the program. When the MAIN
procedure completes execution, it passes control to the PROCESS_STOP_
system procedure, rather than executing an EXIT instruction.
If more than one procedure in a compilation has the MAIN attribute, the compiler
emits a warning and uses the first main procedure it sees as the main procedure.
For example, in the following source code, procedures main_proc1 and
main_proc2 have the MAIN attribute, but in the object file only main_proc1 has
the MAIN attribute:
PROC main_proc1 MAIN; ! This MAIN procedure is MAIN
BEGIN ! in the object file
CALL this_proc;
CALL that_proc;
END;
PROC main_proc2 MAIN; ! This MAIN procedure is not MAIN
BEGIN ! in the object file
CALL some_proc;
END;
INTERRUPT
causes the pTAL compiler to generate an interrupt exit instruction instead of an
EXIT instruction at the end of execution. Only operating system interrupt handlers
use the INTERRUPT attribute. An example is:
PROC int_handler INTERRUPT;
BEGIN
! Do some work
END;
RESIDENT
causes procedure code to remain in main memory for the duration of program
execution. The operating system does not swap pages of this code. The linker
allocates storage for RESIDENT procedures as the first procedures in the code
space. An example is:
PROC res_proc RESIDENT;
BEGIN
! Do some work
END;
CALLABLE
authorizes a procedure to call a PRIV procedure (described next). Nonprivileged
procedures can call CALLABLE procedures, which can call PRIV procedures.
Thus, nonprivileged procedures can only access PRIV procedures indirectly by first
calling CALLABLE procedures. Normally, only operating system procedures have
the CALLABLE attribute. In the following example, a CALLABLE procedure calls
the PRIV procedure declared next:
PROC callable_proc CALLABLE;
BEGIN
CALL priv_proc;
END;
PRIV
means the procedure can execute privileged instructions. Only PRIV or CALLABLE
procedures can call a PRIV procedure. Normally, only operating system
procedures have the PRIV attribute. PRIV protects the operating system from
unauthorized (nonprivileged) calls to its internal procedures.
The following PRIV procedure is called by the preceding CALLABLE procedure:
PROC priv_proc PRIV;
BEGIN
! Privileged instructions
END;
For information about privileged mode, see Privileged Mode on page 15-1.
VARIABLE
means the compiler treats all parameters of the subprocedure as if they are
optional, even if some are required by your code. If you add parameters to the
VARIABLE subprocedure declaration, all procedures that call it must be
recompiled. The following example declares a VARIABLE subprocedure:
SUBPROC v (a, b) VARIABLE;
INT a, b;
BEGIN
! Lots of code
END;
When you call a VARIABLE subprocedure, the compiler allocates space in the
parameter area for all the parameters. The value of the data for a missing
parameter is unspecified.
EXTENSIBLE
lets you add new parameters to the procedure declaration without recompiling its
callers. The compiler treats all parameters of the procedure as if they are optional,
even if some are required by your code. The following example declares an
EXTENSIBLE procedure:
PROC x (a, b) EXTENSIBLE;
INT a, b;
BEGIN
! Do some work
END;
When you call an EXTENSIBLE procedure, the compiler allocates space in the
parameter area for all the parameters. The values of missing parameters are
unspecified.
Declare procedures EXTENSIBLE, but not subprocedures.
count
converts a VARIABLE procedure to an EXTENSIBLE procedure. The count
value is the number of formal parameters in the VARIABLE procedure that you
are converting to EXTENSIBLE. For the count value, specify an INT value in
the range 1 through 15.
RETURNSCC
causes a procedure to return a condition code. The compiler reports an error if a
procedure attempts to test the condition code after calling a procedure that does
not specify RETURNSCC. Procedures declared with RETURNSCC cannot return
64-bit values.
Note. The EpTAL compiler issues a warning if a procedure that has this attribute returns
both a traditional function value and a condition code value by means of RETURN on
page 12-34. The reason for this warning is in Appendix D, RETURN, RETURNSCC, and
C/C++ on TNS/E.
OVERFLOW_TRAPS
enables overflow traps for a procedure.
NOOVERFLOW_TRAPS
disables overflow traps for a procedure.
LANGUAGE
specifies that the external routine is an HP C, HP COBOL, FORTRAN, or Pascal
routine. If you do not know if the external routine is an HP C, HP COBOL,
FORTRAN, or Pascal routine, use LANGUAGE UNSPECIFIED. The following
example shows the LANGUAGE COBOL option and a public name "a_proc" (in
HP COBOL identifier format):
PROC a_proc = "a-proc" (a, b, c) ! EXTERNAL declaration for
LANGUAGE COBOL; ! HP COBOL procedure
STRING .a, .b, .c;
EXTERNAL;
Specify no more than one LANGUAGE attribute in a declaration.
Note. Because no FORTRAN or Pascal compilers exist especially for TNS/R or TNS/E
architecture, LANGUAGE FORTRAN and LANGUAGE PASCAL have no meaning on
TNS/R or TNS/E architecture.
param-type
param-name
.
.EXT
.SG
.SGX
( referral )
REFALIGNED ( 2 )
VST636.vsd
param-type
is the parameter type of the formal parameter and can be one of the following:
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
STRUCT
BADDR
WADDR
EXTADDR
PROCADDR
CBADDR
CWADDR
SGBADDR
SGWADDR
SGXBADDR
SGXWADDR
PROC
type
VST637.vsd
Descriptions for STRUCT, PROC, PROC(32), and type, are included below. You
can find descriptions of the remaining data types in Section 3, Data
Representation.
STRUCT
means the parameter is one of:
• A standard indirect or extended indirect definition structure (not supported
in future software platforms)
• A standard indirect or extended indirect referral structure
PROC
is the address of the entry point of a procedure. You must assign PROC to a
PROCPTR before you can call it.
type
specifies that the parameter is a function procedure, the return value of which
is one of the following data types:
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
VST214.vsd
width
is a constant expression that specifies the number of bits in the variable.
The result of the constant expression must be one of the following values:
Data Type width
INT 16, 32, or 64
REAL 32 or 64
UNSIGNED A value in the range 1 through 31
fpoint
is an integer in the range -19 through 19 that specifies the implied decimal
point position. The default is 0 (no decimal places). A positive fpoint
specifies the number of decimal places to the right of the decimal point. A
negative fpoint specifies a number of integer places to the left of the
decimal point.
*
prevents scaling of the fpoint of a FIXED actual parameter to match the
fpoint in the parameter specification. Such scaling might cause loss of
precision. The called procedure treats the actual parameter as having an
fpoint of 0.
.
.EXT
.SG
.SGX
are indirection symbols (see Indirection Symbols on page 2-7). If present, the
parameter is passed by reference; if absent, the parameter is passed by value.
Specify reference parameters for actual parameters that will be:
• Arrays
• Structures
• Simple variables (when you want to update the original value in the caller’s
scope)
param-name
is the identifier of a formal parameter. The identifier has local scope if declared in a
procedure or sublocal scope if declared in a subprocedure.
referral
is the identifier of a previously declared structure or structure pointer. The diagram
under param-type describes lists the kind parameter requiring a referral.
REFALIGNED
For simple pointers, the default for REFALIGNED is the value you specify in the
REFALIGNED on page 17-53.
2
specifies that the variables and structures that identifier references are aligned as
they would be aligned in TAL (and might not be well-aligned in pTAL).
8
specifies that the variables and structures are well-aligned in pTAL (and in TAL,
that they might have more space).
For nonstructure pointers, the default for REFALIGNED is the value you specify in
the REFALIGNED on page 17-53.
When a procedure is called, each actual parameter is bound to its corresponding
formal parameter. Parameters passed by value must follow the same rules for
assignment compatibility as do assignment statements. Each actual value parameter
corresponds to the right side of an assignment statement.
Table 14-1 on page 14-14 lists the characteristics that you can declare in a formal
parameter specification depending on the kind of actual parameter the procedure or
subprocedure expects.
In Example 14-3 on page 14-15, the compiler treats var1 as if it were a simple
variable and treats var2 as if it were a simple pointer.
Topics:
• Using STRUCT as a Formal Parameter on page 14-16
• Passing an .EXT Parameter to a Non-EXTENDED Reference Parameter on
page 14-16
• Using the PROC Formal Parameter on page 14-16
• Referencing Parameters on page 14-16
Referencing Parameters
Do not depend on the order in which parameters are allocated in memory. You must
refer to each parameter only as a named entity. Do not refer to one parameter as a
base off of which you reference other parameters.
Guidelines:
• Do not treat a procedure’s formal parameters as an implied array or implied
structure.
• Do not index a parameter to access another parameter or local variable.
• Do not perform block moves in which the source or destination spans more than
one parameter.
• Do not pass the address of a value parameter to another procedure that expects
the address of an array or structure.
• Do not proceed through a parameter list using indexing and address calculations.
Procedure Body
A procedure body can contain local declarations, subprocedure declarations, and
statements.
BEGIN
local-decl subproc-decl
; ;
END
statement
VST061.vsd
local-decl
is a declaration for one of:
• simple variable
• array (direct, indirect, or read-only)
• structure (direct or indirect)
• simple pointer
• structure pointer
• equivalenced variable
• LITERAL
• DEFINE
• label
• entry point
• FORWARD subprocedure
subproc-decl
is a subprocedure declaration, as described in Subprocedure Declarations on
page 14-19.
statement
is any statement described in Section 12, Statements.
Subprocedure Declarations
You can declare subprocedures within procedures, but not within subprocedures.
SUBPROC identifier
type parameter-list
VARIABLE
RETURNSCC
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
subproc-body ;
parameter-spec ; FORWARD
VST702.vsd
type
specifies that the subprocedure is a function that returns a result and indicates the
data type of the returned result. type can be any data type described in
Section 3, Data Representation.
identifier
is the identifier of the subprocedure.
parameter-list
( param-name )
param-pair
,
VST210.vsd
param-name
is the identifier of a formal parameter. The number of formal parameters a
subprocedure can have is limited by space available in the parameter area of
the subprocedure.
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. The
actual parameter is the identifier of a STRING array or simple pointer
declare inside or outside a structure.
length
is the identifier of a directly addressed INT simple variable. The actual
parameter is an expression that specifies the length of string in bytes.
VARIABLE
specifies that the compiler treats all parameters as optional, even if some are
required by your code.
RETURNSCC
causes a subprocedure to return a condition code. The compiler reports an error if
a subprocedure attempts to test the condition code after calling a subprocedure
that does not specify RETURNSCC. Subprocedures declared with RETURNSCC
cannot return 64-bit values.
OVERFLOW_TRAPS
enables overflow traps for a subprocedure.
NOOVERFLOW_TRAPS
disables overflow traps for a subprocedure.
parameter-spec
specifies the parameter type of a formal parameter and whether it is a value or
reference parameter, as described in Formal Parameter Specification on
page 14-10.
subproc-body
is a BEGIN-END block that contains sublocal declarations and statements—see
Subprocedure Body on page 14-21.
FORWARD
means the subprocedure body is declared later in this procedure.
Subprocedure Body
A subprocedure body can contain sublocal declarations and statements.
BEGIN END ;
sublocal-decl statement
; ;
VST062.vsd
sublocal-decl
is a declaration for one of:
• simple variable
• array (direct or read-only)
• structure (direct only)
• simple pointer
• structure pointer
• equivalenced variable
• LITERAL
• DEFINE
• label
• entry point
statement
is any statement described in Section 12, Statements.
In subprocedures, declare pointers and directly addressed variables only. Here are
examples:
Sublocal Variable Example
Simple variable INT var;
(always direct)
Direct array INT array[0:5];
Read-only array INT ro_array = 'P' := [0,1,2,3,4,5];
Simple variable INT var;
(always direct)
Direct array INT array[0:5];
Read-only array INT ro_array = 'P' := [0,1,2,3,4,5];
Entry-Point Declarations
The entry-point declaration associates an identifier with a secondary location in a
procedure or subprocedure where execution can start.
ENTRY identifier ;
VST195.vsd
identifier
is an entry-point identifier to be placed in the procedure or subprocedure body. It is
an alternate or secondary point in the procedure or subprocedure at which to start
executing.
Topics:
• Procedure Entry-Point Identifiers on page 14-23
• Subprocedure Entry-Point Identifiers on page 14-24
Procedure Pointers
Procedure pointers allow a program to call a variable dynamically or to call an
EXTENSIBLE procedure.
The syntax of procedure pointers is similar to the syntax of forward procedures;
however, instead of the keyword PROC, you declare a procedure pointer using the
keyword PROCPTR. As with a forward procedure, a procedure pointer fully specifies
the procedure’s attributes and formal parameters but has no body—a procedure
pointer does not include executable statements.
You can declare procedure pointers as:
• Variables
• Formal parameters
• Structure fields
PROCPTR procptr-name
return-type
formal-param-names attributes ;
VST600.vsd
return-type
specifies that the procedure is a function that returns a result and indicates the
data type of the returned result, and can be any of:
• BADDR
• CBADDR
• CWADDR
• EXTADDR
• FIXED
• FIXED [(scale )]
• INT
• REAL
• REAL(64)
• PROCADDR
• SGWADDR
• SGBADDR
• SGXWADDR
• SGXBADDR
• STRING
• UNSIGNED (width )
• WADDR
scale
is a constant integer expression from -19 to 19.
width
is a constant integer expression from 1 to 31.
procptr-name
is the name of the procedure pointer.
formal-param-names
is the identifier of a formal parameter. A procedure can have up to 32 formal
parameters, with no limit on the number of words of parameters and has the form:
( param-name )
param-pair
,
VST210.vsd
param-name
is the identifier of a formal parameter. A procedure can have up to 32 formal
parameters, with no limit on the number of words of 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. The
actual parameter is the identifier of a STRING array or simple pointer
declared inside or outside a structure.
length
is the identifier of a directly addressed INT simple variable. The actual
parameter is an INT expression that specifies the length of string in
bytes.
attributes
is an attribute described in Procedure Attributes on page 14-5.
formal-param-spec
is a formal parameter and has the following form:
procptr
param-type identifier
.EXT
.SG
.SGX
( referral )
,
VST712.vsd
procptr
is a pointer identifier.
param-type
is any data type described in the data-type parameter of this syntax
description.
.
.EXT
.SG
.SGX
are indirection symbols (see Indirection Symbols on page 2-7). If present, the
parameter is passed by reference; if absent, the parameter is passed by value.
identifier
is an identifier (as described in Identifiers on page 2-8).
referral
is the name of a previously declared structure or structure pointer. You must
include referral if the formal parameter identifier is the name of a
structure.
Topics:
• Declaring PROCPTR Variables on page 14-29
• Declaring PROCPTR in Structures on page 14-30
• Declaring PROCPTRs as Formal Parameters on page 14-32
• Assignments to PROCPTRs on page 14-33
• Dynamically Selected Procedure Calls on page 14-35
procptr = prev-identifier ;
:= procaddr
VST714.vsd
procptr
is a pointer identifier.
prev-identifier
is the identifier of a previously declared variable. On TNS architecture, prev-
identifier must be 16 bits. On TNS/R and TNS/E architecture, prev-
identifier must be 32 bits or more.
procaddr
is a constant or dynamic expression of type PROCADDR. procaddr must be the
name of a procedure, procedure pointer, or PROCADDR variable. If procaddr is
a procedure or procedure pointer, the parameters of procptr and procaddr
must match and the following procedure attributes must match: EXTENSIBLE,
VARIABLE, RETURNSCC, MAIN, and INTERRUPT; the following procedure
attributes do not have to match: OVERFLOW_TRAPS, CALLABLE, PRIV, and
RESIDENT.
You can declare a PROCPTR anywhere a data declaration is valid. For purposes of
declarations, PROCPTRs are treated as data, not as procedures.
The address type of a PROCPTR is PROCADDR.
The address type of a PROCADDR variable is WADDR.
The object data type of a reference to a function PROCPTR is the data type returned
by the PROCPTR.
You can equivalence a PROCPTR to any previously declared variable provided that
the width of the previous variable is greater than or equal to the width of the
PROCPTR.
procptr ;
= prev-identifier
VST715.vsd
procptr
is a pointer identifier.
previous-identifier
The identifier of a field at the same level as procptr in the same structure.
Example 14-13 on page 14-31 declares a REAL PROCPTR as a field in a structure
array of 10 elements. Use an index to reference elements of array s1:
CALL s1[3].f(3.0e1);
The code in Example 14-15 on page 14-31 uses the structure s2 in Example 14-14 on
page 14-31.
Example 14-15. Code That Uses the Structure in Example 14-14 on page 14-31
STRUCT s(s2);
REAL my_real;
INT my_index := type_int;
CASE my_index OF
BEGIN
type_real -> my_real := s.f(3.0E1);
type_int -> my_real := s.g(3);
type_fixed -> my_real := s.h(3F);
END;
Assignments to PROCPTRs
You can assign values to a PROCPTR variable in much the same way as you assign
values to any variable; however, only values of data type PROCADDR can be
assigned to a PROCPTR.
You can assign the following items to a PROCPTR:
• The address of a procedure or function
• The value of another PROCPTR
• The value of a variable whose data type is PROCADDR
Assignment statements involving PROCPTRs fall into one of two categories:
• If the left side is a PROCPTR and right side is an @ character followed by the
name of a procedure, subprocedure, or function—that is, neither the left side nor
the right side is a PROCADDR variable—the attributes and the formal parameter
types of each side of the assignment must match. The attributes specified must be
the same but do not have to be presented in the same order.
• If either the left side or the right side of the assignment statement is a PROCADDR
variable, the compiler does not attempt to match attributes or parameter types.
Once you have set up a PROCPTR to point to a procedure, you can call the procedure
by using the PROCPTR name in a CALL statement or, if the PROCPTR is typed, in an
expression:
CALL a(1, 2);
r := d(r);
IF (s1[i].f(r)) < 1.0E0 THEN ...
Although you cannot create an array of PROCPTRs, you can create a structure that
includes a PROCPTR field. You can choose dynamically which PROCPTR in the
structure array to call.
You must initialize the array s1 to hold the addresses of the procedures that you want
to dynamically call, as in the following example:
@s1[dev_6530].d := @device_6530;
@s1[dev_3270].d := @device_3270;
@s1[dev_dove].d := @device_dove;
Use an index to choose which element of array s1 to call, as in the following example:
CALL s1[dev_6530].d(80, 2);
Labels in Procedures
A label is the target location of a GOTO statement.
LABEL identifier ;
,
VST196.vsd
identifier
is as described in Identifiers on page 2-8. It cannot be an entry-point identifier.
The following guidelines apply:
• LABEL is not a valid data type for a formal procedure parameter. You cannot pass
a label to a procedure.
• 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, before the subprocedure that contains the GOTO statement (see
Nonlocal on page 12-24).
Built-in routine calls whose results do not depend on the values of variables (such as
$LEN(n ) or $INT(10D)) can be used wherever constant values are allowed.
The syntax descriptions in this section use these terms:
Term Definition
sINT Signed 16-bit integer. Range is -32,768 through 32,767.
uINT Unsigned 16-bit integer. Range is 0 through 65,535. Must be an INT variable, not
a STRING or UNSIGNED variable.
word 16-bit word unless otherwise specified
“sINT” and “uINT” are not pTAL data types. This section uses them only to specify how
built-in routines use INT parameters.
Privileged Mode
Many built-in routines can be executed only by processes running in privileged mode.
Routines that operate in privileged mode can:
• Call other routines that operate in privileged mode
• Perform privileged operations by means of calls to system procedures
• Execute privileged instructions that can affect other programs or the operating
system
• Use system global pointers and 'SG' equivalencing to:
° Access system tables (which are described in the system description manual
for your system)
° Compare and move data between the system data area and the user data area
Routines that operate in privileged mode must be specially licensed, because they
might (if improperly written) adversely affect the status of the processor in which they
are running.
The following execute in privileged mode:
• CALLABLE procedures (that is, procedures declared with the attribute CALLABLE
on page 14-6)
• PRIV procedures (that is, procedures declared with the attribute PRIV on
page 14-6)
• Nonprivileged procedures that are called by CALLABLE or PRIV procedures
• pTAL Privileged Routines on page 15-11
Parameters
Parameters of built-in routines are always passed by value.
Topics:
• Addresses as Parameters on page 15-2
• Expressions as Parameters on page 15-3
Addresses as Parameters
If a parameter of a built-in routine is an address, the address must have the correct
address type—whether the parameter is an input parameter, an output parameter, or
both.
In Example 15-1 on page 15-2, the built-in routine $BUILT_IN_1 has one formal
parameter whose data type is BADDR. The corresponding actual parameter must be
either a BADDR variable or the address field of a STRING pointer.
Expressions as Parameters
Many built-in routines accept expressions as parameters (see their individual syntax
descriptions). If a parameter of a built-in routine is an expression:
• The value of the expression can be any data type except STRING or UNSIGNED.
• Except in INT and INT(32) expressions, all operands must be of the same data
type.
• An INT expression can include STRING, INT, and UNSIGNED(1-16) operands.
The system treats STRING and UNSIGNED(1-16) operands as if they were 16-bit
values; that is, the system:
° Places a STRING operand in the right byte of a word and sets the left byte to
0.
° Places an UNSIGNED(1-16) operand in the right bits of a word and sets the
unused left bits to 0.
• An INT(32) expression can include INT(32) and UNSIGNED(17-31) operands.
The system treats UNSIGNED(17-31) operands as if they were 32-bit values.
Before evaluating the expression, the system places an UNSIGNED(17-31)
operand in the right bits of a doubleword and sets the unused left bits to 0.
• The built-in routine, not the expression or its data type, determines whether the
value of the parameter is signed or unsigned:
° Built-in routines that expect signed arguments treat unsigned expressions as if
they were signed.
Hardware Indicators
The description of each built-in routine specifies which hardware indicators (condition
code, $CARRY, and $OVERFLOW) the built-in routine sets. If the description does not
specify the conditions for which the built-in routine sets the value of a hardware
indicator, see the system description manual for your system.
If a built-in routine does not set a particular hardware indicator, then the value of that
hardware indicator is undefined after the built-in routine completes. If you reference a
hardware indicator when its value is undefined, the 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. If overflow traps are disabled, you
must test $OVERFLOW explicitly in your program.
For general information about hardware indicators, see Section 13, Hardware
Indicators.
Atomic Operations
The built-in routines in Table 15-1 on page 15-4 perform atomic operations. No other
process can access the memory referenced by an atomic operation until the atomic
operation completes; for example, $ATOMIC_ADD is equivalent to the following
algorithm:
var := var + value;
After the atomic operation reads var, no other process can access the memory
location associated with var until the read completes. The read, add, and store
operations are performed without interruption, as if the three operations were one.
$ATOMIC_ADD
$ATOMIC_ADD atomically adds two INT values.
VST607.vsd
var input,output
sINT:variable
is the variable that $ATOMIC_ADD increments.
value input
sINT:value
is the value $ATOMIC_ADD adds to var.
$ATOMIC_ADD performs the following operation:
var := var + value
The read, add, and store operations are performed without interruption, as if the three
operations were one.
$ATOMIC_AND
$ATOMIC_AND performs an atomic LAND on two INT values.
VST608.vsd
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.
$ATOMIC_AND performs the following operation:
var := var LAND mask
The read, LAND, and store operations are performed without interruption, as if the
three operations were one.
$ATOMIC_DEP
$ATOMIC_DEP atomically deposits bits into an INT variable.
value ) ;
VST609.vsd
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.
$ATOMIC_DEP stores into each bit position of var. The corresponding bit in
value after performing an “and” operation between the corresponding bits in
value and mask.
value input
INT:value
holds the bits that, after being masked, $ATOMIC_DEP deposits in var.
$ATOMIC_DEP performs the following operation:
var := (var LAND $COMP(mask)) LOR (value LAND mask)
All the operations are performed without interruption, as if they were one.
$ATOMIC_GET
$ATOMIC_GET atomically gets (returns) the value of a variable.
$ATOMIC_GET ( var ) ;
VST610.vsd
var input
type:variable
is the variable whose value $ATOMIC_GET returns. var must be one of:
• A well-aligned byte, 2-byte, or 4-byte variable whose address is an integral
multiple of its width.
• A bit field fully contained in a 1-byte, 2-byte, or 4-byte variable that is
aligned on an even-byte boundary.
If var is not well aligned, an error occurs.
The operation is performed without interruption.
$ATOMIC_OR
$ATOMIC_OR performs an atomic LOR on two INT values.
VST611.vsd
var input,output
INT:variable
is the variable to which $ATOMIC_OR applies mask.
mask input
INT:value
is a 16-bit mask that $ATOMIC_OR applies to var.
$ATOMIC_OR performs the following statement:
var := var LOR mask
The read, LOR, and store operations are performed without interruption, as if the three
operations were one.
$ATOMIC_PUT
$ATOMIC_PUT atomically puts a value into a variable.
VST612.vsd
var output
type:variable
the variable into which $ATOMIC_PUT stores value. var must be one of:
• A 1-byte, 2-byte, or 4-byte variable whose address is an integral multiple of
its width.
• A bit field fully contained in a 1-byte, 2-byte, or 4-byte variable that is
aligned on an even-byte boundary.
value input
type:value
the value $ATOMIC_PUT stores in var. value must be assignment-
compatible with var.
$ATOMIC_PUT performs the following action:
var := value
Nonatomic Operations
• pTAL Privileged Routines on page 15-11
• Type-Conversion Routines on page 15-12
• Address-Conversion Routines on page 15-14
• Character-Test Routines on page 15-14
• Minimum and Maximum Routines on page 15-15
• Arithmetic Routines on page 15-15
• Carry and Overflow Routines on page 15-15
• FIXED-Expression Routines on page 15-15
• Variable-Characteristic Routines on page 15-16
• Procedure-Parameter Routines on page 15-16
• Miscellaneous Routines on page 15-16
Table 15-13 on page 15-17 lists the built-in routines for nonatomic operations
alphabetically and shows which hardware indicators they can can set.
Type-Conversion Routines
A type-conversion routine converts its argument or arguments from one data type to
another data type.
Type-conversion routines that convert an argument from a smaller data type to a larger
data type, such as $DFIX, perform a sign extension of the expression to the high bits.
Type-conversion routines whose names end in R, such as $DBLR, round their results.
All other type-transfer routines truncate their results.
Type-conversion routines round values as follows:
(IF value < 0 THEN value − 5 ELSE value + 5) / 10
That is:
1. If value is negative, 5 is subtracted; if value is positive, 5 is added.
2. Integer division by 10 truncates the result; therefore, if the absolute value of the
least significant digit of the result after initial truncation is 5 or more, one is added
to the absolute value of the final least significant digit.
Rounding has no effect on INT, INT(32), or FIXED expressions.
Address-Conversion Routines
An address-conversion routine converts one address type to another address type.
The pTAL privileged routine $AXADR on page 15-26, supported only by the pTAL
compiler, is also an address-conversion routine.
Character-Test Routines
A character-test routine tests the right byte of an INT value for an alphabetic, numeric,
or special character, returning a true value if the character is there and a false value
otherwise.
Arithmetic Routines
FIXED-Expression Routines
Variable-Characteristic Routines
Variable-characteristic routines return INT values that represent various characteristics
of variables.
Procedure-Parameter Routines
Miscellaneous Routines
$ABS
$ABS returns the absolute value of its argument. The returned value has the same
data type as the argument.
$ABS ( expression )
VST072.vsd
expression
is an expression (as described in Section 5, Expressions).
If the absolute value of a negative INT, INT(32), or FIXED expression cannot be
represented in two’s complement form (for example, if expression has the INT
value -32,768), $ABS traps if overflow traps are enabled (see Section 13, Hardware
Indicators); otherwise, $ABS ignores the problem.
$ALPHA
$ALPHA tests the right byte of an INT value for the presence of an alphabetic
character.
$ALPHA ( int-expression )
VST073.vsd
int-expression
is an INT expression.
$ALPHA inspects bits <8:15> of int-expression and ignores bits <0:7>. It tests for
an alphabetic character according to the following criteria:
int-expression >= "A" AND int-expression <= "Z" OR
int-expression >= "a" AND int-expression <= "z"
If an alphabetic character occurs, $ALPHA sets the condition code indicator to CCE
(condition code equal to). If you plan to check the condition code, do so before an
arithmetic operation or assignment occurs.
If the character passes the test, $ALPHA returns a -1 (true); otherwise, it returns a 0
(false).
int-expression can include STRING and UNSIGNED(1-16) operands, as
described in “Expression Arguments” at the beginning of this section.
$ASCIITOFIXED
$ASCIITOFIXED converts an ASCII value to a FIXED value.
VST606.vsd
bufferaddr input,output
BADDR:variable
is the byte address from which $ASCIITOFIXED reads ASCII digits. When
$ASCIITOFIXED completes, bufferaddr contains the address following the
last byte read.
maxdigits input
uINT:value
is the maximum number of ASCII digits to read from bufferaddr.
remainingdigits output
uINT:variable
is the number of bytes that $ASCIITOFIXED did not convert because it
encountered a nonnumeric ASCII byte. remainingdigits must be an INT
variable; it cannot be a STRING, UNSIGNED, or USE variable or a bit field.
qvaluein input
FIXED(*):value
is a value that $ASCIITOFIXED adds to the result of converting the bytes at
bufferaddr. $ASCIITOFIXED multiplies 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.
qvalueout output
FIXED(*):variable
is a quadrupleword integer value that holds the final result of the conversion.
$ASCIITOFIXED converts a string of ASCII-coded digits at bufferaddr to a binary-
coded FIXED value, adds qvaluein times 10n, where n is the number of digits
converted, and stores the result in qvalueout.
If a nondigit ASCII code is encountered, $ASCIITOFIXED ends the conversion.
$ASCIITOFIXED converts only the digits before the nondigit ASCII code. CCG
indicates that $ASCIITOFIXED converted only part of the ASCII number. CCE
indicates $ASCIITOFIXED converted the entire string. If overflow traps are enabled
and the result is greater than 263-1 or less than 263, $ASCIITOFIXED sets
$OVERFLOW and qvalueout is undefined.
$AXADR
Note. The EpTAL compiler does not support this routine. (The EpTAL compiler does allow
$AXADR as a DEFINE name.)
$AXADR ( variable )
VST116.vsd
variable
is the identifier of a simple variable, pointer, array element, structure, or structure
data item.
If variable is a pointer, $AXADR returns the absolute extended address of the item
to which the pointer points, not the address of the pointer itself.
$BADDR_TO_EXTADDR
$BADDR_TO_EXTADDR converts a BADDR address to an EXTADDR address.
$BADDR_TO_EXTADDR ( expression )
VST683.vsd
expression
is an expression whose value is a BADDR address.
$BADDR_TO_WADDR
$BADDR_TO_WADDR converts a BADDR address to a WADDR address.
$BADDR_TO_WADDR ( expression )
VST684.vsd
expression
is an expression whose value is a BADDR address.
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.
$BITLENGTH
$BITLENGTH returns an INT value that is the length, in bits, of a variable.
$BITLENGTH ( variable )
VST074.vsd
variable
is the identifier of a simple variable, array element, pointer, structure, or structure
data item.
$BITLENGTH returns the length, in bits, of a single occurrence of a simple variable,
array element, structure, structure item, or item to which a pointer points.
The length of a structure or substructure occurrence is the sum of the lengths of all
items contained in the structure or substructure. Complete the structure before you use
$BITLENGTH to obtain the length of any of the items in the structure.
To compute the total number of bits in an entire array or substructure, multiply the
value returned by $BITLENGTH by the value returned by $OCCURS. To compute the
total number of bits in a structure, first round up the value returned by $BITLENGTH to
the word boundary and then multiply the rounded value by the value returned by
$OCCURS.
You can use $BITLENGTH in LITERAL expressions and global initializations, because
it always returns a constant value.
$BITOFFSET
$BITOFFSET returns an INT value that is the offset, in bits, of a structure data item
from the address of the zeroth structure occurrence.
$BITOFFSET ( variable )
VST075.vsd
variable
is the fully qualified identifier of a structure item.
The zeroth structure occurrence has an offset of 0. For items other than substructure,
simple variable, array, or pointer declared within a structure, $BITOFFSET returns a 0.
When you qualify the identifier of variable, you can use constant indexes but not
variable indexes; for example:
$BITOFFSET (struct1.subst[1].item) !1 is a constant index
To find the offset of an item in a structure, complete the structure before you use
$BITOFFSET.
You can use $BITOFFSET in LITERAL expressions and global initializations, because
it always returns a constant value.
$CARRY
$CARRY 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
The value returned by $CARRY is based on instructions emitted by the compiler that
determine whether a carry occurred. $CARRY returns -1 if a carry occurred, 0
otherwise.
Procedures cannot return $CARRY.
You can test $CARRY only after one of the following statements:
• An assignment statement in which the final operator executed in the expression on
the right side of the assignment is one of the following:
$CHECKSUM
$CHECKSUM returns the checksum of data.
wordcount ) ;
VST613.vsd
checksum input,output
uINT:variable
the initial value (“seed” value) of the checksum. When $CHECKSUM
completes, checksum holds the final checksum. checksum must be an INT
variable. It cannot be a STRING, UNSIGNED, or USE variable or a bit field.
bufferaddr input
EXTADDR:value
the address of the first 16-bit word to include in the checksum.
wordcount input
uINT:value
the number of 16-bit words to include in the checksum.
$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 bufferaddr is unchanged.
$COMP
$COMP returns the one’s complement of its argument.
$COMP ( int-expression )
VST077.vsd
int-expression
is an expression whose value is 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.
$COUNTDUPS
$COUNTDUPS returns the number of consecutive words, starting at the beginning of a
buffer, that are equal to the first word in the buffer.
duplicationcount ) ;
VST614.vsd
srcaddr input,output
EXTADDR:variable
an address. Starting at srcaddr, $COUNTDUPS scans 16-bit 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.
maxwords input,output
uINT:variable
the maximum number of 16-bit words to scan at srcaddr. At the end of the
operation, maxwords contains:
• 0 if $COUNTDUPS scanned the entire buffer.
• The number of words $COUNTDUPS did not scan because it found a
nonduplicate pair.
maxwords must be an INT variable; it cannot be a STRING, UNSIGNED, or
USE variable or a bit field.
duplicationcount input,output
uINT:variable
holds an initial value. At the end of the operation, duplicationcount
contains its original value plus the number of duplicate words found by
$COUNTDUPS.
duplicationcount must be an INT variable; it cannot be a STRING,
UNSIGNED, or USE variable or a bit field.
$COUNTDUPS scans a buffer from left to right until it encounters two adjacent unequal
words or until it reads maxwords words.
$DBL
$DBL converts its argument to an INT(32) value.
$DBL ( expression )
VST078.vsd
expression
is an expression whose value is an INT, INT(32), FIXED, REAL, REAL(64),
UNSIGNED(1-16), UNSIGNED(17-31), EXTADDR, or PROCADDR value.
$DBLL
$DBLL converts to INT values an INT(32) value.
VST079.vsd
int-expression
is an INT expression.
To form the INT(32) value, $DBLL places the first int-expression in the high-order
16 bits and the second int-expression in the low-order 16 bits.
$DBLR
$DBLR converts its argument to an INT(32) value and rounds the result.
$DBLR ( expression )
VST080.vsd
expression
is an INT, INT(32), FIXED, REAL, or REAL(64) expression.
If expression is too large to be represented by a 32-bit two’s complement integer,
$DBLR traps if overflow traps are enabled (see Section 13, Hardware Indicators);
otherwise, $DBLR ignores the problem.
$DFIX
$DFIX converts an INT(32) value to a FIXED(fpoint ) value.
VST081.vsd
dbl-expression
is an INT(32) expression.
fpoint
is a value in the range -19 through +19 that specifies the position of the implied
decimal point in the result. A positive fpoint specifies the number of decimal
places to the right of the decimal. A negative fpoint specifies the number of
integer places to the left of the decimal point.
$DFIX converts an INT(32) expression to a FIXED(fpoint ) expression by performing
the equivalent of a signed right shift of 32 positions from the left 32 bits into the right 32
bits of a quadrupleword unit.
$EFLT
$EFLT converts its argument to a REAL(64) value.
$EFLT ( expression )
VST082.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression.
If a FIXED expression has a nonzero fpoint, the compiler multiplies or divides the
result by the appropriate power of ten.
$EFLTR
$EFLTR converts its argument to a REAL(64) value and rounds the result.
$EFLTR ( expression )
VST083.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression.
If a FIXED expression has a nonzero fpoint, the compiler multiplies or divides the
result by the appropriate power of ten.
$EFLTR
$EFLTR converts an expression to a REAL(64) value and rounds the result.
$EFLTR ( expression )
VST083.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression.
If a FIXED expression has a nonzero fpoint, the compiler multiplies or divides the
result by the appropriate power of ten.
$EXCHANGE
$EXCHANGE exchanges the values of two variables of the same data type.
VST615.vsd
var1 input,output
anytype: var
a variable whose contents are exchanged with var2.
var2 input,output
anytype: var
a variable whose contents are exchanged with var1.
var1 and var2 must meet the following requirements:
• var1 and var2 must both be INT variables or both be INT(32) variables.
• Neither var1 nor var2 can be a structure, but they can be fields of structures.
• Neither var1 nor var2 can be STRING, UNSIGNED, or USE variables, nor can
they be bit strings.
• var1, var2, or both can be array elements.
• If var1 or var2 names an entire array, $EXCHANGE exchanges element 0 of
the array.
$EXECUTEIO
Note. The EpTAL compiler does not support this procedure.
lacsubcommand , rdstdevstatus ,
channel-status ) ;
VST616.vsd
channel input
uINT:value
is the channel number to which the I/O is initialized.-
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.
channel-status output
sINT:variable
See the system description manual for your system for details.
$EXTADDR_TO_BADDR
$EXTADDR_TO_BADDR converts an EXTADDR address to a BADDR address.
$EXTADDR_TO_BADDR ( expression )
VST686.vsd
expression
is an expression whose value is an EXTADDR address.
$EXTADDR_TO_WADDR
$EXTADDR_TO_WADDR converts an EXTADDR address to an WADDR address.
$EXTADDR_TO_WADDR ( expression )
VST687.vsd
expression
is an expression whose value is an EXTADDR address.
$FILL8
CALL $FILL16
$FILL32
VST688.vsd
area-to-fill
is a variable of any data type. The address of area-to-fill specifies the
beginning of the area to fill.
repetitions
is an INT expression whose value specifies the number of times to write.
value
is an expression whose value is a STRING value for $FILL8, to an INT value for
$FILL16, and to an INT(32) value for $FILL32.
$FILL16 and $FILL32 cause an alignment trap if area-to-fill is not aligned to at
least a 2-byte boundary.
$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. You might overwrite other data in your program with no immediate error,
or you might cause any of several addressing errors, such as attempting to write in an
area for which you do not have write permission, attempting to write in an unmapped
page, and so forth.
$FIX
$FIX converts its argument to a FIXED value.
$FIX ( expression )
VST084.vsd
expression
is an INT, INT(32), FIXED, REAL, or REAL(64) expression.
If expression is too large in magnitude to be represented by a 64-bit two’s
complement integer, $FIX traps if overflow traps are enabled (see Section 13,
Hardware Indicators); otherwise, $FIX ignores the problem.
$FIXD
$FIXD converts a FIXED value to an INT(32) value.
$FIXD ( fixed-expression )
VST085.vsd
fixed-expression
is a FIXED expression, which $FIXD treats as a FIXED expression, ignoring any
implied decimal point.
If the result cannot be represented in a signed doubleword, $FIXD traps if overflow
traps are enabled (see Section 13, Hardware Indicators); otherwise, $FIXD ignores the
problem.
$FIXEDTOASCII
$FIXEDTOASCII converts the absolute value of a FIXED value to an ASCII value.
maxdigits ) ;
VST617.vsd
qvalue 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.
If $FIXEDTOASCII converts maxdigits bytes but leading digits in qvalue are not
converted, and $OVERFLOW can be checked, $FIXEDTOASCII sets $OVERFLOW;
otherwise, it resets $OVERFLOW.
$FIXEDTOASCIIRESIDUE
$FIXEDTOASCIIRESIDUE converts the absolute value of a FIXED value to an ASCII
value and returns the value of the residue.
, maxdigits , qresidue ) ;
VST618.vsd
qvalue 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.
$FIXEDTOASCIIRESIDUE returns in qresidue any portion of qvalue that it does
not convert because maxdigits digits were written but qvalue was not fully
converted.
If $FIXEDTOASCIIRESIDUE converts maxdigits bytes but leading digits in qvalue
are not converted, and $OVERFLOW can be checked, $FIXEDTOASCIIRESIDUEI
sets $OVERFLOW; otherwise, it resets $OVERFLOW.
$FIXI
$FIXI converts a FIXED value to a signed INT value.
$FIXI ( fixed-expression )
VST086.vsd
fixed-expression
is a FIXED expression, which $FIXI treats as a FIXED expression, ignoring any
implied decimal point.
If the result cannot be represented in a signed 16-bit integer, $FIXI traps if overflow
traps are enabled (see Section 13, Hardware Indicators); otherwise, $FIXI ignores the
problem.
$FIXL
$FIXL converts a FIXED value to an unsigned INT value.
$FIXL ( fixed-expression )
VST087.vsd
fixed-expression
is a FIXED expression, which $FIXL treats as a FIXED expression, ignoring any
implied decimal point.
If the result cannot be represented in an unsigned 16-bit integer, $FIXL traps if
overflow traps are enabled (see Section 13, Hardware Indicators); otherwise, $FIXL
ignores the problem.
$FIXR
$FIXR converts its argument to a FIXED value and rounds the result.
$FIXR ( expression )
VST088.vsd
expression
is an INT, INT(32), FIXED, REAL, or REAL(64) expression.
If expression is too large in magnitude to be represented by a 64-bit two’s
complement integer, $FIXR traps if overflow traps are enabled (see Section 13,
Hardware Indicators); otherwise, $FIXR ignores the problem.
$FLT
$FLT converts its argument to a REAL value.
$FLT ( expression )
VST089.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression
If a FIXED expression has a nonzero fpoint, the compiler multiplies or divides the
result by the appropriate power of ten.
$FLTR
$FLTR converts its argument to a REAL value and rounds the result.
$FLTR ( expression )
VST090.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression
If a FIXED expression has a nonzero fpoint, the compiler multiplies or divides the
result by the appropriate power of ten.
$FREEZE
Note.
• The EpTAL compiler does not support this procedure. Use $TRIGGER on page 15-88
instead. (The EpTAL compiler does allow $FREEZE as a DEFINE name.)
$FREEZE halts the processor in which its process is running and any other processors
on the same node that have FREEZE enabled.
$FREEZE
VST619.vsd
$HALT
Note.
• The EpTAL compiler does not support this procedure. Use $TRIGGER on page 15-88
instead. (The EpTAL compiler does allow $HALT as a DEFINE name.)
$HALT
VST620.vsd
$HIGH
$HIGH converts the high-order (leftmost) 16 bits of an INT(32) or EXTADDR value to
an INT value.
$HIGH ( dbl-expression )
VST091.vsd
dbl-expression
is an expression whose value is INT(32) or EXTADDR.
$HIGH returns the high-order 16 bits of dbl-expression and preserves the sign bit.
$HIGH does not cause overflow.
$IFIX
$IFIX converts a signed INT value to a FIXED(fpoint ) value.
VST092.vsd
int-expression
is a signed INT expression.
fpoint
is a value in the range -19 through +19 that specifies the position of the implied
decimal point in the result. A positive fpoint specifies the number of decimal
places to the right of the decimal. A negative fpoint specifies the number of
integer places to the left of the decimal point.
When $IFIX converts the signed INT expression to a FIXED value, it performs the
equivalent of a signed right shift of 48 positions in a quadrupleword unit.
In Example 15-42 on page 15-53, $IFIX returns a FIXED(2) value from a signed INT
expression and an fpoint of 2.
$INT
$INT converts its argument to an INT value.
$INT ( expression )
VST093.vsd
expression
is an expression whose value is an INT, INT(32), UNSIGNED(1-16),
UNSIGNED(17-31), FIXED, REAL, REAL(64), SGBADDR, SGWADDR,
SGXBADDR, SGXWADDR, or EXTADDR value.
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. In Example 15-43 on page 15-54, $INT
returns -1 although the argument to $INT is a positive number.
If the value of the expression in Example 15-43 on page 15-54 is a FIXED, REAL, or
REAL(64) value, $INT returns the result of converting expression arithmetically to an
INT value—$INT does not just truncate an expression. If the converted value of
expression is too large to fit in 16 bits, an exception trap occurs.
For details on SG and SGX variables, see Section 3, Data Representation.
$INT_OV
Note. $INT_OV is supported in the D40 and later product versions.
$INT_OV converts its argument to an INT value and sets $OVERFLOW in some
cases.
$INT_OV ( expression )
VST689.vsd
expression
is an expression whose value is an INT, INT(32), UNSIGNED(1-31), FIXED, REAL,
REAL(64), SGBADDR, SGWADDR, SGXBADDR, SGXWADDR, or EXTADDR
value.
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 (see Section 13, Hardware
Indicators); otherwise, $INT_OV ignores the problem.
$INTERROGATEHIO
Note. The EpTAL compiler does not support this procedure.
) ;
VST643.vsd
select output
uINT:variable
is an integer variable that is always set to 0.
rank-channel output
uINT:variable
is an integer variable that is always set to 0.
ric-int-cause output
uINT:variable
is the read interrupt cause received from the controller holding the completed
I/O.
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.
$INTERROGATEIO
Note. The EpTAL compiler does not support this procedure.
$INTERROGATEIO stores cause and status information from an I/O interrupt, which
the operating system uses to reset the interrupt.
) ;
VST644.vsd
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.
rist-int-cause output
sINT:variable
is the read interrupt status received from the controller holding the completed
I/O.
channel-status output
sINT:variable
is an integer variable that holds the status returned by the controller.
$INTR
$INTR converts:
• The low-order 16 bits of an INT, INT(32), or FIXED value to an INT value
• A REAL or REAL(64) value to a rounded INT value
$INTR ( expression )
VST094.vsd
expression
is an INT, INT(32), FIXED, REAL, or REAL(64) expression.
If expression is type INT, INT(32) or FIXED, $INTR returns the low-order (least
significant) 16 bits and does not explicitly maintain the sign. No overflow occurs.
If expression is type REAL or REAL(64), $INTR returns a fully converted and
rounded INT value, not a truncation. If the converted value of expression is too
large to be represented by a 16-bit two’s complement integer, an overflow trap occurs.
$LEN
$LEN returns an INT value that is the length, in bytes, of a variable.
$LEN ( variable )
VST096.vsd
variable
is the identifier of a simple variable, array element, pointer, structure, or structure
data item.
The compiler reports an error if you apply the $LEN routine to a structure that consists
of an odd number of bytes, exclusive of a pad byte.
You can avoid this error by using one of the following solutions:
• Declare explicitly a 1-byte filler item at the end of structures that consist of an odd
number of bytes.
• Use $BITLENGTH on page 15-28 instead of $LEN.
The compiler reports an error if you apply $LEN to an UNSIGNED variable or structure
field. Use $BITLENGTH to obtain the length of an UNSIGNED variable or structure.
$LFIX
$LFIX converts an unsigned INT value to a FIXED(fpoint ) value.
VST097.vsd
int-expression
is an unsigned INT expression.
fpoint
is a value in the range -19 through +19 that specifies the position of the implied
decimal point in the result. A positive fpoint specifies the number of decimal
places to the right of the decimal. A negative fpoint specifies the number of
integer places to the left of the decimal point.
$LFIX places the INT value in the low-order (least significant) word of the
quadrupleword and sets the three high-order (most significant) words to 0.
$LMAX
$LMAX returns the maximum of two unsigned INT values.
VST098.vsd
int-expression
is an unsigned INT expression.
$LMIN
$LMIN returns the minimum of two unsigned INT values.
VST099.vsd
int-expression
is an unsigned INT expression.
$LOCATESPTHDR
Note. The EpTAL compiler does not support this procedure.
sptbase ) ;
VST645.vsd
headersize input
uINT:value
is the unsigned byte offset from the beginning of the SPT to the beginning of
the header. Because the SPT header always precedes the SPT, headersize
is subtracted from the address of the SPT to obtain the address of the start of
the header.
virtaddr input
EXTADDR:value
is the address of the SPT.
sptbase output
EXTADDR:variable
is the address of the segment-page-table header associated with virtaddr.
$LOCATESPTHDR returns in sptbase the address of the segment-page table for the
address in virtaddr.
$LOCKPAGE
Note. The EpTAL compiler does not support this procedure.
virtaddr ) ;
VST646.vsd
only-if-locked input
sINT:value
is an INT value. If only-if-locked is greater than or equal to zero, the
page will always be locked. If only-if-locked is less than zero, the page
will be locked (that is, lock count will be incremented) only if it is already
locked.
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.
$MAX
$MAX returns the maximum of two signed values.
VST100.vsd
expression
is a signed INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression. Both
expressions must be of the same data type.
$MIN
$MIN returns the minimum of two signed values.
VST101.vsd
expression
is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression. Both
expressions must be of the same data type.
$MOVEANDCXSUMBYTES
$MOVEANDCXSUMBYTES moves a specified number of bytes from one memory
location to another and computes a checksum (bytewise exclusive “or”) on the bytes
moved.
$MOVEANDCXSUMBYTES ( checksum ,
VST647.vsd
checksum input,output
uINT:variable
contains an initial value for the checksum. When $MOVEANDCXSUMBYTES
completes, checksum contains the newly computed value.
destaddr input,output
EXTADDR:variable
is the address to which $MOVEANDCXSUMBYTES moves data. When
$MOVEANDCXSUMBYTES completes, destaddr points to the memory
location following the last byte written.
srcaddr input,output
EXTADDR:variable
is the address from which bytes are read. When $MOVEANDCXSUMBYTES
completes, srcaddr points to the memory location following the last byte
read.
count input
uINT:value
is the number of bytes to move.
$MOVEANDCXSUMBYTES transfers count bytes from srcaddr to destaddr and
computes a checksum (bytewise exclusive “or”) on the data moved. When
$MOVEANDCXSUMBYTES completes, srcaddr points to the immediate right of the
last byte read, destaddr points to the immediate right of the last byte written, and
checksum holds the newly computed checksum.
$MOVEANDCXSUMBYTES does not ensure that the source and destination buffers
do not overlap.
$MOVENONDUP
$MOVENONDUP moves words from one location to another until it encounters two
adjacent identical words.
maxwords , lastword ) ;
VST648.vsd
destaddr input,output
EXTADDR:variable
is the address to which words are moved. When $MOVENONDUP completes,
destaddr is the address after which $MOVENONDUP stored the last byte.
srcaddr input,output
EXTADDR:variable
is the address from which 16-bit words are moved. When $MOVENONDUP
completes, srcaddr is the address after which $MOVENONDUP read the
last byte it moved.
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.
$NUMERIC
$NUMERIC tests the right byte of an INT value for the presence of a numeric
character.
$NUMERIC ( int-expression ) ;
VST102.vsd
int-expression
is an INT expression.
$NUMERIC inspects bits <8:15> of int-expression and ignores bits <0:7>. It tests
for a numeric character according to the criterion:
int-expression >= "0" AND int-expression <= "9"
If a numeric character occurs, $NUMERIC sets the condition code to CCL (condition
code less than). If you plan to test the condition code, do so before an arithmetic
operation or assignment occurs.
If the character passes the test, $NUMERIC returns a -1 (true); otherwise, it returns a 0
(false).
int-expression can include STRING and UNSIGNED(1-16) operands, as
described in “Expression Arguments” at the beginning of this section.
$OCCURS
$OCCURS returns an INT value that is the number of elements in an array.
$OCCURS ( variable )
VST103.vsd
variable
is the name of a variable, array, structure, or structure field. variable cannot be
the name of a structure template.
If identifier is the identifier of an explicitly declared array—that is, it is not a
reference parameter—and identifier is the unindexed name of the array, $OCCURS
returns the number of array elements specified in the array’s declaration; otherwise,
$OCCURS returns 1.
Table 15-15. $OCCURS for Structure Arrays and Arrays Within Structures
$OCCURS
$OCCURS Argument Example Returns
Unindexed structure array or STRUCT s [0:9];
substructure array BEGIN
or STRUCT
BEGIN
an element of a structure array or INT
substructure array, END;
or END;
an array that is a field within a $OCCURS (s); 10
structure or substructure $OCCURS (a[7]); 1
$OCCURS (a[7].t); 8
$OCCURS (a[7].t[3]); 1
$OCCURS (a[7].t[3].i); 5
$OCCURS (a[7].t[3].i[v]); 1
Entire structure STRUCT s;
or BEGIN
INT f;
nonarray field of a structure or END;
substructure 1
$OCCURS (s); 1
$OCCURS (s.f);
Structure template STRUCT s;
BEGIN
INT f[0:9];
END;
Compile-time err
$OCCURS (s); 10
$OCCURS (s.f); 1
$OCCURS (s.f[5]);
$OFFSET
$OFFSET returns an INT value that is the offset, in bytes, of a structure item from the
beginning of the structure.
$OFFSET ( variable )
VST104.vsd
variable
is the fully qualified identifier of a structure field.
The compiler reports an error for the following uses of $OFFSET:
• $OFFSET applied to an UNSIGNED field. Use $BITOFFSET instead of $OFFSET.
• $OFFSET applied to an item that is not a field in a structure.
• $OFFSET applied to a structure array whose lower bound is nonzero; however,
$OFFSET applied to a substructure array whose lower bound is nonzero returns
the appropriate offset.
• $OFFSET for which the result would be greater than 216-1.
$OPTIONAL
$OPTIONAL controls whether a given parameter or parameter pair is passed to a
VARIABLE procedure or EXTENSIBLE procedure.
$OPTIONAL
( cond-expression , param )
param-pair
VST213.vsd
cond-expression
is a conditional expression. If cond-expression is true, param or param-pair
is passed. If cond-expression is false, param (or param-pair ) is not
passed.
param
is an a variable identifier or an expression that defines an actual parameter to pass
to a formal parameter declared in the called procedure if cond-expression is
true.
param-pair
is an actual parameter pair to pass to a formal parameter pair declared in the
called procedure if cond-expression is true. param-pair has the form:
string : length
VST039.vsd
string
is the identifier of a STRING array or simple pointer declared inside or outside
a structure.
length
is an INT expression that specifies the length, in bytes, of string.
A call to a VARIABLE or EXTENSIBLE procedure can omit some or all parameters.
$OPTIONAL lets your program pass a parameter (or parameter-pair) based on a
condition at execution time. $OPTIONAL is evaluated as follows each time the
encompassing CALL statement is executed:
• If cond-expression is true, the parameter is passed; $PARAM, if present, is set
to true for the corresponding formal parameter.
• If cond-expression is false, the parameter is not passed; $PARAM, if present,
is set to false for the corresponding formal parameter.
A called procedure cannot distinguish between a parameter that is passed
conditionally and one that is passed unconditionally. Passing parameters conditionally,
however, is slower than passing them unconditionally. In the first case, the
EXTENSIBLE mask is computed at execution time; in the second case, the mask is
computed at compilation time.
You can use $OPTIONAL when one procedure provides a front-end interface for
another procedure that does the actual work, as Example 15-71 on page 15-75 shows.
$OVERFLOW
$OVERFLOW returns a value indicating whether an overflow occurred during certain
arithmetic operations.
$OVERFLOW
VST105.vsd
For more information about overflow, see Section 13, Hardware Indicators.
$PARAM
$PARAM checks for the presence or absence of an actual parameter in the call that
called the current procedure or subprocedure.
$PARAM ( formal-param )
VST106.vsd
formal-param
is the identifier of a formal parameter as specified in the procedure or
subprocedure declaration.
If the actual parameter corresponding to formal-param is present in the CALL
statement, $PARAM returns 1 (not -1 as other Boolean operations do). If the actual
parameter is absent from the CALL statement, $PARAM returns 0.
Only a VARIABLE procedure or subprocedure or an EXTENSIBLE procedure can use
$PARAM. If such a procedure or subprocedure has required parameters, it must check
for the presence or absence of each required parameter in CALL statements. The
procedure or subprocedure can also use $PARAM to check for optional parameters.
$POINT
$POINT returns the fpoint value (as an integer) of a FIXED expression.
$POINT ( fixed-expression )
VST107.vsd
fixed-expression
is a FIXED expression.
The compiler emits no instructions when evaluating fixed-expression ; therefore,
fixed-expression cannot call a routine and cannot be an assignment expression.
$PROCADDR
$PROCADDR converts an INT(32) value to a PROCADDR address.
$PROCADDR ( identifier )
VST031.vsd
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.
VST649.vsd
xbase
INT(32):variable
is the base address of the current extended segment.
xlimit output
INT(32):variable
is the limit of the current extended segment.
Consult the system description manual for your system for the format in which the base
and limit values are returned.
$READCLOCK
$READCLOCK returns the current setting of the system clock as a FIXED value.
$READCLOCK
VST108.vsd
$READSPT
Note. The EpTAL compiler does not support this procedure.
$READSPT returns (copies) an entry from the Segment Page Table (SPT).
VST650.vsd
virtaddr input
EXTADDR:value
is the virtual address of the SPT entry to copy.
sptentryaddr output
EXTADDR:variable
is the address at which $READSPT stores the SPT entry.
$READTIME
$READTIME returns the number of microseconds since the last cold load.
Note. $READTIME is not affected by the TACL command SETTIME; therefore, $READTIME
does not always return the value [JULIANTIMESTAMP(0) - JULIANTIMESTAMP(1)].
For a description of the SETTIME command, see the TACL Reference Manual. For a
description of the JULIANTIMESTAMP function, see the Guardian Procedure Calls Reference
Manual.
$READTIME
VST651.vsd
$SCALE
$SCALE moves the position of the implied fixed-point (decimal point) by changing a
FIXED(fpoint ) value.
VST110.vsd
fixed-expression
is the FIXED expression whose implied decimal point is to be changed.
scale
is an INT constant in the range -19 to +19 that specifies the number of positions to
move the implied decimal point with respect to the least significant digit. If scale
is negative, the implied decimal point moves to the left; if scale is positive, the
implied decimal point moves to the right.
$SCALE adjusts the implied decimal point of the stored FIXED value by multiplying or
dividing the value by 10 to the scale power. Some precision might be lost with
negative scale values.
If the result of the scale operation exceeds the range of a FIXED expression, $SCALE
traps if overflow traps are enabled (see Section 13, Hardware Indicators); otherwise,
$SCALE ignores the problem.
To retain precision when you divide operands that have nonzero fpoint settings, use
the $SCALE built-in routine to scale up the fpoint of the dividend by a factor equal
to the fpoint of the divisor, as in Example 15-80 on page 15-83.
$SGBADDR_TO_EXTADDR
$SGBADDR_TO_EXTADDR converts an SGBADDR or SGXBADDR address to an
EXTADDR address.
$SGBADDR_TO_EXTADDR ( expression )
VST603.vsd
expression
is an expression whose value is an SGBADDR or SGXBADDR address.
$SGBADDR_TO_EXTADDR returns expression converted to an EXTADDR
address.
$SGBADDR_TO_SGWADDR
$SGBADDR_TO_SGWADDR converts an SGBADDR or SGXBADDR address to an
SGWADDR address.
$SGBADDR_TO_SGWADDR ( expression )
VST604.vsd
expression
is an expression whose value is an SGBADDR or SGXBADDR address.
$SGBADDR_TO_SGWADDR returns expression converted to an SGWADDR address.
The result is undefined if the least significant bit of expression is 1.
$SGWADDR_TO_EXTADDR
$SGWADDR_TO_EXTADDR converts an SGWADDR or SGXWADDR address to an
EXTADDR address.
$SGWADDR_TO_EXTADDR ( expression )
VST605.vsd
expression
is an expression whose value is n SGWADDR or SGXWADDR address.
$SGWADDR_TO_EXTADDR returns expression converted to an EXTADDR
address.
$SGWADDR_TO_SGBADDR
$SGWADDR_TO_SGBADDR converts an SGWADDR or SGXWADDR address to an
SGBADDR address.
$SGWADDR_TO_SGBADDR ( expression )
VST690.vsd
expression
is an expression whose value is an SGWADDR or SGXWADDR address.
If expression is not an address in the lower half of the 64K word segment, the
address returned by $SGWADDR_TO_SGBADDR is undefined.
$SPECIAL
$SPECIAL tests the right byte of an INT value for the presence of an ASCII special
(nonalphanumeric) character (see Table 2-1 on page 2-2).
$SPECIAL ( int-expression )
VST111.vsd
int-expression
is an INT expression.
$SPECIAL inspects bits <8:15> of the int-expression and ignores bits <0:7>.
$SPECIAL (int-expression ) has the same value as:
NOT $NUMERIC(int-expression ) AND NOT $ALPHABETIC(int-expression )
If the character passes the test, $SPECIAL returns a -1 (true); otherwise, $SPECIAL
returns a 0 (false).
int-expression can include STRING and UNSIGNED(1-16) operands (see
Expressions as Parameters on page 15-3).
In Example 15-85 on page 15-86, $SPECIAL tests for the presence of a special
character in a STRING argument, which the system places in the right byte of a word
and treats as an INT value.
$STACK_ALLOCATE
Note. The pTAL and EpTAL compilers behave differently.
$STACK_ALLOCATE ( size )
VST032.vsd
size
is an INT expression that specifies the number of bytes to allocate. size is an
unsigned value from 0 through 65534.
Difference between pTAL and EpTAL compilers:
pTAL Compiler EpTAL Compiler
If size is not an integral multiple of 8, If size is not an integral multiple of 32,
$STACK_ALLOCATE rounds size up to $STACK_ALLOCATE rounds size up to
the next integral multiple of 8. the next integral multiple of 32.
The returned value is aligned to an 8-byte The returned value is aligned to a 32-byte
boundary. boundary.
For more information about $STACK_ALLOCATE, see the pTAL Conversion Guide.
$TRIGGER
Note.
$TRIGGER replaces $FREEZE on page 15-51 and $HALT on page 15-51, which are
available only for code generated for the TNS/R architecture.
$TRIGGER ( op )
VST060.vsd
op
is an INT(32) value.
$TYPE
$TYPE returns an INT value that represents the data type of a variable.
$TYPE ( variable )
VST112.vsd
variable
is the identifier of a simple variable, array, simple pointer, structure, structure data
item, or structure pointer.
$TYPE returns an INT value that has a meaning as follows:
Value Meaning Value Meaning
0 Undefined 5 REAL
1 STRING 6 REAL(64)
2 INT 7 Substructure
3 INT(32) 8 Structure
4 FIXED 9 UNSIGNED
For a structure pointer, $TYPE returns the value 8, regardless of whether the structure
pointer points to a structure or to a substructure.
You can use $TYPE in LITERAL expressions and global initializations, because
$TYPE always returns a constant value.
$UDBL
$UDBL converts an unsigned INT value to an INT(32) value.
$UDBL ( int-expression )
VST113.vsd
int-expression
is an unsigned INT expression.
$UDBL places the INT value in the low-order 16 bits of an INT(32) variable and sets
the high-order 16 bits to 0.
$UDIVREM16
$UDIVREM16 divides an INT(32) dividend by an INT divisor to produce an INT
quotient and INT remainder.
quotient , remainder ) ;
VST653.vsd
dividend input
INT(32):value
divisor input
sINT:value
quotient output
sINT:variable
remainder output
sINT:variable
The compiler checks the following conditions during compilation:
• If the value of divisor is a constant value of zero, the compiler reports an error
that division by zero is not valid:
$UDIVREM16(dividend, 2 / 2 - 1, quot, rem); ! Report error
• If both dividend and divisor have constant values whose unsigned quotient is
greater than 16 bits, the compiler reports overflow:
INT quot, rem;
$UDIVREM16(65536 * 1024, 256, quot, rem); ! Report error
• If both dividend and divisor are constants, and you test $OVERFLOW
following the call to $UDIVREM16, the compiler reports a warning that overflow
cannot occur:
$UDIVREM16(32767, 256, quot, rem);
IF $OVERFLOW THEN ... ! Report warning
If the compiler reports an error because overflow occurs for constant dividend and
constant divisor, it does not report a warning if you test $OVERFLOW in the following
IF statement:
$UDIVREM16(65536 * 1024, 256, quot, rem); ! Report error
IF $OVERFLOW THEN.... ! No warning or error
$UDIVREM32
$UDIVREM32 divides an INT(32) dividend by an INT divisor to produce an INT(32)
quotient and INT remainder.
quotient , remainder ) ;
VST654.vsd
dividend input
INT(32):value
divisor input
sINT:value
quotient output
INT(32):variable
remainder output
sINT:variable
The compiler checks the following conditions during compilation:
• If the value of divisor is a constant value of zero, the compiler reports an error
that division by zero is not valid:
$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, the compiler reports a warning that overflow
cannot occur:
$UDIVREM32(32767, 256, quot, rem);
IF $OVERFLOW THEN ... ! Report warning
If the compiler reports an error because overflow occurs for constant dividend and
constant divisor, it does not report a warning if you test $OVERFLOW in the following
IF statement:
$UDIVREM32(65536 * 1024, 256, quot, rem); ! Report error
IF $OVERFLOW THEN.... ! No warning or error
$UNLOCKPAGE
Note. The EpTAL compiler does not support this procedure.
VST655.vsd
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.
$WADDR_TO_BADDR
$WADDR_TO_BADDR converts a WADDR address to a BADDR address.
$WADDR_TO_BADDR ( expression )
VST691.vsd
expression
is an expression whose value is a WADDR address.
$WADDR_TO_EXTADDR
$WADDR_TO_EXTADDR converts a WADDR address to an EXTADDR address.
$WADDR_TO_EXTADDR ( expression )
VST692.vsd
expression
is an expression whose value is a WADDR address.
$WRITEPTE
Note. The EpTAL compiler does not support this procedure.
abs ) :
VST656.vsd
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.
$XADR
$XADR converts a standard address to an EXTADDR address.
$XADR ( variable )
VST115.vsd
variable
is a variable that has a standard address.
$XADR returns an EXTADDR address. If the argument to $XADR is not a variable, the
compiler reports an error.
$XADR returns an absolute extended EXTADDR address in absolute segment 1 if
variable is a system global address (an SGBADDR, SGWADDR, SGXBADDR, or
SGXWADDR address).
Variable can be the name of a pointer preceded by an “@” operator. In this case,
$XADR returns the absolute address of the pointer, as in the following example.
pTAL Source File 1 pTAL Source File 2 ... pTAL Source File n
Linker
Executable
Object File
VST699.vsd
Topics:
• Compiling Source Files on page 16-2
• Linking Object Files on page 16-7
• Creating a Dynamic Linked Library (DLL) on page 16-12
• Compiling With Global Data Blocks on page 16-12
• Compiling With Saved Global Data on page 16-17
• Using the Code Coverage Tool on page 16-17
Note. The remainder of this section applies only to Guardian platforms. To compile and link
pTAL programs on Windows platforms, see Section 18, pTAL Cross Compiler.
The compiler reads input only from a single edit-format disk file. You can use the
SOURCE on page 17-60 in this input file to read code from other source files during
compilation. The input file and code read from other source files comprise a
compilation unit.
In general, the compiler opens each source file as it needs the source file and keeps
the source file open until the end of the compilation. This behavior ensures that the
contents of the file cannot change between the time the compiler reads the file and
creates a listing. You can open a source file for read access, but generally not for write
access, while the source file is compiling.
When the number of files read exceeds the maximum number of files that Guardian
allows to be open, the compiler closes the least recently used file (unless that file is the
primary source file, which is always kept open) in order to continue to open and read
source files.
If you edit a file before the compiler creates an output listing, the source code in the
listing will not match the code in the source file. The compiler reports a warning if it
discovers that part of a source file has changed. Do not alter the source files until the
compilation ends.
Topics:
• Input Files on page 16-3
• Output Files on page 16-3
• Running the Compiler on page 16-4
• Completion Codes Returned by the Compiler on page 16-6
Input Files
The compiler reads input only from an edit-format disk file up to a maximum of 132
characters for each record, ignoring characters after the 132nd (and issuing a warning
for each such line). The compiler does not read input from a terminal or from any other
source or file format.
Output Files
You can direct list output from the compiler to any of the following types of files:
• Spooler
• Entry-sequenced file
• Relative file
• Terminal
• Process
• Printer
• Edit-format file
• HP TACL variable
If you direct output to a disk file that does not exist, the compiler creates an edit-format
file and writes the compiler listing to the newly created file.
If you direct output to an edit-format file that already exists, the compiler removes the
existing file from your current compilation and creates a new file using the file name
you specified.
Difference between pTAL and EpTAL compilers:
pTAL Compiler EpTAL Compiler
On Guardian platforms, object files have the On Guardian platforms, object files have the
file code 700 file code 800
IN File Option
The IN file is the primary source file. You can specify a file name or a DEFINE as
described in Appendix B, Disk File Names and HP TACL Commands. In this example,
the IN file is mysource.
pTAL /IN mysource/ myobject
EpTAL /IN mysource/ myobject
The IN file must be an edit-format disk file. The compiler reads the file as 132-byte
records.
The linker can also strip nonessential information from an object file and modify the
object file’s process attributes (such as HIGHPIN). For more information, see:
• eld Manual
• ld Manual
• nld Manual
The simplest cases are:
• On TNS/E, use the EpTAL compiler and the eld utility to create an object file that
executes on TNS/E (see Figure 16-2 on page 16-8).
• On TNS/R, use the pTAL compiler and either the ld or nld utility to create an
object file that executes on TNS/R (see Figure 16-3 on page 16-9).
Also, TNS allows you to create object files that execute on TNS/R. Use the TAL
compiler and Binder on TNS and the Accelerator (AXCEL) on either TNS or TNS/R to
create an object file that executes on TNS/R (see Figure 16-4 on page 16-10). (In this
case, you begin with TAL source code rather than pTAL source code.)
You can input some kinds of loadfiles to the Accelerator (AXCEL) and the Object Code
Accelerator (OCA) to produce hybrid loadfiles (see Figure 16-5 on page 16-11).
You cannot link PIC and non-PIC object files into a single object file.
EpTAL Compiler
TNS/E Nonexecutable
Object Code (PIC)
eld
TNS/E Executable
Object Code (PIC)
VST045.vsd
The source code can be in one or more files. From each source code file, the compiler generates a single
nonexecutable object code file. Input these object code files to the linker to produce a single loadfile. (See
Figure 16-1 on page 16-1.)
pTAL Compiler
NOCALL_SHARED CALL_SHARED
directive (default) directive
nld ld
VST054.vsd
The source code can be in one or more files. From each source code file, the compiler generates a single
nonexecutable object code file.
If you compile multiple source files, either compile all of them using the CALL_SHARED directive or all of them
without using the CALL_SHARED directive (you cannot link PIC and non-PIC object files into a single object file).
Input these object code files to the appropriate linker to produce a single loadfile. (See Figure 16-1 on page 16-1.)
TNS
TAL Compiler
TNS Nonexecutable
Object Code (non-PIC)
Binder
TNS/R
AXCEL
VST824.vsd
The source code can be in one or more files. From each source code file, the compiler generates a single
nonexecutable object code file. Input these object code files to Binder to produce a single loadfile. (Figure 16-1 on
page 16-1 illustrates this concept, but uses a linker instead of Binder.)
As Figure 16-4 on page 16-10 shows, the Accelerator (AXCEL) is available on both
TNS/R and TNS processors; therefore, you can do either of the following:
• Accelerate your TNS executable object code while it is on a TNS processor and
then move the resulting executable object code to a TNS/R processor.
• Move your TNS executable object code to a TNS/R processor and then accelerate
it.
In both cases, the resulting executable object code executes only on TNS/R
processors.
AXCEL
OCA OCA
VST044.vsd
Topics:
• Naming Compilation Units on page 16-13
• Declaring Named Data Blocks on page 16-13
• Declaring Private Data Blocks on page 16-14
• Declaring Unblocked Data on page 16-14
A variable declared in a named data block can have the same name as the data block.
Modules written in pTAL can share global variables with modules written in HP C by
placing each shared variable in its own block and giving the variable and the block the
same name.
Example 16-4. Data Block and Variable With the Same Name
BLOCK c_var;
INT c_var;
END BLOCK;
The compiler places unblocked data declarations in implicit primary data blocks,
created as follows:
1. When you use named blocks, private blocks, or the BLOCKGLOBALS directive,
each data item becomes its own block. All the other unblocked data items are
grouped into a block named _GLOBAL and $_GLOBAL.
2. Each block so created is split into two blocks to separate “large” data from “small”
data. “Large” data means arrays or structures declared with “.” or “.EXT” notation.
“Small” data is everything else. When both blocks exist, the “large” data block has
a $ in front of its name.
For example, if you have the following global data declarations:
INT x;
INT .y;
INT .z [0:113]
Variables x and y are placed in the block named _GLOBAL, and z is placed in the
block named $_GLOBAL.
Named data blocks are split the same way. For example:
BLOCK blk;
INT x;
INT .y;
INT .ext z [0:99];
END BLOCK;
Two data blocks are created. Variables x and y are placed in the block named BLK
and z is placed in the block named $BLK.
You can link object files compiled with and without template blocks with no loss of
information.
A referral structure and the structure layout to which it refers can appear in different
data blocks. The structure layout must appear first.
In all other cases, a data declaration and any data to which it refers must appear in the
same data block. The following declarations, for example, must appear in the same
data block:
INT var; ! Declare var
INT .ptr := @var; ! Declare ptr by referring to var
If the reference is not in the same block, the compiler issues an error message.
Address Assignments
The compiler assigns each direct variable and each pointer an offset from the
beginning of the encompassing global data block. Within the data block, it allocates
storage for each data declaration according to its data type and size.
Note. The Code Coverage Tool is intended for data generation and collection in a test
environment only. The use of instrumented object code is not recommended for production
environments. Applications compiled with code coverage instrumentation will experience
greatly reduced performance.
For details on using the Code Coverage Tool, see the Code Coverage Tool Reference
Manual.
Compilation Command
compilation-command ; directive
,
VST063.vsd
compilation-command
is as described in Running the Compiler on page 16-4.
directive
is a directive listed in Table 17-1 on page 17-14 or Table 17-2 on page 17-17,
except the following, which can appear only in the source file (see Directive Line
on page 17-2):
• ASSERTION on page 17-19
• BEGINCOMPILATION on page 17-20 (not recommended)
• ENDIF on page 17-29
• IF and IFNOT on page 17-39
• PAGE on page 17-51
• SECTION on page 17-57
• SOURCE on page 17-60
Directive Line
The general form of a directive line is:
? directive
,
VST120.vsd
?
indicates a directive line, and can appear only in column 1.
directive
is a directive listed in Table 17-1 on page 17-14 or Table 17-2 on page 17-17,
except OPTIMIZEFILE, which can appear only in the command line (see
Compilation Command on page 17-1).
The following directives accept Disk File Names on page B-1, DEFINE names, and
ASSIGN names as arguments:
• ERRORFILE on page 17-30
• SAVEGLOBALS on page 17-56 (not recommended)
• SOURCE on page 17-60
• USEGLOBALS on page 17-69 (not recommended)
A DEFINE name or an ASSIGN name is considered a logical file name (see Logical
File Names on page B-4). The directives listed above accept a logical file name in
place of a file name.
You can specify partial file names. If you specify a partial file name, the compiler uses
default values as described in Partial File Names on page B-3.
For the USEGLOBALS directive (not recommended) and the SOURCE and directive,
the compiler can use the node (system), volume, and subvolume specified in ASSIGN
SSV commands, as in Example 17-3 on page 17-7.
Directive Stacks
Each of these directives has a compile-time directive stack onto which you can push,
and from which you can pop, directive settings:
• CHECKSHIFTCOUNT on page 17-23
• DEFEXPAND on page 17-26
• DO_TNS_SYNTAX on page 17-28
• GP_OK on page 17-38
• INNERLIST on page 17-42
• LIST on page 17-44
• MAP on page 17-45
• OVERFLOW_TRAPS on page 17-49
• REFALIGNED on page 17-53
Each directive stack is 31 levels deep.
Topics:
• Pushing Directive Settings on page 17-4
• Popping Directive Settings on page 17-4
• Example on page 17-5
Example
In Example 17-2 on page 17-5:
1. LIST is the default setting for the source file.
2. PUSHLIST pushes the LIST directive setting onto the LIST directive stack.
3. NOLIST suppresses listing of procedures included by the SOURCE directive.
4. POPLIST pops the top value from the LIST directive stack and restores LIST as
the current setting for the remainder of the source file.
Toggles
Toggles allow these directives to effect conditional compilation:
Directive Description
DEFINETOG Specifies toggles without changing their settings. If DEFINETOG is
specifying a toggle for the first time, its setting is off.
SETTOG Specifies toggles and turns them on
RESETTOG Specifies toggles and turns them off
IF and IFNOT Begin conditional compilation, based on the value of a specified toggle
ENDIF Ends conditional compilation
Topics:
• Named Toggles on page 17-6
• Numeric Toggles on page 17-6
• Examples on page 17-6
Named Toggles
Before you use a named toggle in an IF or IFNOT directive, you must specify that
name in a DEFINETOG, SETTOG, or RESETTOG directive. Which of these directives
you use depends on whether you want the setting of the toggle to be unchanged,
turned on, or turned off.
Setting
Directive New Toggle Specified Existing Toggle
DEFINETOG Off Unchanged
SETTOG On On
RESETTOG Off Off
You can use DEFINETOG if you are not sure the toggles were created earlier in the
compilation, possibly in a file that you included by using a SOURCE directive. If you
specify toggles that already exist, DEFINETOG does not change their settings (as
SETTOG and RESETTOG do).
Numeric Toggles
The numeric toggles are 1 through 15. All other toggles (including 16, 17, and so on)
are considered named toggles.
You can use a numeric toggle in an IF or IFNOT directive even if that toggle has not
been specified in a DEFINETOG, SETTOG, or RESETTOG directive.
By default, all numeric toggles not turned on by SETTOG are turned off. To turn off
numeric toggles turned on by SETTOG, use RESETTOG.
Examples
• Example 17-3, DEFINETOG, IF, and ENDIF Directives, on page 17-7
• Example 17-4, DEFINETOG, IFNOT, and ENDIF Directives Directive, on page 17-7
• Example 17-5, SETTOG, IF, and ENDIF Directives, on page 17-7
• Example 17-6, SETTOG, IFNOT, and ENDIF Directives, on page 17-7
• Example 17-7, SETTOG, RESETTOG, IF, and ENDIF Directives, on page 17-8
Note.
• The EpTAL compiler does not accept the SAVEGLOBALS or USEGLOBALS directive.
• The EpTAL compiler ignores the BEGINCOMPILATION directive.
Topics:
• Saving Global Data Declarations on page 17-9
• Retrieving Global Data Declarations on page 17-9
• Examples on page 17-10
• Migrating from TNS/R to TNS/E on page 17-11
Terms used in the following topics:
Term Meaning
SAVEGLOBALS compilation The compilation for which you specify SAVEGLOBALS
SAVEGLOBALS compilation file The source file for the SAVEGLOBALS compilation
USEGLOBALS compilation The compilation for which you specify USEGLOBALS
USEGLOBALS compilation file The source file for the USEGLOBALS compilation
You must use the same version of the compiler for the SAVEGLOBALS compilation
and the USEGLOBALS compilation; otherwise, an error occurs in the USEGLOBALS
compilation.
Whenever you switch to a new version of the compiler, you must recompile the source
code using SAVEGLOBALS to create a new global declarations file.
Caution. Be sure the global data declarations in both the SAVEGLOBALS and USEGLOBALS
compilations are identical. If you include new or changed global data declarations anywhere in
the USEGLOBALS source file, results are unpredictable.
Examples
The source file in Example 17-8 on page 17-10 (MYPROG) is compiled in examples
Example 17-9 on page 17-10 through Example 17-12 on page 17-11, which show how
the SAVEGLOBALS, USEGLOBALS, BEGINCOMPILATION, and SYNTAX directives
interact.
Example 17-8. MYPROG Source File for Example 17-9 Through Example 17-12
Source File MYPROG
! Source file MYPROG
! Unless USEGLOBALS is active, compile the entire source file.
?SOURCE SHARGLOB
?BEGINCOMPILATION ! When USEGLOBALS is active, compile
! following code
?PUSHLIST, NOLIST, SOURCE $system.system.extdecs
?POPLIST
PROC my_first_proc;
BEGIN
...
END;
PROC my_last_proc;
BEGIN
...
END;
File of Shared Global Data, SHARGLOB
?SOURCE glbfile1 (section1, section2)
?SOURCE moreglbs
INT ignore_me1;
INT ignore_me2;
The compilation command in Example 17-9 on page 17-10 compiles myprog (the
source file in Example 17-8) and saves global data declarations and data initializations.
A USEGLOBALS compilation (Example 17-10 on page 17-11) then produces object file
newobj and retrieves global data declarations and initialization from ptalsym and
global initializations from myobj. When USEGLOBALS is active, the compiler ignores
text lines and SOURCE directives until BEGINCOMPILATION appears in the source
file.
You can check the syntax of global data declarations before saving them, as in
Example 17-11 on page 17-11.
After you correct any errors, you can recompile myprog as in Example 17-12 on
page 17-11.
If some files do not compile successfully because of missing global data declarations,
the source code files were not set up correctly and you must modify one or more of
them.
For example:
1. Suppose that the original SAVEGLOBALS compilation source file is COMP1 in
Example 17-13 on page 17-12.
2. Extract all directives and declarations from the beginning of COMP1 to (but not
including) BEGINCOMPILATION. Put them in a new source file called GLOBALS
(see Example 17-14 on page 17-12).
4. In each file that depended on the global data declarations file that the original
COMP1 produced:
• Use a SOURCE directive to include GLOBALS.
The SOURCE directive must appear before any other declarations and must
be immediately followed by the BEGINCOMPILATION directive.
• After the BEGINCOMPILATION directive, specify any additional directives that
were originally specified in the compilation command.
Note. In the following directive topics, “Default:” identifies the default for the compiler directive
itself, not for its optional parameter(s). This default applies if a program does not contain the
compiler directive at all.
ASSERTION
ASSERTION executes a procedure when the condition specified in the active ASSERT
statement is true.
ASSERTION assertion-level ,
=
procedure-name
VST123.vsd
assertion-level
is an unsigned decimal constant in the range 0 through 32,767.
procedure-name
is the name of the procedure to execute if both:
• The condition defined in the active ASSERT statement is true.
• assertion-level is less than the assert-level in the active ASSERT
statement.
This procedure must not have parameters.
HP pTAL Reference Manual—523746-006
17 -19
Compiler Directives BEGINCOMPILATION
Default: None
Placement: • Anywhere in the source file (not in the compilation command)
• Must be the last directive on the directive line
Scope: Applies until another ASSERTION overrides it
Dependencies: Has no effect without the ASSERT statement
References: ASSERT on page 12-3
ASSERT on page 12-3 explains how to use the ASSERTION directive and the
ASSERT statement together.
BEGINCOMPILATION
Note. The EpTAL compiler ignores this directive. See Migrating from TNS/R to TNS/E on
page 17-11.
BEGINCOMPILATION
VST991.vsd
Default: None
Placement: • In the source file between the last global data declaration and the
first procedure declaration, including any EXTERNAL and
FORWARD declarations
• Can appear only once in a compilation unit
Scope: Applies to all source code that follows it in 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
• Interacts with SAVEGLOBALS and USEGLOBALS (see Saving and
Using Global Data Declarations on page 17-8)
References: • SAVEGLOBALS on page 17-56
• USEGLOBALS on page 17-69
BLOCKGLOBALS
BLOCKGLOBALS determines how the compiler allocates global data that is not
declared within the scope of a named data block or the private data block.
BLOCKGLOBALS
VST658.vsd
Default: The compiler allocates data items in the _GLOBAL and $_GLOBAL data
blocks
Placement: Before the first data declaration in a compilation
Scope: Applies to the compilation unit
Dependencies: None
If you specify BLOCKGLOBALS, the compiler allocates its own data block for each
global variable that is not declared in the scope of a named data block or the private
data block. The name of the data block is the same as the name of the variable
contained in the data block.
Separately compiled modules can share access to a data block only if both modules
allocate the block in the small data area or both modules allocate the block in the large
data area.
References to data in the small data area are faster than references to data in the
large data area.
All data blocks in a shared run-time library must be allocated in the large data area.
If the name of a variable is the same as the name of the data block in which the
variable is located, and the block only contains one variable, the compiler allocates the
data block in the small data area if the length of the block is eight or fewer bytes;
otherwise, the compiler allocates the data block in the large data area. (This is the
allocation strategy used by the native HP C compiler.)
The compiler does not allocate memory for LITERALs, DEFINEs, or templates and,
therefore, does not create an implicit global data block for these items.
CALL_SHARED
Note.
• This directive is useful only for the pTAL compiler. The EpTAL compiler ignores it (and
issues a warning).
• You cannot link PIC and non-PIC object files into a single object file.
CALL_SHARED
NOCALL_SHARED
VST036.vsd
CALL_SHARED
generates shared code (PIC), the only option for the EpTAL compiler.
NOCALL_SHARED
causes the pTAL compiler to generate nonshared code (non-PIC).
CHECKSHIFTCOUNT
CHECKSHIFTCOUNT
NOCHECKSHIFTCOUNT
PUSHCHECKSHIFTCOUNT
POPCHECKSHIFTCOUNT
VST659.vsd
CHECKSHIFTCOUNT
generates code that causes an overflow trap if the number of positions in a bit-shift
operation is too large, as in:
INT j := 20;
INT i;
i := i << j;
(For more information about bit shifts, see Bit Shifts on page 5-33.)
NOCHECKSHIFTCOUNT
suppresses the generation of code that causes an overflow trap if the number of
positions in a bit-shift operation is too large.
PUSHCHECKSHIFTCOUNT
pushes the current setting (CHECKSHIFTCOUNT or NOCHECKSHIFTCOUNT)
onto the CHECKSHIFTCOUNT directive stack. Does not change the current
setting.
POPCHECKSHIFTCOUNT
pops the top value from the CHECKSHIFTCOUNT directive stack and changes the
current setting to that value.
For an explanation of directive stacks, see Directive Stacks on page 17-4.
Default: NOCHECKSHIFTCOUNT
Placement: Anywhere
Scope: • CHECKSHIFTCOUNT applies to the shift operators that follow it
until it is overridden by NOCHECKSHIFTCOUNT
• NOCHECKSHIFTCOUNT applies to the shift operators that follow it
until it is overridden by CHECKSHIFTCOUNT
Dependencies: None
CODECOV
Note.
• This directive can be used only with the EpTAL compiler.
• Instrumented object code can result in greatly reduced performance. Therefore, the
CODECOV directive should be used only in a test environment.
CODECOV causes the compiler to generate instrumented object code for use by the
Code Coverage Tool. For detailed information about the Code Coverage Tool, see the
Code Coverage Tool Reference Manual.
CODECOV
VST834.vsd
COLUMNS
COLUMNS causes the compiler to treat any text beyond the specified column as
comments.
COLUMNS columns-value
VST127.vsd
columns-value
is an unsigned decimal constant in the range 12 through 132, the column beyond
which the compiler is to treat text as comments.
If columns-value is smaller than 12 or larger than 132, the compiler issues an
error message.
The columns-value active at any given time depends on the context, as follows:
• The main input file initially has the columns-value set by the last COLUMNS
directive in the compilation command. If there was no COLUMNS directive in the
compilation command, the main input file initially has the default columns-value
of 132.
• At each SOURCE directive, each included file initially has the columns-value
active when the SOURCE directive appeared.
• At each SECTION directive, columns-value is set by the last COLUMNS
directive before the first SECTION directive in the included file. If there is no such
COLUMNS directive, each SECTION initially has the columns-value active at
the beginning of the included file.
• Within a section, a COLUMNS directive sets the columns-value only until the
next COLUMNS or SECTION directive or the end of the file.
• After a SOURCE directive completes execution (that is, after all sections listed in
the SOURCE directive are read or the end of the file is reached), the compiler
restores columns-value to what it was when the SOURCE directive appeared.
• In all other cases, columns-value is set by the most recently processed
COLUMNS directive.
If a SOURCE directive lists sections, the compiler processes no source code outside
the listed sections except any COLUMNS directives that appear before the first
SECTION directive in the included file. For more information about including files or
sections, see SOURCE on page 17-60 and SECTION on page 17-57.
DEFEXPAND
DEFEXPAND
NODEFEXPAND
PUSHDEFEXPAND
POPDEFEXPAND
VST023.vsd
DEFEXPAND
expands DEFINEs in the compiler listing.
NODEFEXPAND
suppresses the expansion of DEFINEs in the compiler listing.
PUSHDEFEXPAND
pushes the current setting (DEFEXPAND or NODEFEXPAND) onto the
DEFEXPAND directive stack. Does not change the current setting.
POPDEFEXPAND
pops the top value from the DEFEXPAND directive stack and changes the current
setting to that value.
For an explanation of directive stacks, see Directive Stacks on page 17-4.
Default: NODEFEXPAND
Placement: Anywhere
Scope: • DEFEXPAND applies to subsequent code it until it is overridden by
NODEFEXPAND
• NODEFEXPAND applies to subsequent code until it is overridden by
DEFEXPAND
Dependencies: DEFEXPAND has no effect if NOLIST or SUPPRESS is active
References: • LIST on page 17-44
• SUPPRESS on page 17-65
In the DEFEXPAND listing, the DEFINE body appears on lines following the DEFINE
identifier. In the listing:
• All letters are uppercase.
• No comments, line boundaries, or extra blanks appear.
• The lexical level of the DEFINE appears in the left margin, starting at 1.
• Parameters to the DEFINE appear as #n, where n is the sequence number of the
parameter, starting at 1.
DEFINETOG
DEFINETOG specifies toggles for use in conditional compilation, without changing
their settings. If DEFINETOG is specifying a toggle for the first time, its setting is off.
DEFINETOG toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST212.vsd
toggle-name
is an identifier.
The EpTAL compiler allows toggle-name to be RISC1, _TNS_E_TARGET, or
TARGETSPECIFIED, as long as toggle-name does not change the value of
target in the IF, IFNOT, or ENDIF statement (see IF and IFNOT on page 17-39
and ENDIF on page 17-29).
toggle-number
is an unsigned decimal constant in the range 1 through 15. Leading zeros are
ignored.
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• SETTOG
• RESETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • ENDIF on page 17-29
• IF and IFNOT on page 17-39
• RESETTOG on page 17-54
• SETTOG on page 17-58
DO_TNS_SYNTAX
DO_TNS_SYNTAX
NODO_TNS_SYNTAX
PUSHDO_TNS_SYNTAX
POPDO_TNS_SYNTAX
VST663.vsd
DO_TNS_SYNTAX
issues a warning for each occurrence of certain constructs that are valid in pTAL
but not in TAL (for these constructs, see the pTAL Conversion Guide).
NODO_TNS_SYNTAX
suppresses warnings for each occurrence of a construct that is valid in pTAL but
not in 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.
Default: NODO_TNS_SYNTAX
Placement: • Can appear only once in a compilation
• Must precede any TARGET directive and any nondirective lines
Scope: Applies to the compilation unit
Dependencies: None
References: TARGET on page 17-68
ENDIF
ENDIF identifies the end of code that is to be conditionally compiled.
ENDIF toggle-name
toggle-number
target
pTAL
VST693.vsd
toggle-name
is an identifier that was used as a toggle-name in an earlier IF or IFNOT
directive.
toggle-number
is an unsigned decimal constant in the range 1 through 15 that was used as a
toggle-name in an earlier IF or IFNOT directive. Leading zeros are ignored.
target
is as defined in IF and IFNOT on page 17-39.
pTAL
identifies the end of code that is to be compiled by the pTAL or EpTAL compiler but
not by the TAL compiler:
Compiler IF pTAL IFNOT pTAL
pTAL or EpTAL True False
TAL False True
Default: None
Placement: • Anywhere in the source file (not in the compilation command)
• Must be the only directive on the directive line
Scope: Everything between ENDIF and the most recently compiled IF or IFNOT
directive that specifies the same toggle, target, or keyword
Dependencies: Interacts with:
• DEFINETOG
• SETTOG
• RESETTOG
• IF
• IFNOT
• TARGET
See Toggles on page 17-5.
References: • DEFINETOG on page 17-27
• IF and IFNOT on page 17-39
• RESETTOG on page 17-54
• SETTOG on page 17-58
• TARGET on page 17-68
ERRORFILE
ERRORFILE writes compilation errors and warnings to an error file so you can use the
HP TACL FIXERRS macro (available only on Guardian platforms) to view the
diagnostic messages in one PS Text Edit window and correct the source file in another
window.
ERRORFILE file-name
define-name
assign-name
VST137.vsd
file-name
is the name of either:
• An existing error file created by ERRORFILE. Such a file has file code 106 (an
entry-sequenced disk file used only with the HP TACL FIXERRS macro). The
compiler purges any data in it before logging errors and warnings.
• A new error file to be created by ERRORFILE if errors occur.
If a file with the same name exists but the file code is not 106, the compiler
terminates compilation to prevent overwriting the file.
You can specify partial file names as described in Partial File Names on page B-3.
The compiler uses the current default volume and subvolume names as needed.
For this directive, the compiler does not use HP TACL ASSIGN SSV information
(available only on Guardian platforms) to complete the file name.
define-name
is the name of a MAP DEFINE that refers to an error file.
assign-name
is a logical file name you have equated with an error file by issuing an ASSIGN
command.
Default: None
Placement: • In the compilation command or in the source code before any
declarations
• Can appear only once in a compilation unit
Scope: Applies to the compilation unit
Dependencies: None
The compiler writes a header record to the error file and then writes a record for each
error or warning. Each record contains information such as:
• The location of the error or warning—source file name, edit line number, and
column number
• The message text of the error or warning
At the end of the compilation, the compiler prints the complete name of the error file in
the trailer message of the compilation listing.
After the compiler logs messages to the error file, you can call the HP TACL FIXERRS
macro and correct the source file. FIXERRS uses the PS Text Edit ANYHOW option to
open the source file in a two-window session. One window displays a diagnostic
message. The other window displays the source code to which the message applies. If
you have write access to the file, you can correct the source code. If you have only
read access, you can view the source code, but you cannot correct it.
Initially, the edit cursor is located in the source code at the first diagnostic. To move the
cursor to the next or previous diagnostic, use the PS Text Edit NEXTERR or
PREVERR command.
The HP TACL command for calling FIXERRS is:
FIXERRS error-file
; tedit-cmds
VST211.vsd
error-file
is the name of the error file specified in the ERRORFILE directive.
tedit-cmds
is any PS Text Edit commands that are allowed on the PS Text Edit run line.
Example 17-17 on page 17-32 issues an HP TACL DEFINE command that calls
FIXERRS and defines PS Text Edit function keys for NEXTERR and PREVERR.
ERRORS
ERRORS sets the maximum number of error messages to allow before the compiler
terminates the compilation.
ERRORS num-messages
=
VST138.vsd
num-messages
is an unsigned decimal constant in the range 0 through 32,767 that represents the
maximum number of error messages to allow before the compilation terminates.
A single error can cause many error messages. The compiler counts each error
message separately. If the compiler’s count exceeds the maximum you specify, the
compiler terminates the compilation. (Warning messages do not affect the count.)
EXPORT_GLOBALS
EXPORT_GLOBALS
NOEXPORT_GLOBALS
PUSHEXPORT_GLOBALS
POPEXPORT_GLOBALS
VST662.vsd
EXPORT_GLOBALS
causes the compiler to define (rather than only declare) global data blocks,
allocating space for them and (optionally) giving them initial values, and causes the
linker to include in the program file all global data blocks declared up to the next
occurrence of NOEXPORT_GLOBALS or through the last declared global data
block, whichever is first.
NOEXPORT_GLOBALS
causes the compiler to declare (rather than define) global data blocks.
PUSHEXPORT_GLOBALS
pushes the current setting (EXPORT_GLOBALS or NOEXPORT_GLOBALS) onto
the EXPORT_GLOBALS directive stack. Does not change the current setting.
POPEXPORT_GLOBALS
pops the top value from the EXPORT_GLOBALS directive stack and changes the
current setting to that value.
Default: EXPORT_GLOBALS
Placement: • Can appear any number of times in a compilation unit
• Must appear before the first procedure is compiled
• Cannot appear within BLOCK declarations
Scope: 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 USEGLOBALS, the compiler exports
the data blocks declared in the USEGLOBALS declarations file only
if EXPORT_GLOBALS is active when the compiler encounters the
BEGINCOMPILATION directive.
References: • BEGINCOMPILATION on page 17-20
• SRL on page 17-65
• USEGLOBALS on page 17-69
You can export only whole data blocks. You cannot export individual variables declared
within a data block.
The compiler exports initialization values for variables that specify them. If a data block
is not being exported, the compiler ignores any specified initial values within the block.
You must export every data block in at least one compilation.
FIELDALIGN
FIELDALIGN specifies the default alignment for structures.
FIELDALIGN ( SHARED2 )
SHARED8
PLATFORM
AUTO
NODEFAULT
VST660.vsd
SHARED2
specifies that the base of the structure and each field in the structure must begin at
an even-byte address except STRING fields. For more information, see SHARED2
on page 9-6.
SHARED8
specifies that the offset of each field in the structure from the base of the structure
must be begin at an address that is an integral multiple of the width of the field. For
more information, see SHARED8 on page 9-6.
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 is not
the same behavior as the AUTO attribute has in the native mode HP C compiler).
For more information, see AUTO on page 9-7.
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. For more
information, see PLATFORM on page 9-7.
NODEFAULT
specifies that every structure declaration must include a FIELDALIGN Clause on
page 9-20.
Default: FIELDALIGN AUTO
Placement: • Can appear only once in a compilation unit
• Must precede all declarations of data, blocks, and procedures
Scope: Applies to the compilation unit
Dependencies: None
FMAP
FMAP
NOFMAP
VST141.vsd
FMAP
lists the file map in the compiler listing.
NOFMAP
suppresses the file map in the compiler listing.
Default: NOFMAP
Placement: Anywhere, any number of times. The last FMAP or NOFMAP in the
compilation unit determines whether the compiler lists the file map.
Scope: Applies to the compilation unit
Dependencies: FMAP has no effect if either NOLIST or SUPPRESS is active
References: • LIST on page 17-44
• SUPPRESS on page 17-65
GLOBALIZED
Note. This directive is valid only with the EpTAL compiler.
The GLOBALIZED directive directs the compiler to generate preemptable object code.
Preemptable object code allows named references in a DLL to resolve to externally-
defined code and data items instead of to the DLL’s own internally-defined code and
data items. You must specify the GLOBALIZED directive when compiling code that will
be linked into a globalized DLL. By default, the compiler generates non-preemptable
object code. Non-preemptable code is more efficient than preemptable code and
results in faster compilation and execution, so you should specify GLOBALIZED only
when required.
GLOBALIZED
VST835.vsd
GMAP
GMAP
NOGMAP
VST142.vsd
GMAP
lists the global map in the compiler listing.
NOGMAP
suppresses the global map in the compiler listing.
Default: GMAP
Placement: Anywhere, any number of times. The last GMAP or NOGMAP in the
compilation unit determines whether the compiler lists the global map.
Scope: Applies to the compilation unit
Dependencies: • GMAP has no effect if NOLIST, NOMAP, or SUPPRESS is active
• NOGMAP suppresses the global map even if MAP is active
References: • LIST on page 17-44
• MAP on page 17-45
• SUPPRESS on page 17-65
GP_OK
Note. The EpTAL compiler ignores these directives.
GP_OK
NOGP_OK
PUSHGP_OK
POPGP_OK
VST661.vsd
GP_OK
causes the pTAL compiler to generate code that has GP-relative addressing
(“small” data).
NOGP_OK
suppresses the generation of code that has GP-relative addressing. (This is the
only option for the EpTAL compiler.)
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 Directive Stacks on page 17-4.
A pTAL program that references data in a shared run-time library (SRL) must specify
NOGP_OK when it declares a data block that belongs to a shared run-time library. This
behavior prevents the pTAL compiler from using GP-relative addressing for references
to data in an SRL.
IF and IFNOT
IF and IFNOT identify the beginning of code that is to be conditionally compiled.
IF toggle-name
IFNOT toggle-number
target
pTAL
VST694.vsd
toggle-name
was specified by one of the following:
• DEFINETOG on page 17-27
• SETTOG on page 17-58
• RESETTOG on page 17-54
IF compiles the conditional code only if toggle-name is on.
IFNOT compiles the conditional code only if toggle-name is off.
The EpTAL compiler allows toggle-name to be RISC1, _TNS_E_TARGET, or
TARGETSPECIFIED, as long as toggle-name does not change the value of
target in the IF, IFNOT, or ENDIF statement.
toggle-number
is an unsigned decimal constant in the range 1 through 15. Leading zeros are
ignored.
IF compiles the conditional code only if toggle-name is on.
target
ANY
RISC1
TNS_ARCH
TNSR_ARCH
_TNS_E_TARGET
TARGETSPECIFIED
VST695.vsd
ANY
tests for a TARGET ANY directive in the current compilation.
RISC1
tests for a TARGET RISC1 directive in the current compilation.
TNS_ARCH
tests for a TARGET TNS_ARCH directive in the current compilation.
TNS_R_ARCH
tests for a TARGET TNS_R_ARCH directive in the current compilation.
_TNS_E_TARGET
tests for a TARGET _TNS_E_TARGET directive in the current compilation.
TARGETSPECIFIED
tests for a TARGET directive in the current compilation.
pTAL
identifies the beginning of code that is to be compiled by the pTAL or EpTAL
compiler but not by the TAL compiler:
Compiler IF pTAL IFNOT pTAL
pTAL or EpTAL True False
TAL False True
Default: None
Placement: • Anywhere in the source file (not in the compilation command)
• Must be the last directive on the directive line
Scope: Everything between IF or IFNOT and the next ENDIF that specifies the
same toggle, target, or keyword
Dependencies: Interacts with:
• ENDIF
• DEFINETOG
• SETTOG
• RESETTOG
• TARGET
See Toggles on page 17-5.
References: • DEFINETOG on page 17-27
• ENDIF on page 17-29
• RESETTOG on page 17-54
• SETTOG on page 17-58
• TARGET on page 17-68
If you insert an ENDIF for the IF in the code in Example 17-21 on page 17-41, as in
Example 17-22 on page 17-42, the compiler skips only the first part.
An asterisk (*) appears in column 11 of the listing for any statements not compiled
because of the IF or IFNOT directive.
INNERLIST
INNERLIST
NOINNERLIST
PUSHINNERLIST
POPINNERLIST
VST149.vsd
INNERLIST
lists mnemonics for each statement after that statement in the compiler listing.
NOINNERLIST
suppresses the mnemonics for each statement after that statement in the compiler
listing.
PUSHINNERLIST
pushes the current setting (INNERLIST or NOINNERLIST) onto the INNERLIST
directive stack. Does not change the current setting.
POPINNERLIST
pops the top value from the INNERLIST directive stack and changes the current
setting to that value.
For an explanation of directive stacks, see Directive Stacks on page 17-4.
Default: NOINNERLIST
Placement: Anywhere
Scope: • INNERLIST applies to subsequent statements it until it is overridden
by NOINNERLIST
• NOINNERLIST applies to subsequent statements until it is
overridden by INNERLIST
Dependencies: INNERLIST has no effect if NOLIST or SUPPRESS is active
References: • LIST on page 17-44
• SUPPRESS on page 17-65
INVALID_FOR_PTAL
INVALID_FOR_PTAL forces the compiler to report an error message. Use it to identify
a TAL source file that the pTAL or EpTAL compiler must not compile.
INVALID_FOR_PTAL
VST701.vsd
Default: None
Placement: After IF or IFNOT and before ENDIF
Scope: Applies to code between itself and ENDIF
Dependencies: None
References: • IF and IFNOT on page 17-39
• ENDIF on page 17-29
LINES
LINES sets the maximum number of output lines per page if the list file is a line printer
or a process.
LINES num-lines
=
VST154.vsd
num-lines
is an unsigned decimal constant in the range 10 through 32,767.
Default: LINES 60
Placement: Anywhere
Scope: Applies until overridden by another LINES directive
Dependencies: Has no effect if the list file is a terminal
LIST
LIST
NOLIST
PUSHLIST
POPLIST
VST155.vsd
LIST
lists the source code in the compiler listing.
NOLIST
suppresses the source code the compiler listing.
PUSHLIST
pushes the current setting (LIST or NOLIST) onto the LIST directive stack. Does
not change the current setting.
POPLIST
pops the top value from the LIST directive stack and changes the current setting to
that value.
Default: LIST
Placement: Anywhere
Scope: • LIST applies to subsequent code it until it is overridden by NOLIST
• NOLIST applies to subsequent code until it is overridden by LIST
Dependencies: LIST has no effect if SUPPRESS is active
References: SUPPRESS on page 17-65
MAP
MAP
NOMAP
PUSHMAP
POPMAP
VST157.vsd
MAP
lists identifier maps in the compiler listing.
NOMAP
suppresses identifier maps in the compiler listing.
PUSHMAP
pushes the current setting (MAP or NOMAP) onto the MAP directive stack. Does
not change the current setting.
POPMAP
pops the top value from the MAP directive stack and changes the current setting to
that value.
For an explanation of directive stacks, see Directive Stacks on page 17-4.
Default: MAP
Placement: Anywhere
Scope: • MAP applies to subsequent code it until it is overridden by NOMAP
• NOMAP applies to subsequent code until it is overridden by MAP
Dependencies: MAP has no effect if NOLIST or SUPPRESS is active
References: • LIST on page 17-44
• SUPPRESS on page 17-65
MAP lists:
• Sublocal identifiers after each subprocedure
• Local identifiers after each procedure
• Global identifiers after the last procedure in the source program
Each identifier map includes:
Item Possible Values
Identifier class • VAR
• SUBPROC
• ENTRY
• LABEL
• DEFINE
• LITERAL
Type • Data type
• Structure
• Substructure
• Structure pointer
Addressing mode • Direct
• Indirect
Subprocedure, entry, or label offset
Text of LITERALs and DEFINEs
OPTIMIZE
OPTIMIZE level
=
VST665.vsd
level
Level Effect
0 Code is not optimized. Provided in case other optimization levels cause
errors or interfere with debugging. Supports symbolic debugging; data is
always in memory.
1 Code is optimized within statements and across statement boundaries. The
resulting code is more efficient than that produced by lower levels of
optimization and does not interfere with debugging.
2 Code is optimized within statements and across statement boundaries, and
the resulting code is more efficient than code produced by lower levels.
Note. If your program compiles successfully at level 0 but runs out of memory at level 1 or
2, either compile your program only at level 0 or split your program into smaller
subprograms and compile those at the same higher level.
Default: OPTIMIZE 1
Placement: Outside the boundary of a separately compiled program
Scope: The optimization level active at the beginning of a separately compiled
program determines the level of optimization for that program and any
programs it contains
Dependencies: None, but OPTIMIZEFILE can override OPTIMIZE in individual
procedures
References: OPTIMIZEFILE on page 17-47
OPTIMIZEFILE
OPTIMIZEFILE sets the optimization level for individual procedures and
subprocedures.
OPTIMIZEFILE filename
VST666.vsd
filename
is an EDIT file on Guardian platforms and a text file on Windows platforms. Each
line of the file must have this syntax:
routine-name optimize-level
# comment
blank line
VST064.vsd
routine-name
is either a:
• procedure name
• subprocedure name of the form
procedure-name.subprocedure-name
Each routine-name in filename must appear only once in filename.
optimize-level
is an integer. If it is not 0, 1, or 2, the compiler ignores the line. optimize-
level must be preceded by white space and it can be followed by white
space.
comment
is any text.
def 1
° Before routine-name
° After optimize-level
OVERFLOW_TRAPS
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
PUSHOVERFLOW_TRAPS
POPOVERFLOW_TRAPS
VST697.vsd
OVERFLOW_TRAPS
enables overflow traps throughout the program.
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.
For an explanation of directive stacks, see Directive Stacks on page 17-4.
PAGE
The first PAGE sets the string to be printed as part of the heading for each page. Each
subsequent PAGE prints the heading and causes a page eject.
PAGE
VST160.vsd
heading-string
is a character string of at most 122 characters. The default is an empty string.
PRINTSYM
PRINTSYM
NOPRINTSYM
VST162.vsd
PRINTSYM
lists symbols in the compiler listing.
NOPRINTSYM
suppresses symbols in the compiler listing.
Default: PRINTSYM
Placement: Anywhere
Scope: • PRINTSYM applies to subsequent declarations until overridden by
NOPRINTSYM
• NOPRINTSYM applies to subsequent declarations until overridden
by PRINTSYM
Dependencies: • PRINTSYM has no effect if NOLIST or SUPPRESS is active
• PRINTSYM interacts with SAVEGLOBALS and USEGLOBALS (see
Saving Global Data Declarations on page 17-9)
References: • LIST on page 17-44
• SAVEGLOBALS on page 17-56
• SUPPRESS on page 17-65
• USEGLOBALS on page 17-69
You can use PRINTSYM and NOPRINTSYM to list individual symbols or groups of
symbols, such as global, local, or sublocal declarations.
REFALIGNED
REFALIGNED ( 2 )
PUSHREFALIGNED
POPREFALIGNED
VST669.vsd
REFALIGNED
specifies the default alignment for pointers to nonstructure data items and
procedure reference parameters.
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 Directive Stacks on page 17-4.
Default: REFALIGNED 8
Placement: Anywhere
Scope: Applies to subsequent pointers to nonstructure data items and
procedure reference parameters until overridden by another REFALIGN
directive
Dependencies: None
RESETTOG
RESETTOG turns off either specified toggles or all numeric toggles.
RESETTOG
toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST164.vsd
toggle-name
is an identifier.
toggle-number
is an unsigned decimal constant in the range 1 through 15. Leading zeros are
ignored.
The EpTAL compiler allows toggle-name to be RISC1, _TNS_E_TARGET, or
TARGETSPECIFIED, as long as toggle-name does not change the value of
target in the IF, IFNOT, or ENDIF statement (see IF and IFNOT on page 17-39
and ENDIF on page 17-29).
RESETTOG with no arguments turns off all numeric toggles but does not affect named
toggles.
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• DEFINETOG
• SETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • DEFINETOG on page 17-27
• ENDIF on page 17-29
• IF and IFNOT on page 17-39
• SETTOG on page 17-58
ROUND
ROUND rounds FIXED values assigned to FIXED variables that have smaller fpoint
values than the values you are assigning.
ROUND
NOROUND
VST165.vsd
ROUND
turns on rounding. If the fpoint of the assignment value is greater than that of
the variable, ROUND first truncates the assignment value so that its fpoint is
one greater than that of the destination variable. The truncated assignment value is
then rounded away from zero as follows:
value = (IF value < 0 THEN value − 5 ELSE value + 5) / 10
In other words, if the truncated assignment value is negative, 5 is subtracted; if
positive, 5 is added. Then, an integer division by 10 is performed, and the result is
truncated again, this time by a factor of 10. Thus, if the absolute value of the least
significant digit of the initially truncated assignment value is 5 or more, a 1 is added
to the absolute value of the final least significant digit.
NOROUND
turns off rounding. That is, rounding does not occur when a FIXED value is
assigned to a FIXED variable that has a smaller fpoint. If the fpoint of the
assignment value is greater than that of the variable, the assignment value is
truncated and some precision is lost.
Default: NOROUND
Placement: Anywhere
Scope: • ROUND applies to subsequent code until overridden by NOROUND
• NOROUND applies to subsequent code until overridden by ROUND
Dependencies: None
SAVEGLOBALS
Note. The EpTAL compiler does not accept this directive. See Migrating from TNS/R to TNS/E
on page 17-11.
SAVEGLOBALS saves all global data declarations in a file for use in subsequent
compilations that specify the USEGLOBALS directive.
SAVEGLOBALS file-name
define-name
VST670.vsd
file-name
is the name of a disk file to which the compiler is to write the global data
declarations.
If file-name already exists, the compiler purges the existing file and creates an
unstructured global declarations file.
If the existing file is secured so that the compiler cannot purge it, the compilation
terminates.
The compiler uses the current default volume and subvolume names as needed
and lists the complete file name in the trailer message at the end of compilation.
For this directive, the compiler does not use HP TACL ASSIGN SSV information
(available only on Guardian platforms) to complete the file name.
define-name
is the name of a MAP DEFINE that refers to the disk file to which you want the
compiler to write the global data declarations.
Default: None
Placement: Either in the compilation command or in the source code before any
global data declarations
Scope: Applies to the compilation unit
Dependencies: • If SAVEGLOBALS and USEGLOBALS appear in the same
compilation unit, the compiler uses only the one that appears first
• The compilation unit must have exactly one BEGINCOMPILATION
directive
• Interacts with the directives referenced in the next row (see Saving
and Using Global Data Declarations on page 17-8)
References: • BEGINCOMPILATION on page 17-20
• PRINTSYM on page 17-52
• SYMBOLS on page 17-66
• SYNTAX on page 17-67
• USEGLOBALS on page 17-69
SECTION
SECTION gives a name to a section of a source file for use in a SOURCE directive.
SECTION section-name
VST171.vsd
section-name
is an identifier.
Default: None
Placement: • Only in the source file (not in the compilation command)
• Must be the only directive on the directive line
Scope: Applies to subsequent code until another SECTION directive or the end
of the file, whichever is first
Dependencies: Interacts with SOURCE (see Section Names on page 17-61)
References: SOURCE on page 17-60
SETTOG
SETTOG turns on either specified toggles or all numeric toggles.
SETTOG
toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST172.vsd
toggle-name
is an identifier.
The EpTAL compiler allows toggle-name to be RISC1, _TNS_E_TARGET, or
TARGETSPECIFIED, as long as toggle-name does not change the value of
target in the IF, IFNOT, or ENDIF statement (see IF and IFNOT on page 17-39
and ENDIF on page 17-29).
toggle-number
is an unsigned decimal constant in the range 1 through 15. Leading zeros are
ignored.
SETTOG with no arguments turns on all numeric toggles but does not affect named
toggles.
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• DEFINETOG
• RESETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • DEFINETOG on page 17-27
• ENDIF on page 17-29
• IF and IFNOT on page 17-39
• RESETTOG on page 17-54
SOURCE
SOURCE reads source code from another source file.
SOURCE
file-name
define-name ( section-name )
assign-name ,
VST173.vsd
file-name
is the name of a disk file from which the compiler is to read source code. On
Guardian platforms, the compiler uses HP TACL ASSIGN SSV information, if
specified, to complete the file name; otherwise, the compiler uses the current
default volume and subvolume names as needed.
define-name
is the name of a MAP DEFINE that refers to a disk file from which the compiler is
to read source code.
assign-name
is a logical file name you have equated to a disk file (from which the compiler is to
read source code) by issuing an ASSIGN command.
section-name
is an identifier specified within the included file by a SECTION directive. If the
compiler does not find section-name in the specified file, it issues a warning.
The list of section names can extend to continuation lines.
Default: None
Placement: • Only in the source file (not in the compilation command)
• Must be the last directive on the directive line
Scope: Applies to the source file
Dependencies: • Interacts with COLUMNS
• Interacts with SECTION (see Section Names on page 17-61)
• Interacts with the directives referenced in the next row (see Effect of
Other Directives on page 17-62)
References: • BEGINCOMPILATION on page 17-20
• COLUMNS on page 17-24
• LIST on page 17-44
• SECTION on page 17-57
• SUPPRESS on page 17-65
• USEGLOBALS on page 17-69
Topics:
• Section Names on page 17-61
• Nesting Levels on page 17-62
• Effect of Other Directives on page 17-62
• Including System Procedure Declarations on page 17-63
• Examples on page 17-64
Section Names
If you specify SOURCE with no section names, the compiler processes the specified
source file until the end of that file. The compiler treats any SECTION directives in the
source file as comments.
If you specify SOURCE with section names, the compiler processes the source file
until it reads all the specified sections. A section begins with a SECTION directive and
ends with another SECTION directive or the end of the file, whichever comes first.
The compiler reads the sections in order of appearance in the source file, not in the
order specified in the SOURCE directive. If you want the compiler to read sections in a
particular order, use a separate SOURCE directive for each section and place the
SOURCE directives in the desired order.
Nesting Levels
You can nest SOURCE directives to a maximum of seven levels, not counting the
original outermost source file. For example, the deepest nesting allowed is as follows:
1. The MAIN file F sources in file F1.
2. File F1 sources in file F2.
3. File F2 sources in file F3.
4. File F3 sources in file F4.
5. File F4 sources in file F5.
6. File F5 sources in file F6.
7. File F6 sources in file F7.
COLUMNS
If a SOURCE directive specifies sections of a file, the compiler honors all COLUMNS
directives in that file that precede the first section of that file. (The first section of the file
might not be the first section of the file that the SOURCE directive specifies.) The
compiler also honors COLUMN directives that appear in the sections that the SOURCE
directive specifies.
After a SOURCE directive completes execution, the value of COLUMNS is restored to
what it was before the SOURCE directive:
File1:
?COLUMNS 80
...
File2:
?COLUMNS 100
...
?SOURCE file1
! COLUMNS is restored to 100 at this point
NOLIST
You can precede SOURCE with NOLIST to suppress the listings of procedures to be
read in. Place NOLIST and SOURCE on the same line, because the line containing
NOLIST is not suppressed:
?PUSHLIST, NOLIST, SOURCE $src.current.routines
! Suppress listings, read in external declarations of routines
?POPLIST
A procedure in the same source file can then call the procedures listed in the
preceding SOURCE directive, as in Example 17-32 on page 17-64.
Examples
The SOURCE directive in Example 17-33 on page 17-64 instructs the compiler to
process the file until an end of file occurs. (Any SECTION directives in the file
ROUTINES are treated as comments.)
This SOURCE directive in Example 17-34 on page 17-64 reads three sections from the
source file. It reads the files in the order in which they appear in the source file, not in
the order specified in the SOURCE directive. (The specified files appear in the source
file in the order sec3, sec2, and sec1, so they are read in that order.)
Example 17-35 on page 17-64 shows how you can specify the order in which the
compiler is to read the sections, regardless of their order in the source file.
SRL
Note. The EpTAL compiler ignores this directive.
SRL causes the pTAL compiler to generate code that can be linked into a user library.
You must specify SRL to be able to link the object file created by the compilation into a
user library.
SRL
VST671.vsd
Default: None
Placement: Anywhere
Scope: Applies to the compilation unit
Dependencies: When declaring a data block that belongs to an SRL, you must specify
NOEXPORT_GLOBALS and NOGP_OK.
References: • EXPORT_GLOBALS on page 17-33
• GP_OK on page 17-38
SUPPRESS
SUPPRESS
NOSUPPRESS
VST176.vsd
SUPPRESS
suppresses all compilation listings except the compiler leader text, diagnostic
messages, and the trailer text. (Does not alter the source code.)
NOSUPPRESS
allows all compilation listings.
Default: NOSUPPRESS
Placement: Anywhere
Scope: Applies to the compilation unit
Dependencies: Overrides all the listing directives (referenced in the next row)
References: • DEFEXPAND on page 17-26
• FMAP on page 17-36
• GMAP on page 17-37
• INNERLIST on page 17-42
• LIST on page 17-44
• MAP on page 17-45
• PAGE on page 17-51
• PRINTSYM on page 17-52
The compilation command in Example 17-36 on page 17-66 starts the compilation and
suppresses all source code listings and maps from printing in the compiler output.
SYMBOLS
SYMBOLS saves symbols in a symbol table in the object file, enabling you use a
symbolic debugger to debug the object file.
SYMBOLS
NOSYMBOLS
VST672.vsd
SYMBOLS
saves all symbols information.
NOSYMBOLS
saves information about:
• Procedure memos
• Global data block names
• Line numbers
Does not save information about parameters, local variables, data types, and so
on.
Default: NOSYMBOLS
Placement: Before the first declaration in the compilation
Scope: The last legally placed SYMBOLS or NOSYMBOLS applies to the
compilation unit
Dependencies: Interacts with SAVEGLOBALS and USEGLOBALS (see Saving Global
Data Declarations on page 17-9)
References: • SAVEGLOBALS on page 17-56
• USEGLOBALS on page 17-69
Usually you save symbols for the entire compilation by specifying SYMBOLS once at
the beginning of the compilation unit. The symbol table then contains all the symbols
generated by the source code.
After debugging the program, you can use the linker to create a new, smaller object file
without symbols. The executable portion of the old object file remains intact, but you
dramatically reduce what you can do with a symbolic debugger.
nld -x -r oldobj -o newobj
ld -x -r oldobj -o newobj
eld -x -r oldobj -o newobj
Use the linker option -s when linking a loadfile, or use the strip utility after creating
the loadfile.
STRIP oldobj
SYNTAX
SYNTAX checks the syntax of the source text without producing an object file.
SYNTAX
VST178.vsd
The compilation command in Example 17-38 on page 17-68 checks the syntax of
global data declarations in source file myprog and saves the declarations in file
ptalsym for use in subsequent compilations.
The compilation command in Example 17-39 on page 17-68 checks for the syntax of
the code or data in source file myprog. In this compilation, USEGLOBALS retrieves
global data declarations saved in the compilation shown in Example 17-38 on
page 17-68.
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
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. It is also the default for the EpTAL compiler.
TNS_ARCH
specifies the TNS architecture. The compiler does not accept this option.
T16
specifies the T16 architecture. The compiler does not accept this option.
TNS_R_ARCH
LIBERTY
specifies the Liberty architecture. The compiler does not accept this option.
ANY
specifies any architecture. The compiler does not accept this option.
USEGLOBALS
Note. The EpTAL compiler does not accept this directive. See Migrating from TNS/R to TNS/E
on page 17-11.
USEGLOBALS reads global data declarations and initializations that were saved in a
file by SAVEGLOBALS during a previous compilation.
USEGLOBALS file-name
define-name
VST674.vsd
file-name
is the name of the global declarations disk file created by SAVEGLOBALS in a
previous compilation.
On Guardian platforms, the compiler uses HP TACL ASSIGN SSV information, if
specified, to complete the file name; otherwise, the compiler uses the current
default volume and subvolume names as needed.
define-name
is the name of a MAP DEFINE that refers to the global declarations file.
assign-name
is a logical file name you have equated to a disk file (that refers to the global
declarations file) by issuing an ASSIGN command.
Default: None
Placement: Either in the compilation command or in the source code before any
global data declarations
Scope: Applies to the compilation unit
Dependencies: • The compilation unit must have exactly one BEGINCOMPILATION
directive.
• The compiler exports the data blocks declared in the USEGLOBALS
declarations file only if EXPORT_GLOBALS is active when the
compiler encounters the BEGINCOMPILATION directive.
• A module that specifies USEGLOBALS can export a global data
block that was declared in the compilation that specified
SAVEGLOBALS only if the SAVEGLOBALS compilation exported
the data block.
Typically, a project that uses SAVEGLOBALS explicitly links globals
into the object file and specifies NOEXPORT_GLOBALS (the
default) for all individual compilations.
• Interacts with the directives referenced in the next row (see Saving
and Using Global Data Declarations on page 17-8)
References: • BEGINCOMPILATION on page 17-20
• EXPORT_GLOBALS on page 17-33
• PRINTSYM on page 17-52
• SAVEGLOBALS on page 17-56
• SYMBOLS on page 17-66
• SYNTAX on page 17-67
WARN
WARN
NOWARN warning-number
VST675.vsd
WARN
prints specific (or all) warning messages in the compiler listing.
NOWARN
suppresses specific (or all) warning messages in the compiler listing.
warning-number
is the number of a warning message. The default is all warning messages.
If warning-number is outside the range of all pTAL warnings and all TAL
warnings, the compiler issues a warning. If warning-number is inside either
range but not assigned warning text, the compiler ignores the WARN directive. For
an explanation of how the compiler handles TAL warnings, see the pTAL
Conversion Guide.
Default: WARN
Placement: Anywhere
Scope: • WARN applies to subsequent code until overridden by NOWARN
• NOWARN applies to subsequent code until overridden by WARN;
however: To print selected warnings, you must specify WARN before
any NOWARN directives. If you specify NOWARN first, subsequent
WARN warning-number directives have no effect.
Dependencies: None
You can use NOWARN when a compilation produces a warning and you have
determined that no real problem exists. Before the source line that produces the
warning, specify NOWARN and the number of the warning you want suppressed.
Following that source line, specify a WARN directive.
If NOWARN is active, the compiler records the number of suppressed and
unsuppressed warnings. The compilation statistics at the end of the compiler listing
include the following counts:
Number of unsuppressed compiler warnings = count
Number of warnings suppressed by NOWARN = count
Unsuppressed compiler warnings are compiler warnings that are not suppressed by
NOWARN directives. The summary does not report the location of the last compiler
warning.
If no compiler errors and no unsuppressed compiler warnings occur, the completion
code is zero.
The following directive specifies that the compiler does not print warning message 12:
?NOWARN 12
On all Windows platforms, valid pTAL cross compiler source files must have the
extension .tal.
The pTAL cross compiler allows you to:
• Write, compile, and link NonStop RISC-based or Itanium-based server applications
(NonStop Guardian executable files, static libraries, user libraries, and DLLs) on
the PC and transfer them to the Guardian platform for use in production.
Object files built on the PC platform are functionally identical object files built in the
NonStop RISC-based or Itanium-based server platform.
• Link pTAL, C/C++, and NMCOBOL or ECOBOL objects into a single object file.
• When multiple RVUs are installed, use any installed RVUs of the cross compilers
and libraries. (Tools must come from the same RVU—HP does not test the
interactions of tools used in one RVU with tools from other RVUs.)
• On the ETK platform, enter ADD, MODIFY, SET, and DELETE statements into a
TACL DEFINE file (see TACL DEFINE Tool (ETK) on page 18-7).
The pTAL cross compiler is delivered on a separate CD and is not available on the site
update tape (SUT).
Topics:
• NonStop pTAL (ETK) on page 18-2
• pTAL or EpTAL (PC Command Line) on page 18-3
• Compilation and Linking on page 18-5
• Debugging on page 18-6
• Tools and Utilities on page 18-6
• Documentation on page 18-8
For PC and NonStop server hardware and software requirements, see the ETK online
help. For instructions for accessing the online help, see Documentation on page 18-8.
Note. Before you can use eptal, you must set the COMP_ROOT environment variable so
that it points to the root of the directory location of the cross compiler. For instructions, see
Using the Command-Line Cross Compilers on Windows.
ptal
sourcefile.tal
flag ptal-directive
VST033.vsd
ptal
calls the pTAL cross compiler from the command line. ptal is not case-sensitive.
eptal
calls the EpTAL cross compiler from the command line. eptal is not case-
sensitive.
object-file
is the name of the object file to be created. The default is sourcefile.o.
directory
is the name of a directory for the compiler to search. If no directory is specified, the
compiler searches only in the current working directory. If any directories are
specified, the compiler searches them in the order in which they are listed, but
does not search the current directory unless it is explicitly named.
flag
is one of the following:
flag Directs the compiler to:
-Whelp Display information about how to run the compiler. No compilation
system components are run.
-Wusage Display information about how to run the compiler. No compilation
system components are run.
-Wverbose Displays the command line used when the driver calls each
component of the compiler.
ptal-directive
is one of the following:
Directives Sources (page 1 of 2)
-blockglobals BLOCKGLOBALS on page 17-21
-[no]call_shared CALL_SHARED on page 17-22
-[no]checkshiftcount CHECKSHIFTCOUNT on page 17-23
-codecov (eptal only) CODECOV on page 17-24
-columns=n COLUMNS on page 17-24
-[no]defexpand DEFEXPAND on page 17-26
-[no]do_tns_syntax DO_TNS_SYNTAX on page 17-28
-errors=n ERRORS on page 17-33
-export_globals EXPORT_GLOBALS on page 17-33
-fieldalign(value) FIELDALIGN on page 17-35
-[no]fmap FMAP on page 17-36
-globalized (eptal only) GLOBALIZED on page 17-36
-[no]gmap GMAP on page 17-37
-[no]gp_ok GP_OK on page 17-38
-[no]innerlist INNERLIST on page 17-42
-invalid_for_ptal INVALID_FOR_PTAL on page 17-43
-[no]list LIST on page 17-44
-[no]map MAP on page 17-45
-optimize=n OPTIMIZE on page 17-47
-[no]overflow_traps OVERFLOW_TRAPS on page 17-49
-[no]printsym PRINTSYM on page 17-52
-refaligned(n) REFALIGNED on page 17-53
-resettog(value) RESETTOG on page 17-54
The command-line interface allows you to create batch scripts for use on multiple
platforms.
pTAL cross compiler linking is performed with one of the cross linkers:
Cross Linker Cross Compilers Directive Object Code
nld NonStop pTAL -nocall_shared* Non-PIC
ptal
ld NonStop pTAL -call_shared** PIC
ptal
eld NonStop pTAL -call_shared PIC
eptal
* Default for pTAL. EpTAL ignores it (and issues a warning).
** Default for EpTAL.
Note. You cannot link PIC and non-PIC object files into a single object file.
Debugging
On the ETK platform, debug pTAL source code using Visual Inspect. After Visual
Inspect is installed on your workstation, you can configure Visual Inspect as an
external tool.
On the command-line platform, debug loadfiles that were compiled through the pTAL
cross compiler either by using Visual Inspect on Windows or by running Native Inspect
on the NonStop RISC-based or Itanium-based server. To use Native Inspect, you must
copy the loadfiles and the source files to the host (see PC-to-NonStop-Host Transfer
Tools on page 18-7).
For more information:
Topic Source
Visual Inspect Visual Inspect online help
Native Inspect Native Inspect Manual
NonStop ar Utility
The NonStop ar utility creates and maintains archives composed of groups of object
files. After an archive has been created, new files can be added and existing files can
be extracted, deleted, or replaced.
The ar utility accepts all OSS files, Guardian TNS code files, Guardian C text files (file
code 180 files), TNS/R (PIC and non-PIC) native object files, and TNS/E native linkfiles
or loadfiles as archive members.
You can mix one or more object file formats in one archive file; however, such an
archive file will not contain the symbols table and cannot be used by the linker.
If an archive contains one or more native object files of the same format, the linker can
use the archive as an object file library, replacing most functions provided by the
Binder SELECT SEARCH command.
This cross linker can
If an archive contains one use the archive as an
or more ... object file library ... For more information, see ...
TNS/R non-PIC object files nld on a G-Series system nld Manual
TNS/R PIC object files ld ld Manual
TNS/E PIC object files eld eld Manual
ETK
The Deploy command builds and copies each project in the active solution to the
NonStop host.
The Transfer Tool moves any kind of files to the NonStop host for execution and
debugging.
The Transfer Tool is better for transferring very large, complex applications to the
NonStop host. For most applications, Deploy is more convenient.
PC Command Line
From the PC command line, you can use any FTP application to transfer executable
and source files to the NonStop host.
Documentation
The ETK has online help that provides conceptual, reference, task-oriented, and error
message information, as well as quick-start tutorials. To access the online help, do
either of the following:
• From the Help menu, select Contents, Index, or Search.
• Click the Help button in any ETK dialog box.
The command-line documentation, Using the Command-Line Cross Compilers on
Windows, is available:
• On the pTAL cross compiler CD
• On the EpTAL cross compiler CD
• In the ETK online help in the References chapter
Syntax information for pTAL and EpTAL is also available from the command-line:
ptal -Whelp
eptal -Whelp
Data Types
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
VST214.vsd
Constants
• Character String on page A-2
• STRING Numeric on page A-2
• INT Numeric on page A-2
• INT(32) Numeric on page A-2
• FIXED Numeric on page A-3
• REAL and REAL(64) Numeric on page A-3
• Constant List on page A-3
Character String
VST001.vsd
STRING Numeric
integer
base
VST002.vsd
INT Numeric
integer
+ base
VST027.vsd
INT(32) Numeric
ns
integer D
ns
+ base %D
VST028.vsd
FIXED Numeric
integer
+ base
-
. fraction %F
VST005.vsd
integer . fraction
+
E exponent
L +
VST006.vsd
Constant List
repetition-constant-list
FIELDALIGN ( SHARED2 )
SHARED8
[ repetition-constant-list ]
constant-list-seq
VST621.vsd
repetition-constant-list
[ constant-list-seq ]
repetition-factor *
VST008.vsd
constant-list-seq
constant
repetition-constant-list
VST029.vsd
Expressions
• Arithmetic on page A-4
• Conditional on page A-5
• Assignment on page A-5
• CASE on page A-5
• IF on page A-5
• Group Comparison on page A-6
• Bit Extraction on page A-6
• Bit Shift on page A-6
Arithmetic
+ operand
- arithmetic-operand operand
VST010.vsd
Conditional
condition
NOT AND
OR
VST996.vsd
Assignment
variable := expression
VST012.vsd
CASE
END
OTHERWISE expression ;
VST013.vsd
IF
VST014.vsd
Group Comparison
var-1 relational-operator
constant-list
-> next-addr
VST015.vsd
Bit Extraction
ns
int-expression
ns ns
. < left-bit >
ns ns ns
: right-bit
VST016.vsd
Bit Shift
dbl-expression
VST017.vsd
Declarations
• LITERAL on page A-7
• DEFINE on page A-7
• Simple Variable on page A-8
• Array on page A-8
• Read-Only Array on page A-9
• Structures on page A-9
• Redefinition on page A-16
• Pointer on page A-21
• Equivalenced Variable on page A-22
• Procedure and Subprocedure on page A-28
LITERAL
LITERAL identifier
= constant
VST018.vsd
DEFINE
DEFINE item-list ;
VST019.vsd
item-list
identifier = define-body #
param-list
VST995.vsd
param-list
( param-name )
VST994.vsd
Simple Variable
type
VOLATILE
identifier ;
:= initialization
,
VST622.vsd
Array
type identifier
range ;
. := initialization
.EXT
.SG
.SGX
VST021.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Read-Only Array
type identifier =
range
'p' := initialization ;
VST022.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Structures
• Definition Structure on page A-10
• Template Structure on page A-11
• Referral Structure on page A-12
• Simple Variables Declared in Structure on page A-12
• Arrays Declared in Structure on page A-13
• Definition Substructure on page A-13
• Referral Substructure on page A-14
• Filler in Structure on page A-14
• Simple Pointers Declared in Structure on page A-15
• Structure Pointers Declared in Structure on page A-16
Definition Structure
STRUCT identifier
.
.EXT
.SG
.SGX
structure-layout ;
range field-alignment
VST624.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
Template Structure
STRUCT identifier ( * )
STRUCTALIGN ( MAXALIGN )
structure-layout ;
field-alignment
VST625.vsd
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
Referral Structure
.EXT
.SG
.SGX
range
VST025.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
type identifier ;
VOLATILE ,
VST705.vsd
VST201.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Definition Substructure
STRUCT identifier
structure-layout ;
field-alignment range
VST626.vsd
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Referral Substructure
range
VST203.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Filler in Structure
FILLER constant-expression ;
BIT_FILLER
VST026.vsd
type
VOLATILE
identifier
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
VST627.vsd
STRING
VOLATILE INT
identifier ( referral )
.EXT
.SG
.SGX
REFALIGNED ( 2 )
VST628.vsd
Redefinition
• Simple Variable on page A-17
• Array on page A-17
• Definition Substructure on page A-18
• Referral Substructure on page A-19
• Simple Pointer on page A-19
• Structure Pointer on page A-20
Simple Variable
VST706.vsd
Array
type
identifier = previous-identifier ;
range
VST030.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Definition Substructure
STRUCT identifier
range field-alignment
= previous-identifier ; structure-layout ;
VST707.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
Referral Substructure
= previous-identifier ;
range
VST208.vsd
range
[ lower-bound : upper-bound ]
VST993.vsd
Simple Pointer
type identifier
VOLATILE .
.EXT
.SG
.SGX
REFALIGNED ( 2 )
= previous-identifier ;
VST708.vsd
Structure Pointer
STRING identifier
VOLATILE INT .
.EXT
.SG
.SGX
( referral )
REFALIGNED ( 2 )
= previous-identifier ;
VST709.vsd
Pointer
• Simple on page A-21
• Structure on page A-22
• System Global on page A-22
Simple
type
VOLATILE
identifier
.
.EXT
.SG
.SGX
REFALIGNED ( 2 )
;
:= initialization
VST676.vsd
Structure
STRING
VOLATILE INT
identifier ( referral )
.EXT
.SG
.SGX
;
:= initialization
VST677.vsd
System Global
type
.SG identifier ;
:= preset-address
,
VST020.vsd
Equivalenced Variable
• Nonstructure on page A-23
• Simple Variable on page A-24
• Simple Pointer on page A-24
• Definition Structure on page A-25
• 'SG'-Equivalenced Simple Variable on page A-26
Nonstructure
VOLATILE
= previous-identifier
;
[ index ]
+ offset
-
VST629.vsd
Simple Variable
type
VOLATILE
identifier ( referral )
= previous-identifier
;
[ index ]
+ offset
-
VST004.vsd
Simple Pointer
type
VOLATILE
identifier ( referral )
.
.EXT = previous-identifier
.SG
.SGX ;
[ index ]
+ offset
-
VST630.vsd
Definition Structure
.EXT
.SG
.SGX
= previous-identifier
field-alignment
;
[ index ] structure-layout
+ offset
VST632.vsd
field-alignment
FIELDALIGN ( SHARED2 )
SHARED8
AUTO
PLATFORM
VST992.vsd
type
identifier =
'SG' ;
[ index ]
+ offset
-
VST068.vsd
.SG
.SGX
; structure-layout ;
[ index ]
+ offset
-
VST710.vsd
.SGX
.EXT
= 'SG' ;
[ index ]
+ offset
-
VST703.vsd
.SGX
.EXT
;
[ index ]
+ offset
-
VST704.vsd
STRING . identifier
INT .SG
.SGX
.EXT
( referral ) = 'SG'
;
[ index ]
+ offset
-
VST711.vsd
Procedure
PROC identifier
type public-name-spec
parameter-list proc-attribute
,
proc-body ;
param-spec ; EXTERNAL
FORWARD
VST058.vsd
type
See Data Types on page A-1.
public-name-spec
VST209.vsd
parameter-list
( param-name )
param-pair
,
VST210.vsd
param-pair
string : length
VST039.vsd
proc-attribute
MAIN
INTERRUPT
RESIDENT
CALLABLE
PRIV
VARIABLE
EXTENSIBLE
( count )
RETURNSCC
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
LANGUAGE C
COBOL
FORTRAN
PASCAL
UNSPECIFIED
VST635.vsd
Note.
• The EpTAL compiler ignores INTERRUPT.
• Because no FORTRAN or Pascal compilers exist especially for TNS/R or TNS/E
architecture, LANGUAGE FORTRAN and LANGUAGE PASCAL have no meaning on
TNS/R or TNS/E architecture.
param-spec
See Formal Parameters on page A-33.
proc-body
BEGIN
local-decl subproc-decl
; ;
END
statement
VST061.vsd
Subprocedure
SUBPROC identifier
type parameter-list
VARIABLE
RETURNSCC
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
subproc-body ;
parameter-spec ; FORWARD
VST702.vsd
type
See Data Types on page A-1.
parameter-list
( param-name )
param-pair
,
VST210.vsd
param-pair
string : length
VST039.vsd
param-spec
See Formal Parameters on page A-33.
subproc-body
BEGIN
END ;
sublocal-decl statement
; ;
VST062.vsd
Formal Parameters
param-type
param-name
.
.EXT
.SG
.SGX
( referral )
REFALIGNED ( 2 )
VST636.vsd
param-type
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
STRUCT
BADDR
WADDR
EXTADDR
PROCADDR
CBADDR
CWADDR
SGBADDR
SGWADDR
SGXBADDR
SGXWADDR
PROC
type
VST637.vsd
Note. The EpTAL compiler does not allow you to assign label or subprocedure addresses
to CBADDR and CWADDR address types.
type
STRING
INT
REAL ( width )
UNSIGNED ( width )
FIXED
( fpoint )
VST214.vsd
Entry Point
ENTRY identifier ;
VST195.vsd
Label
LABEL identifier ;
VST196.vsd
Procedure Pointer
PROCPTR procptr-name
return-type
formal-param-names attributes ;
VST600.vsd
formal-param-names
( param-name )
param-pair
,
VST210.vsd
param-pair
string : length
VST039.vsd
attributes
MAIN
INTERRUPT
RESIDENT
CALLABLE
PRIV
VARIABLE
EXTENSIBLE
( count )
RETURNSCC
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
LANGUAGE C
COBOL
FORTRAN
PASCAL
UNSPECIFIED
VST635.vsd
Note.
• The EpTAL compiler ignores INTERRUPT.
• Because no FORTRAN or Pascal compilers exist especially for TNS/R or TNS/E
architecture, LANGUAGE FORTRAN and LANGUAGE PASCAL have no meaning on
TNS/R or TNS/E architecture.
formal-param-spec
procptr
param-type identifier
.EXT
.SG
.SGX
( referral )
,
VST712.vsd
Statements
• Compound on page A-39
• ASSERT on page A-40
• Assignment on page A-40
• Bit Deposit Assignment on page A-40
• CALL on page A-41
• Labeled CASE on page A-41
• Unlabeled CASE on page A-42
• DO-UNTIL on page A-42
• DROP on page A-42
• FOR on page A-43
• GOTO on page A-43
• IF on page A-43
• Move on page A-44
• RETURN on page A-44
• SCAN and RSCAN on page A-45
• USE on page A-45
• WHILE on page A-45
Compound
BEGIN END
statement ;
VST034.vsd
ASSERT
VST035.vsd
Assignment
The assignment statement assigns a value to a previously declared variable.
variable := expression
VST012.vsd
ns ns ns >
variable . < left-bit
ns ns ns
: right-bit
:= expression
VST037.vsd
CALL
identifier
CALL ( )
param-name
param-pair
,
VST038.vsd
param-pair
string : length
VST039.vsd
Labeled CASE
END
OTHERWISE -> ;
statement-2
VST041.vsd
case-alternative
case-label ->
lower-case-label .. upper-case-label
,
statement-1
;
VST042.vsd
Unlabeled CASE
CASE selector OF
BEGIN ;
statement
END
OTHERWISE ;
statement
VST040.vsd
DO-UNTIL
DO UNTIL condition
statement
VST046.vsd
DROP
DROP identifier
,
VST047.vsd
FOR
DO
BY step statement
VST048.vsd
GOTO
GOTO label-name
VST049.vsd
Note. Nonlocal GOTO statements are are inefficient and not recommended.
IF
IF condition THEN
statement
ELSE
statement
VST050.vsd
Move
destination :=
=:
&
constant
[ constant ]
constant-list
-> next-addr
VST051.vsd
RETURN
Note. The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
result-expression and a cc-expression and has the procedure attribute
RETURNSCC on page 14-8. The reason for this warning is in Appendix D, RETURN,
RETURNSCC, and C/C++ on TNS/E.
RETURN
cc-expression
result-expression
, cc-expression
VST052.vsd
RSCAN UNTIL
-> next-addr
VST053.vsd
USE
USE identifier
,
VST056.vsd
WHILE
WHILE condition DO
statement
VST057.vsd
Overflow Traps
OVERFLOW_TRAPS Directive
See OVERFLOW_TRAPS on page A-107.
BEGIN
: ENABLE_OVERFLOW_TRAPS
DISABLE_OVERFLOW_TRAPS
VST682.vsd
Built-in Routines
• Atomic on page A-46
• Nonatomic on page A-49
Atomic
• $ATOMIC_ADD on page A-47
• $ATOMIC_AND on page A-47
• $ATOMIC_DEP on page A-47
• $ATOMIC_GET on page A-48
• $ATOMIC_OR on page A-48
• $ATOMIC_PUT on page A-48
$ATOMIC_ADD
VST607.vsd
$ATOMIC_AND
VST608.vsd
$ATOMIC_DEP
value ) ;
VST609.vsd
$ATOMIC_GET
$ATOMIC_GET ( var ) ;
VST610.vsd
$ATOMIC_OR
VST611.vsd
$ATOMIC_PUT
VST612.vsd
Nonatomic
• $ABS on page A-52
• $ALPHA on page A-52
• $ASCIITOFIXED on page A-53
• $AXADR on page A-53
• $BADDR_TO_EXTADDR on page A-54
• $BADDR_TO_WADDR on page A-54
• $BITLENGTH on page A-54
• $BITOFFSET on page A-55
• $CARRY on page A-55
• $CHECKSUM on page A-56
• $COMP on page A-56
• $COUNTDUPS on page A-57
• $DBL on page A-57
• $DBLL on page A-58
• $DBLR on page A-58
• $DFIX on page A-58
• $EFLT on page A-59
• $EFLTR on page A-59
• $EXCHANGE on page A-59
• $EXECUTEIO on page A-60
• $EXTADDR_TO_BADDR on page A-60
• $EXTADDR_TO_WADDR on page A-61
• $FILL8, $FILL16, and $FILL32 on page A-61
• $FIX on page A-62
• $FIXD on page A-62
• $FIXEDTOASCII on page A-63
• $FIXEDTOASCIIRESIDUE on page A-63
• $FIXI on page A-64
• $FIXL on page A-64
$ABS
$ABS ( expression )
VST072.vsd
$ALPHA
$ALPHA ( int-expression )
VST073.vsd
$ASCIITOFIXED
VST606.vsd
$AXADR
Note. The EpTAL compiler does not support this routine. (The EpTAL compiler does allow
$AXADR as a DEFINE name.)
$AXADR ( variable )
VST116.vsd
$BADDR_TO_EXTADDR
$BADDR_TO_EXTADDR ( expression )
VST683.vsd
$BADDR_TO_WADDR
$BADDR_TO_WADDR ( expression )
VST684.vsd
$BITLENGTH
$BITLENGTH ( variable )
VST074.vsd
$BITOFFSET
$BITOFFSET ( variable )
VST075.vsd
$CARRY
$CARRY
VST076.vsd
$CHECKSUM
wordcount ) ;
VST613.vsd
$COMP
$COMP ( int-expression )
VST077.vsd
$COUNTDUPS
duplicationcount ) ;
VST614.vsd
$DBL
$DBL ( expression )
VST078.vsd
$DBLL
$DBLL ( expression )
VST079.vsd
$DBLR
$DBLR ( expression )
VST080.vsd
$DFIX
VST081.vsd
$EFLT
$EFLT ( expression )
VST082.vsd
$EFLTR
$EFLTR ( expression )
VST083.vsd
$EXCHANGE
VST615.vsd
$EXECUTEIO
Note. The EpTAL compiler does not support this routine.
lacsubcommand , rdstdevstatus ,
channel-status ) ;
VST616.vsd
$EXTADDR_TO_BADDR
$EXTADDR_TO_BADDR ( expression )
VST686.vsd
$EXTADDR_TO_WADDR
$EXTADDR_TO_WADDR ( expression )
VST687.vsd
$FILL8
CALL $FILL16
$FILL32
VST688.vsd
$FIX
$FIX ( expression )
VST084.vsd
$FIXD
$FIXD ( expression )
VST085.vsd
$FIXEDTOASCII
maxdigits ) ;
VST617.vsd
$FIXEDTOASCIIRESIDUE
, maxdigits , qresidue ) ;
VST618.vsd
$FIXI
$FIXI ( fixed-expression )
VST086.vsd
$FIXL
$FIXL ( fixed-expression )
VST087.vsd
$FIXR
$FIXR ( expression )
VST088.vsd
$FLT
$FLT ( expression )
VST089.vsd
$FLTR
$FLTR ( expression )
VST090.vsd
$FREEZE
Note.
• The EpTAL compiler does not support this procedure. Use $TRIGGER on page 15-88
instead. (The EpTAL compiler does allow $FREEZE as a DEFINE name.)
$FREEZE
VST619.vsd
$HALT
Note.
• The EpTAL compiler does not support this procedure. Use $TRIGGER on page 15-88
instead. (The EpTAL compiler does allow $HALT as a DEFINE name.)
$HALT
VST620.vsd
$HIGH
$HIGH ( dbl-expression )
VST091.vsd
$IFIX
VST092.vsd
$INT
$INT ( expression )
VST093.vsd
$INT_OV
Note. $INT_OV is supported in the D40 and later RVUs.
$INT_OV ( expression )
VST689.vsd
$INTERROGATEHIO
Note. The EpTAL compiler does not support this routine.
) ;
VST643.vsd
$INTERROGATEIO
Note. The EpTAL compiler does not support this routine.
) ;
VST644.vsd
$INTR
$INTR ( expression )
VST094.vsd
$LEN
$LEN ( variable )
VST096.vsd
$LFIX
VST097.vsd
$LMAX
VST098.vsd
$LMIN
VST099.vsd
$LOCATESPTHDR
Note. The EpTAL compiler does not support this routine.
sptbase ) ;
VST645.vsd
$LOCKPAGE
Note. The EpTAL compiler does not support this routine.
virtaddr ) ;
VST646.vsd
$MAX
VST100.vsd
$MIN
VST101.vsd
$MOVEANDCXSUMBYTES
$MOVEANDCXSUMBYTES ( checksum ,
VST647.vsd
$MOVENONDUP
maxwords , lastword ) ;
VST648.vsd
$NUMERIC
$NUMERIC ( int-expression ) ;
VST102.vsd
$OCCURS
$OCCURS ( variable )
VST103.vsd
$OFFSET
$OFFSET ( variable )
VST104.vsd
$OPTIONAL
$OPTIONAL
( cond-expression , param )
param-pair
VST213.vsd
param-pair
string : length
VST039.vsd
$OVERFLOW
$OVERFLOW
VST105.vsd
$PARAM
$PARAM ( formal-param )
VST106.vsd
$POINT
$POINT ( fixed-expression )
VST107.vsd
$PROCADDR
$PROCADDR ( identifier )
VST031.vsd
$READBASELIMIT
Note. The EpTAL compiler does not support this procedure.
VST649.vsd
$READCLOCK
$READCLOCK
VST108.vsd
$READSPT
Note. The EpTAL compiler does not support this routine.
VST650.vsd
$READTIME
$READTIME
VST651.vsd
$SCALE
VST110.vsd
$SGBADDR_TO_EXTADDR
$SGBADDR_TO_EXTADDR ( expression )
VST603.vsd
$SGBADDR_TO_SGWADDR
$SGBADDR_TO_SGWADDR ( expression )
VST604.vsd
$SGWADDR_TO_EXTADDR
$SGWADDR_TO_EXTADDR ( expression )
VST605.vsd
$SGWADDR_TO_SGBADDR
$SGWADDR_TO_SGBADDR ( expression )
VST690.vsd
$SPECIAL
$SPECIAL ( int-expression )
VST111.vsd
$STACK_ALLOCATE
Note. The pTAL and EpTAL compilers behave differently.
$STACK_ALLOCATE ( size )
VST032.vsd
$TRIGGER
Note.
$TRIGGER ( op )
VST060.vsd
$TYPE
$TYPE ( variable )
VST112.vsd
$UDBL
$UDBL ( int-expression )
VST113.vsd
$UDIVREM16
quotient , remainder ) ;
VST653.vsd
$UDIVREM32
quotient , remainder ) ;
VST654.vsd
$UNLOCKPAGE
Note. The EpTAL compiler does not support this routine.
VST655.vsd
$WADDR_TO_BADDR
$WADDR_TO_BADDR ( expression )
VST691.vsd
$WADDR_TO_EXTADDR
$WADDR_TO_EXTADDR ( expression )
VST692.vsd
$WRITEPTE
Note. The EpTAL compiler does not support this routine.
abs ) :
VST656.vsd
$XADR
$XADR ( variable )
VST115.vsd
Compiler Directives
• Directive Line on page A-89
• ASSERTION on page A-89
• BEGINCOMPILATION on page A-90
• BLOCKGLOBALS on page A-90
• CALL_SHARED on page A-91
• CHECKSHIFTCOUNT on page A-92
• CODECOV on page A-92
• COLUMNS on page A-93
• DEFEXPAND on page A-94
• DEFINETOG on page A-95
• DO_TNS_SYNTAX on page A-96
• ENDIF on page A-96
• ERRORFILE on page A-96
• ERRORS on page A-97
• EXPORT_GLOBALS on page A-97
• FIELDALIGN on page A-98
• FMAP on page A-98
• GLOBALIZED on page A-99
• GMAP on page A-99
Directive Line
? directive
,
VST120.vsd
ASSERTION
ASSERTION assertion-level ,
=
procedure-name
VST123.vsd
Default: None
Placement: • Anywhere in the source file (not in the compilation command)
• Must be the last directive on the directive line
Scope: Applies until another ASSERTION overrides it
Dependencies: Has no effect without the ASSERT statement
References: ASSERT on page A-40
BEGINCOMPILATION
Note.
• This directive can appear only in the source file, not in the compilation command.
• The EpTAL compiler ignores this directive.
BEGINCOMPILATION
VST991.vsd
Default: None
Placement: • In the source file between the last global data declaration and the
first procedure declaration, including any EXTERNAL and
FORWARD declarations
• Can appear only once in a compilation unit
Scope: Applies to all source code that follows it in 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
• Interacts with SAVEGLOBALS and USEGLOBALS
References: • SAVEGLOBALS on page A-111
• USEGLOBALS on page A-118
BLOCKGLOBALS
BLOCKGLOBALS
VST658.vsd
Default: The compiler allocates data items in the _GLOBAL and $_GLOBAL data
blocks
Placement: Before the first data declaration in a compilation
Scope: Applies to the compilation unit
Dependencies: None
CALL_SHARED
Note.
• This directive is useful only for the pTAL compiler. The EpTAL compiler ignores it (and
issues a warning).
• You cannot link PIC and non-PIC object files into a single object file.
CALL_SHARED
NOCALL_SHARED
VST036.vsd
CHECKSHIFTCOUNT
CHECKSHIFTCOUNT
NOCHECKSHIFTCOUNT
PUSHCHECKSHIFTCOUNT
POPCHECKSHIFTCOUNT
VST659.vsd
Default: NOCHECKSHIFTCOUNT
Placement: Anywhere
Scope: • CHECKSHIFTCOUNT applies to the shift operators that follow it
until it is overridden by NOCHECKSHIFTCOUNT
• NOCHECKSHIFTCOUNT applies to the shift operators that follow it
until it is overridden by CHECKSHIFTCOUNT
Dependencies: None
Caution. If NOCHECKSHIFT is active and a bit-shift operation occurs in which the number of
positions in a bit-shift operation is too large, subsequent program behavior is undefined.
CODECOV
Note. This directive is valid only in the eptal command line.
CODECOV
VST834.vsd
COLUMNS
COLUMNS columns-value
VST127.vsd
DEFEXPAND
DEFEXPAND
NODEFEXPAND
PUSHDEFEXPAND
POPDEFEXPAND
VST023.vsd
Default: NODEFEXPAND
Placement: Anywhere
Scope: • DEFEXPAND applies to subsequent code it until it is overridden by
NODEFEXPAND
• NODEFEXPAND applies to subsequent code until it is overridden by
DEFEXPAND
Dependencies: DEFEXPAND has no effect if NOLIST or SUPPRESS is active
References: • LIST on page A-104
• SUPPRESS on page A-115
DEFINETOG
DEFINETOG toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST212.vsd
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• SETTOG
• RESETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • IF, IFNOT, and ENDIF on page A-100
• RESETTOG on page A-110
• SETTOG on page A-113
DO_TNS_SYNTAX
DO_TNS_SYNTAX
NODO_TNS_SYNTAX
PUSHDO_TNS_SYNTAX
POPDO_TNS_SYNTAX
VST663.vsd
Default: NODO_TNS_SYNTAX
Placement: • Can appear only once in a compilation
• Must precede any TARGET directive and any nondirective lines
Scope: Applies to the compilation unit
Dependencies: None
References: TARGET on page A-117
ENDIF
See IF, IFNOT, and ENDIF on page A-100.
ERRORFILE
ERRORFILE file-name
define-name
assign-name
VST137.vsd
Default: None
Placement: • In the compilation command or in the source code before any
declarations
• Can appear only once in a compilation unit
Scope: Applies to the compilation unit
Dependencies: None
ERRORS
ERRORS num-messages
=
VST138.vsd
EXPORT_GLOBALS
EXPORT_GLOBALS
NOEXPORT_GLOBALS
PUSHEXPORT_GLOBALS
POPEXPORT_GLOBALS
VST662.vsd
Default: EXPORT_GLOBALS
Placement: • Can appear any number of times in a compilation unit
• Must appear before the first procedure is compiled
• Cannot appear within BLOCK declarations
Scope: 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 USEGLOBALS, the compiler exports
the data blocks declared in the USEGLOBALS declarations file only
if EXPORT_GLOBALS is active when the compiler encounters the
BEGINCOMPILATION directive.
References: • BEGINCOMPILATION on page A-90
• SRL on page A-115
• USEGLOBALS on page A-118
FIELDALIGN
FIELDALIGN ( SHARED2 )
SHARED8
PLATFORM
AUTO
NODEFAULT
VST660.vsd
FMAP
FMAP
NOFMAP
VST141.vsd
Default: NOFMAP
Placement: Anywhere, any number of times. The last FMAP or NOFMAP in the
compilation unit determines whether the compiler lists the file map.
Scope: Applies to the compilation unit
Dependencies: FMAP has no effect if either NOLIST or SUPPRESS is active
References: • LIST on page A-104
• SUPPRESS on page A-115
GLOBALIZED
Note. This directive is valid only in the eptal command line.
GLOBALIZED
VST835.vsd
GMAP
GMAP
NOGMAP
VST142.vsd
Default: GMAP
Placement: Anywhere, any number of times. The last GMAP or NOGMAP in the
compilation unit determines whether the compiler lists the global map.
Scope: Applies to the compilation unit
Dependencies: • GMAP has no effect if NOLIST, NOMAP, or SUPPRESS is active
• NOGMAP suppresses the global map even if MAP is active
References: • LIST on page A-104
• MAP on page A-105
• SUPPRESS on page A-115
GP_OK
Note. The EpTAL compiler ignores this directive.
GP_OK
NOGP_OK
PUSHGP_OK
POPGP_OK
VST661.vsd
IF toggle-number
IFNOT toggle-name
target
pTAL
VST694.vsd
ENDIF toggle-name
toggle-number
target
pTAL
VST693.vsd
target
ANY
RISC1
TNS_ARCH
TNSR_ARCH
_TNS_E_TARGET
TARGETSPECIFIED
VST695.vsd
pTAL
Compiler IF pTAL IFNOT pTAL
pTAL or EpTAL True False
TAL False True
Default: None
Placement: • Anywhere in the source file (not in the compilation command)
• IF or IFNOT must be the last directive on its directive line
• ENDIF must be the only directive on its directive line
Scope: Everything between IF or IFNOT and the next ENDIF that specifies the
same toggle, target, or keyword
Dependencies: Interact with:
• DEFINETOG
• SETTOG
• RESETTOG
• TARGET
See Toggles on page 17-5.
References: • DEFINETOG on page A-95
• RESETTOG on page A-110
• SETTOG on page A-113
• TARGET on page A-117
More information:
• IF and IFNOT on page 17-39
• ENDIF on page 17-29
INNERLIST
INNERLIST
NOINNERLIST
PUSHINNERLIST
POPINNERLIST
VST149.vsd
Default: NOINNERLIST
Placement: Anywhere
Scope: • INNERLIST applies to subsequent statements it until it is overridden
by NOINNERLIST
• NOINNERLIST applies to subsequent statements until it is
overridden by INNERLIST
Dependencies: INNERLIST has no effect if NOLIST or SUPPRESS is active
References: • LIST on page A-104
• SUPPRESS on page A-115
INVALID_FOR_PTAL
INVALID_FOR_PTAL
VST701.vsd
Default: None
Placement: After IF or IFNOT and before ENDIF
Scope: Applies to code between itself and ENDIF
Dependencies: None
References: IF, IFNOT, and ENDIF on page A-100
LINES
LINES num-lines
=
VST154.vsd
Default: LINES 60
Placement: Anywhere
Scope: Applies until overridden by another LINES directive
Dependencies: Has no effect if the list file is a terminal
LIST
LIST
NOLIST
PUSHLIST
POPLIST
VST155.vsd
Default: LIST
Placement: Anywhere
Scope: • LIST applies to subsequent code it until it is overridden by NOLIST
• NOLIST applies to subsequent code until it is overridden by LIST
Dependencies: LIST has no effect if SUPPRESS is active
References: SUPPRESS on page A-115
MAP
MAP
NOMAP
PUSHMAP
POPMAP
VST157.vsd
Default: MAP
Placement: Anywhere
Scope: • MAP applies to subsequent code it until it is overridden by NOMAP
• NOMAP applies to subsequent code until it is overridden by MAP
Dependencies: MAP has no effect if NOLIST or SUPPRESS is active
References: • LIST on page A-104
• SUPPRESS on page A-115
OPTIMIZE
OPTIMIZE level
=
VST665.vsd
Default: OPTIMIZE 1
Placement: Outside the boundary of a separately compiled program
Scope: The optimization level active at the beginning of a separately compiled
program determines the level of optimization for that program and any
programs it contains
Dependencies: None
OPTIMIZEFILE
OPTIMIZEFILE filename
VST666.vsd
filename
routine-name optimize-level
# comment
blank line
VST064.vsd
OVERFLOW_TRAPS
OVERFLOW_TRAPS
NOOVERFLOW_TRAPS
PUSHOVERFLOW_TRAPS
POPOVERFLOW_TRAPS
VST697.vsd
PAGE
PAGE
VST160.vsd
PRINTSYM
PRINTSYM
NOPRINTSYM
VST162.vsd
Default: PRINTSYM
Placement: Anywhere
Scope: • PRINTSYM applies to subsequent declarations until overridden by
NOPRINTSYM
• NOPRINTSYM applies to subsequent declarations until overridden
by PRINTSYM
Dependencies: • PRINTSYM has no effect if NOLIST or SUPPRESS is active
• PRINTSYM interacts with SAVEGLOBALS and USEGLOBALS
References: • LIST on page A-104
• SAVEGLOBALS on page A-111
• SUPPRESS on page A-115
• USEGLOBALS on page A-118
REFALIGNED
REFALIGNED ( 2 )
PUSHREFALIGNED
POPREFALIGNED
VST669.vsd
Default: REFALIGNED 8
Placement: Anywhere
Scope: Applies to subsequent pointers to nonstructure data items and
procedure reference parameters until overridden by another REFALIGN
directive
Dependencies: None
RESETTOG
RESETTOG
toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST164.vsd
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• DEFINETOG
• SETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • DEFINETOG on page A-95
• IF, IFNOT, and ENDIF on page A-100
• SETTOG on page A-113
ROUND
ROUND
NOROUND
VST165.vsd
Default: NOROUND
Placement: Anywhere
Scope: • ROUND applies to subsequent code until overridden by NOROUND
• NOROUND applies to subsequent code until overridden by ROUND
Dependencies: None
SAVEGLOBALS
Note. The EpTAL compiler does not accept this directive.
SAVEGLOBALS file-name
define-name
VST670.vsd
Default: None
Placement: Either in the compilation command or in the source code before any
global data declarations
Scope: Applies to the compilation unit
Dependencies: • If SAVEGLOBALS and USEGLOBALS appear in the same
compilation unit, the compiler uses only the one that appears first
• The compilation unit must have exactly one BEGINCOMPILATION
directive
• Interacts with the directives referenced in the next row
References: • BEGINCOMPILATION on page A-90
• PRINTSYM on page A-108
• SYMBOLS on page A-116
• SYNTAX on page A-116
• USEGLOBALS on page A-118
SECTION
SECTION section-name
VST171.vsd
Default: None
Placement: • Only in the source file (not in the compilation command)
• Must be the only directive on the directive line
Scope: Applies to subsequent code until another SECTION directive or the end
of the file, whichever is first
Dependencies: Interacts with SOURCE (see Section Names on page 17-61)
References: SOURCE on page 17-60
SETTOG
SETTOG
toggle-name
toggle-number
,
( toggle-name )
toggle-number
VST172.vsd
Default: None
Placement: • With a parenthesized list, it can appear anywhere
• Without a parenthesized list, it must be the last directive on the
directive line or compilation command line
Scope: Applies to the compilation unit
Dependencies: Interacts with:
• DEFINETOG
• RESETTOG
• IF
• IFNOT
• ENDIF
See Toggles on page 17-5.
References: • DEFINETOG on page A-95
• IF, IFNOT, and ENDIF on page A-100
• RESETTOG on page A-110
SOURCE
SOURCE
file-name
define-name ( section-name )
assign-name ,
VST173.vsd
Default: None
Placement: • Only in the source file (not in the compilation command)
• Must be the last directive on the directive line
Scope: Applies to the source file
Dependencies: • Interacts with COLUMNS
• Interacts with SECTION (see Section Names on page 17-61)
• Interacts with the directives referenced in the next row
References: • BEGINCOMPILATION on page A-90
• COLUMNS on page A-93
• LIST on page A-104
• SECTION on page A-112
• SUPPRESS on page A-115
• USEGLOBALS on page A-118
SRL
Note. The EpTAL compiler ignores this directive.
SRL
VST671.vsd
Default: None
Placement: Anywhere
Scope: Applies to the compilation unit
Dependencies: When declaring a data block that belongs to an SRL, you must specify
NOEXPORT_GLOBALS and NOGP_OK.
References: • EXPORT_GLOBALS on page A-97
• GP_OK on page A-100
SUPPRESS
SUPPRESS
NOSUPPRESS
VST176.vsd
Default: NOSUPPRESS
Placement: Anywhere
Scope: Applies to the compilation unit
Dependencies: Overrides all the listing directives (see the following row)
References: • DEFEXPAND on page A-94
• FMAP on page A-98
• GMAP on page A-99
• INNERLIST on page A-103
• LIST on page A-104
• MAP on page A-105
• PAGE on page A-108
• PRINTSYM on page A-108
SYMBOLS
SYMBOLS
NOSYMBOLS
VST672.vsd
Default: NOSYMBOLS
Placement: Before the first declaration in the compilation
Scope: The last legally placed SYMBOLS or NOSYMBOLS applies to the
compilation unit
Dependencies: Interacts with SAVEGLOBALS and USEGLOBALS
References: • SAVEGLOBALS on page A-111
• USEGLOBALS on page A-118
SYNTAX
SYNTAX
VST178.vsd
TARGET
TARGET T16
LIBERTY
RISC1
ANY
TNS_ARCH
TNS_R_ARCH
_TNS_E_TARGET
VST673.vsd
USEGLOBALS
Note. The EpTAL compiler does not accept this directive.
USEGLOBALS file-name
define-name
VST674.vsd
Default: None
Placement: Either in the compilation command or in the source code before any
global data declarations
Scope: Applies to the compilation unit
Dependencies: • The compilation unit must have exactly one BEGINCOMPILATION
directive.
• The compiler exports the data blocks declared in the USEGLOBALS
declarations file only if EXPORT_GLOBALS is active when the
compiler encounters the BEGINCOMPILATION directive.
• A module that specifies USEGLOBALS can export a global data
block that was declared in the compilation that specified
SAVEGLOBALS only if the SAVEGLOBALS compilation exported
the data block.
Typically, a project that uses SAVEGLOBALS explicitly links globals
into the object file and specifies NOEXPORT_GLOBALS (the
default) for all individual compilations.
• Interacts with the directives referenced in the next row.
References: • BEGINCOMPILATION on page A-90
• EXPORT_GLOBALS on page A-97
• PRINTSYM on page A-108
• SAVEGLOBALS on page A-111
• SYMBOLS on page A-116
• SYNTAX on page A-116
WARN
WARN
NOWARN warning-number
VST675.vsd
Default: WARN
Placement: Anywhere
Scope: • WARN applies to subsequent code until overridden by NOWARN
• NOWARN applies to subsequent code until overridden by WARN;
however: To print selected warnings, you must specify WARN before
any NOWARN directives. If you specify NOWARN first, subsequent
WARN warning-number directives have no effect.
Dependencies: None
Topics:
• Parts of a Disk File Name on page B-2
• Partial File Names on page B-3
• Logical File Names on page B-4
• Internal File Names on page B-4
You can name your own subvolumes and file IDs, but nodes (systems) and volumes
are named by the system manager.
All parts of the file name except the file ID are optional except as noted in the following
discussion. If you omit any part of the file name, the system uses values as described
in Partial File Names on page B-3.
Topics:
• Node or System Name on page B-2
• Volume Name on page B-3
• Subvolume Name on page B-3
• File ID on page B-3
Volume Name
The volume name, such as $MYVOL, is the name of the disk volume where the file
resides. If specified, the volume name must begin with a dollar sign ($), followed by
one to six or one to seven alphanumeric characters as follows. The character following
the dollar sign must be an alphabetic character.
On a D-series system, the volume name can contain one to seven alphanumeric
characters.
On a C-series system, the volume name can contain:
• One to six alphanumeric characters if you include the system name
• One to seven alphanumeric characters if you omit the system name
On a C-series system, if you specify the system name, you must also specify the
volume name. If you omit the system name, specifying the volume name is optional.
Subvolume Name
The subvolume name, such as MYSUBVOL, is the name of the set of files, on the disk
volume, within which the file resides. The subvolume name can contain from one to
eight alphanumeric characters, the first of which must be alphabetic.
On a D-series system, if you specify the volume name, you must also specify the
subvolume name. If you omit the volume name, specifying the subvolume name is
optional.
File ID
The file ID, such as MYFILE, is the identifier of the file in the subvolume. The file ID
can contain from one to eight alphanumeric characters, the first of which must be
alphabetic.
The file ID is required.
Following are all the partial file names you can specify for a disk file named
\BRANCH.$DIV.DEPT.EMP:
D-Series C-Series
Omitted File-Name Parts Partial File Name System System
Node (system) $div.dept.emp Yes Yes
Node (system), volume dept.emp Yes Yes
Node (system), volume, subvolume emp Yes Yes
Volume \branch.dept.emp Yes No
Volume, subvolume \branch.emp Yes No
Subvolume \branch.$div.emp No Yes
Node (system), subvolume $div.emp No Yes
HP TACL Commands
Before starting the compiler, you can send information to it by using the following
HP TACL commands:
• DEFINE on page B-5
• PARAM SWAPVOL on page B-7
• ASSIGN on page B-7
For complete information about these commands, see the following manuals:
• TACL Reference Manual (syntactic information)
• TACL Programmer’s Guide (programmatic information)
• Guardian User’s Guide (interactive information)
• Guardian Programmer’s Guide (programmatic information)
DEFINE
• Substituting File Names for DEFINE Macros on page B-5
• DEFINE Names on page B-5
To create a DEFINE message or set its attributes, you must set a CLASS attribute for
the DEFINE. The CLASS attributes are:
• MAP DEFINE (Guardian Platforms Only) on page B-6
• TAPE DEFINE (D-Series Systems Only) on page B-6
• SPOOL DEFINE on page B-6
• DEFAULTS DEFINE on page B-7
Each attribute has an initial setting based on whether the attribute is required, optional,
or default.
DEFINE Names
HP TACL DEFINE names:
• Are not case-sensitive
• Have 2 to 24 characters
• Begin with an equals sign (=) followed by an alphabetic character
• Continue with any combination of letters, digits, hyphens (-), underscores (_), and
circumflexes (^)
DEFINE names that begin with an equals sign followed by an underscore (=_) are
reserved by HP (for example, =_DEFAULTS).
SPOOL DEFINE
The SPOOL DEFINE lets you specify spooler settings or attributes, such as number of
copies, form name, location, owner, report name, and priority.
DEFAULTS DEFINE
In the DEFAULTS class, a permanently built-in DEFINE named =_DEFAULTS has the
following attributes, which are active regardless of any DEFMODE setting:
Attribute Required Purpose
VOLUME Yes Contains the default node, volume, and subvolume names for
the current process as set by the HP TACL VOLUME,
SYSTEM, and LOGON commands
SWAP No Contains the node and volume name in which the operating
system is to store swap files
CATALOG No Contains a substitute name for a catalog as described in the
SQL/MP Reference Manual and the SQL/MX Reference
Manual.
PARAM SWAPVOL
The PARAM SWAPVOL command lets you specify the volume that the compiler and
SYMSERV use for temporary files. For example:
PARAM SWAPVOL $myvol
The compiler ignores any node specification and allocates temporary files on its own
node. If you omit the volume, the compiler uses the default volume for temporary files;
SYMSERV uses the volume that is to receive the object file.
Use this command when:
• The volumes normally used for temporary files might not have sufficient space.
• The default volume or the volume to receive the object file is on a different node
from the compiler.
ASSIGN
You can issue the HP TACL ASSIGN command before starting the compiler to
substitute actual file names for logical file names used in the source file. The HP TACL
product stores the file-name mapping until the compiler requests it.
ASSIGN commands fall into two categories:
• Ordinary ASSIGN Command on page B-8
• ASSIGN SSV on page B-9
Note. The EpTAL compiler ignores the SAVEGLOBALS and USEGLOBALS directives.
In each ASSIGN command, specify a logical identifier followed by a comma and the file
name or an HP TACL DEFINE name:
ASSIGN dog, \a.$b.c.dog
ASSIGN cat, =mycat
If the file name is incomplete, the HP TACL product completes it from your current
default node, volume, and subvolume. For example, if your current defaults are
\X.$Y.Z, the HP TACL product completes the incomplete file names in ASSIGN
commands as follows:
Incomplete File Names Complete File Names
ASSIGN qq, cat ASSIGN qq, \x.$y.z.cat
ASSIGN ss, b.dog ASSIGN ss, \x.$y.b.dog
ASSIGN tt, $a.b.rat ASSIGN tt, \x.$a.b.rat.
If you use an HP TACL DEFINE name in place of a file name, the HP TACL product
qualifies the file name specified in the ADD DEFINE command when it processes the
ASSIGN command. Even if you specify new node, volume, and subvolume defaults
between the ADD DEFINE command and the ASSIGN command, the ASSIGN
mapping still reflects the ADD DEFINE settings.
If you issue the following commands:
ASSIGN aa, $a.b.cat
ASSIGN bb, $a.b.dog
ASSIGN cc, =my_zebra
ADD DEFINE =my_zebra, CLASS MAP, FILE $a.b.zebra
pTAL /IN mysource, OUT $s/ obj
the compiler equates SOURCE directives in MYSOURCE to files as follows:
?SOURCE aa ! Equivalent to ?SOURCE $a.b.cat
?SOURCE cc ! Equivalent to ?SOURCE $a.b.zebra
?SOURCE bb ! Equivalent to ?SOURCE $a.b.dog
You can name new source files at each compilation without changing the contents of
the source file.
ASSIGN SSV
The ASSIGN SSV (search subvolume) command lets you specify which node, volume,
and subvolume to take files from. The compiler uses ASSIGN SSV information to
resolve partial file names in the SEARCH, SOURCE, and USEGLOBALS directives.
For each ASSIGN SSV command, append to the SSV keyword a value in the range 0
through 49. Values in the range 0 through 9 can appear with or without a leading 0.
For example, if you specify:
ASSIGN SSV1, oldfiles
and the compiler encounters the directive:
?SOURCE myutil
the compiler looks for oldfiles.myutil.
If you then specify:
ASSIGN SSV1, newfiles
and run the compiler again, it looks for newfiles.myutil.
If you omit the node or volume, the HP TACL product uses the current default node or
volume. If you omit the subvolume, the compiler ignores the command. HP TACL
DEFINE names are not allowed.
The ASSIGN SSV command also lets you specify the order in which subvolumes are
searched. You can specify ASSIGN SSV commands in any order. If the same SSV
value appears more than once, the HP TACL product stores only the last command
having that value.
For example, if you issue the following commands, the HP TACL product stores only
two of the messages:
Assign SSV Command Stored
ASSIGN SSV28, $a.b Yes
ASSIGN SSV7, $c.d No
ASSIGN SSV7, $e.f No
ASSIGN SSV07, $g.h Yes
The compiler stores ASSIGN SSV messages in its SSV table in ascending order.
For each file name the compiler processes, the compiler scans the SSVs in ascending
order from SSV0 until it finds a subvolume that holds the file.
For example, if you issue the following ASSIGN commands before running the
compiler:
ASSIGN SSV7, $aa.b3
ASSIGN SSV10, $aa.grplip
ASSIGN SSV8, mylib
ASSIGN SSV20, $cc.divlib
ASSIGN trig, $sp.math.xtrig
and the compiler encounters the following SOURCE directive:
?SOURCE unpack
the compiler first looks for an ASSIGN message having the logical name unpack. If
there is none, the compiler looks for the file in subvolumes in the following order:
$aa.b3.unpack (SSV7)
$default-volume.mylib.unpack (SSV8)
$aa.grplib.unpack (SSV10)
$cc.divlib.unpack (SSV20)
$default-volume.default-subvolume.unpack
The compiler uses the first file it finds. If it finds none named unpack, it issues an error
message.
When the compiler encounters this directive:
?SOURCE trig
it tries only $sp.math.xtrig; if it does not find that exact file, it issues an error
message.
General
Topic pTAL Compiler EpTAL Compiler
RVU D40 and later G06.20 and later
H06.01 and later
Compiler command ptal eptal
Cross compiler* NonStop pTAL NonStop EpTAL
Object code generated • TNS/R object code • TNS/E object code
• Non-PIC (default) or PIC • PIC
• Object files have file code • Object files have file code
700 on Guardian platform 800 on Guardian platform
• Preemptable • Non-preemptable (default)
or preemptable
* For differences between cross compilers, see NonStop pTAL (ETK) on page 18-2
Routines
Routine or Attribute pTAL Compiler EpTAL Compiler
INTERRUPT attribute Not recognized
RETURN statement Issues a warning if a
RETURN statement
includes both a
result-expression
and a cc-expression
(see Appendix D,
RETURN, RETURNSCC,
and C/C++ on TNS/E)
$AXADR routine Not supported except as a
DEFINE name
$EXECUTEIO routine Not supported
$FREEZE routine Not supported except as a
DEFINE name. Use
$TRIGGER instead.
$HALT routine Not supported except as a
DEFINE name. Use
$TRIGGER instead.
$INTERROGATEHIO routine Not supported
$INTERROGATEIO routine Not supported
$LOCATESPTHDR routine Not supported
$LOCKPAGE routine Not supported
$READBASELIMIT routine Not supported
$READSPT routine Not supported
$STACKALLOCATE routine • If size is not an • If size is not an
integral multiple of 8, integral multiple of 16,
$STACK_ALLOCATE $STACK_ALLOCATE
rounds size up to the rounds size up to the
next integral multiple of next integral multiple of
8. 16.
• The returned value is • The returned value is
aligned to an 8-byte aligned to a 16-byte
boundary. boundary.
$UNLOCKPAGE routine Not supported
$TRIGGER routine Not supported
$UNLOCKPAGE routine Not supported
$WRITEPTE routine Not supported
Compiler Directives
Directive pTAL Compiler EpTAL Compiler
BEGINCOMPILATION Ignored
SAVEGLOBALS Not accepted
USEGLOBALS Not accepted
CALL_SHARED Default
NOCALL_SHARED Default Not accepted
GP_OK Not accepted
NOGP_OK Ignored
PUSHGP_OK Ignored
POPGP_OK Ignored
OPTIMIZEFILE Does not issue warnings Issues a warning when filename
for errors in filename meets one of the Conditions: on
page C-3
OVERFLOW_TRAPS Default
NOOVERFLOW_TRAPS Default
SRL Not accepted
TARGET Default and only Default and only accepted option
accepted option is is _TNS_E_TARGET
TNS_R_ARCH
Conditions:
The EpTAL compiler issues a warning when the filename in OPTIMIZEFILE:
• 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:
° Has a routine-name that does not match any routine declaration in the
source file
° Before routine-name
° After optimize-level
° Between routine-name and optimize-level
Caution. C/C++ prototypes such as these are not guaranteed to work on the TNS/R
architecture, and extracting only the traditional function value (as in Example D-2 on page D-3)
does not work on the TNS/E architecture.
The EpTAL compiler issues a warning whenever a pTAL procedure returns both a
traditional function value and a condition code value. To migrate such a procedure to
TNS/E, HP recommends that you:
1. Write a pTAL shell procedure that returns the two values in the way that C/C++
returns them (in Example D-3 on page D-3, this procedure is P_SHELL).
2. Change the alias of the C/C++ prototype to the name of the pTAL shell procedure
in Step 1. (This change eliminates the need to change the calls to this prototype.)
3. Retire the original pTAL procedure linkage name. This allows the eld utility to
identify any uses of unchanged C/C++ prototypes, instead of producing an
executable program that uses the old prototypes (because the eld utility does not
produce an executable program if there are unresolved procedure references).
Example D-1. C Procedure Extracting Two pTAL Return Values from a 64-Bit
Value (Works Only on TNS/R Systems—Not Recommended)
pTAL procedure with two return values:
int proc p (i, j, k) returnscc;
int(16) i;
int(32) .ext j;
int(64) k;
begin
...
return i, j < k; ! Traditional function value is the value of i.
! Expression j < k sets condition code.
end;
C/C++ prototype for accessing pTAL procedure:
_tal _alias ("P") long long some_name (short i, int* j, long long k);
C/C++ code that captures the 64-bit value:
typedef union val_cc_combo
{
long long combo;
struct
{
long value;
long condition_code;
} parts
} val_cc_combo
...
val_cc_combo.combo = some_name ();
C/C++ code that extracts the condition code from the 64-bit value:
(short)val_cc_combo.parts.value /* For 16-bit return value */
val_cc_combo.parts.value /* For 32-bit return value */
C/C++ code that extracts the two return values from the 64-bit value:
(short)val_cc_combo.parts.condition_code /* Always 16-bits */
Example D-2. C Procedure Extracting Only the Traditional Function Value from a
64-Bit Value (Works Only on TNS/R Systems)
pTAL procedure with two return values:
int proc p (i, j, k) returnscc;
int(16) i;
int(32) .ext j;
int(64) k;
begin
...
return i, j < k; ! Traditional function value is the value of i.
! Expression j < k sets condition code.
end;
C/C++ prototype for accessing pTAL procedure:
_tal _alias ("P") long some_name1 (short i, int* j, long long k);
Example D-3. Migrating a pTAL Procedure With Two Return Values to TNS/E
(Works on TNS/R and TNS/E Systems)
pTAL shell procedure that returns values in the way that C/C++ does:
int proc p_shell (result, i, j, k);
int(32) . result;
int(16) i;
int(32) .ext j;
int(64) k;
begin
int cc;
result := p (i, j, k);
if < then
cc := -1D
else
if > then
cc := 1D
else
cc := 0D;
return cc;
end;
Declaration of pTAL procedure P in Example D-1 on page D-2 :
int proc p (i, j, k) returnscc;
int(16) i;
int(32) .ext j;
int(64) k;
begin
...
return i, j < k; ! Traditional function value is the value of i.
! Expression j < k sets condition code.
end;
C/C++ prototype for accessing pTAL shell procedure:
_tal _alias ("P_SHELL") short xyz
(int* result, short i, int* j, long long k);
accelerated object code. The MIPS RISC instructions (in the MIPS region) that result from
processing a TNS object file with the Accelerator or the Intel® Itanium® instructions (in
the Itanium instruction region) that result from processing a TNS object file with the
Object Code Accelerator (OCA).
accelerated object file. A TNS object file that, in addition to its TNS instructions (in the
TNS region) and symbol information (in the symbol region), has been augmented by
the Accelerator with equivalent but faster MIPS RISC instructions (in the MIPS region),
the Object Code Accelerator (OCA) with equivalent but faster Intel® Itanium®
instructions (in the Itanium instruction region), or both.
Accelerator. A program optimization tool that processes a TNS object file and produces an
accelerated object file that also contains equivalent MIPS RISC instructions (called the
MIPS region). TNS object code that is accelerated runs faster on TNS/R processors
than TNS object code that is not accelerated. See also TNS Object Code Accelerator
(OCA).
aligned. In native mode, a data item is aligned if its address is a multiple of its size; for
example, a 4-byte data item is aligned if its byte address is a multiple of four.
array. A variable that represents a collectively stored set of elements of the same data type
that are uniquely identified by a monotonically increasing integer with a user-specified
base integer.
ASSIGN command. An HP TACL command (available only on Guardian platforms) that lets
you associate a logical file name with an HP file name.
Binder. A programming utility that combines one or more compilation units’ TNS object
code files to create an executable TNS object code file for a TNS program or library.
Used only with TNS object files.
bit deposit. The assignment of a value to a bit field in a previously allocated STRING, INT,
INT(32), or UNSIGNED(1-31) variable, but not in an UNSIGNED(1-16) variable. A bit-
deposit field has the form <n > or <n :n >. Deposits of 16 or fewer bits require an INT
value to be deposited. Deposits of more than 16 bits require an INT(32) value.
bit extraction. The access of a bit field in an INT expression [which can include STRING,
INT, INT(32), UNSIGNED(1-16), or UNSIGNED(1-31) variables]. A bit-extraction field
has the form <n > or <n :n >. Extractions of 16 or fewer bits yield an INT-typed value.
Extractions of 17 or more bits yield an INT(32)-typed value.
bit shift. The shifting of bits within an INT or INT(32) expression a specified number of
positions to the left or right. An INT expression can consist of STRING, INT, or
UNSIGNED(1-16) values. An INT(32) expression can consist of INT(32) or
UNSIGNED(17-31) values.
bit-shift operators. Unsigned ('<<', '>>') or signed (<<, >>) operators that left shift or right
shift a bit field within an INT or INT(32) expression.
pTAL and epTAL implement arithmetic left shift (<<) as logical left shift ('<<'). The
arithmetic left shift operator (<<) causes a warning.
bitwise logical operator. The LOR, LAND, or XOR operator, which performs a bit-by-bit
operation on INT expressions.
blocked global data. Data you declare within BLOCK declarations. See BLOCK
declaration.
BLOCK declaration. A means by which you can group global data declarations into a
relocatable data block that is either shareable with all compilation units in a program or
private to the current compilation unit.
central processing unit (CPU). Historically, the main data processing unit of a computer.
HP NonStop™ servers have multiple cooperating processors rather than a single CPU.
See also processor.
character string constant. A string of one or more ASCII characters that you enclose
within quotation mark delimiters. Also referred to as a character string.
code segment. A segment that contains program instructions to be executed, plus related
information. Applications can read code segments but cannot write to them.
code space. A part of virtual memory that is reserved for user code, user library code,
system code, and system library code. The current code space of your process
consists of an optional library code space and a user code space.
compilation unit. A source file plus source code that is read in from other source files by
SOURCE directives, which together compose a single input to the compiler.
condition code. A status returned by expressions and by some file system procedure calls
as follows:
Condition
Code Meaning Expression Status
CCG Condition-code-greater-than Positive
CCL Condition-code-less-than 0
CCE Condition-code-equal-to Negative
data segment. A virtual memory segment holding data. Every process begins with its own
data segments for program global variables and runtime stacks (and for some libraries,
instance data). Additional data segments can be dynamically created.
DEFINE. An HP Tandem Advanced Command Language (TACL) command you can use to
specify a named set of attributes and values to pass to a process.
definition structure. A declaration that describes a structure layout and allocates storage
for the structure layout. Compare to referral structure and template structure.
direct addressing. Data access that requires only one memory reference and that is
relative to the base of the global, local, or sublocal area of the data space. Compare to
extended addressing.
doubleword. A 32-bit storage unit for the INT(32) or REAL data type.
dynamic-link library (DLL). A collection of procedures whose code and data can be loaded
and executed at any virtual memory address, with run-time resolution of links to and
from the main program and other independent libraries. The same DLL can be used by
more than one process. Each process gets its own copy of DLL static data.
entry point. An identifier by which a procedure can be called. The primary entry point is the
procedure identifier specified in the procedure declaration. Secondary entry points are
identifiers specified in entry-point declarations.
EpTAL compiler. The compiler that takes pTAL source code as input and generates either
TNS/R native object code or TNS/E native object code. Compare to pTAL compiler and
TAL compiler.
EXTDECS. A file, provided by the operating system, that contains external declarations for
system procedures. System procedures, for example, manage files, activate and
terminate programs, and monitor the operations of processes.
extended addressing. Data access through an extended (32-bit) pointer. Compare to direct
addressing.
extended pointer. A 32-bit simple pointer or structure pointer. An extended pointer can
contain a 32-bit byte address of any location in virtual memory.
EXTENSIBLE procedure. A procedure that you declare using the EXTENSIBLE keyword; a
procedure to which you can add formal parameters without recompiling its callers; a
procedure for which the compiler considers all parameters to be optional, even if some
are required by your program. Compare to VARIABLE procedure.
file identifier. In the Guardian environment, the portion of a filename following the
subvolume name. In the Open System Services (OSS) environment, a file identifier is a
portion of the internal information used to identify a file in the OSS file system (an node
number). The two identifiers are not comparable.
fileset. In the Open System Services (OSS) environment, a set of files with a common
mount point within the file hierarchy. A fileset can be part or all of a single virtual file
system.
On an HP NonStop™ system, the Guardian file system for an Expand node has a
mount point and is a subset of the OSS virtual file system. The entire Guardian file
system therefore could be viewed as a single fileset. However, each volume and each
process of subtype 30 within the Guardian file system is actually a separate fileset.
The term file system is often used interchangeably with fileset in UNIX publications.
file system. In the Open System Services (OSS) environment, a collection of files and file
attributes. A file system provides the namespace for the file serial numbers that
uniquely identify its files. Open System Services provides a file system (see also
ISO/IEC IS 9945-1:1990 [ANSI/IEEE Std. 1003.1-1990], Clause 2.2.2.38); the
Guardian application program interface (API) provides a file system; and OSS Network
File System (NFS) provides a file system. (OSS NFS filenames and pathnames are
governed by slightly different rules than OSS filenames and pathnames.) Within the
OSS and OSS NFS file systems, filesets exist as manageable objects.
On an HP NonStop™ system, the Guardian file system for an Expand node is a subset
of the OSS virtual file system. Traditionally, the API for file access in the Guardian
environment is referred to as the Guardian file system.
In some UNIX and NFS implementations, the term file system means the same thing
as fileset. That is, a file system is a logical grouping of files that, except for the root of
the file system, can be contained only by directories within the file system. See also
fileset.
filler bit. A declaration that allocates a bit place holder for data or unused space in a
structure.
filler byte. A declaration that allocates a byte place holder for data or unused space in a
structure.
flat segment. A type of logical segment. Each flat segment has its own distinct address
range within the process address space that never overlaps the range of any other
allocated segments. Thus all allocated flat segments for a process are always available
for use concurrently. Compare to selectable segment.
global variable. A variable that has global scope; that is, a variable that is declared at the
program level (not in a procedure or subprocedure). A global variable is visible
everywhere in the program after the point where it is declared. Compare to local
variable and sublocal variable.
high PIN. A process identification number (PIN) that is greater than 255. Compare to low
PIN.
home terminal. Usually the terminal from which a process was started.
identifier. A name you declare for an object such as a variable, LITERAL, or procedure.
IF expression. An expression that selects the THEN expression for a true state or the
ELSE expression for a false state.
keyword. A term that has a predefined meaning to the compiler. A program cannot use a
keyword as an identifier.
label. An identifier you place before a statement for access by other statements within the
encompassing procedure, usually a GOTO statement.
LAND. A bitwise logical operator that performs a bitwise logical AND operation.
linkfile. An object file that requires linking with other object files before execution (also
called a nonexecutable object file). Compare to loadfile.
loadfile. An object file that is ready for immediate execution. Compare to linkfile.
local variable. A variable that has local scope; that is, a variable that is declared in a
procedure (including its formal parameters). A local variable is visible everywhere in
the procedure that declares it (including within subprocedures of that procedure) after
the point where it is declared. Compare to global variable and sublocal variable.
logical segment. A single data area consisting of one or more consecutive 128-kilobyte
unitary segments that is dynamically allocated by a process. The two types of logical
segments are selectable segments and flat segments. See also selectable segment
and flat segment.
low PIN. A process identification number (PIN) in the range 0 through 254. Compare to high
PIN.
misaligned. In TNS mode and TNS accelerated mode, an erroneous address that is odd-
byte aligned. In native mode, an inefficient address that is not aligned.
move statement. A statement that copies a group of elements from one location to another.
NAME declaration. A declaration that associates an identifier with a compilation unit (and
with its private global data block if any).
named data block. A BLOCK declaration that specifies a data-block identifier. The global
data declared within the BLOCK declaration is accessible to all compilation units in the
program. Compare to private data block.
Native Inspect. The HP interactive symbolic debugging tool for TNS/E programs. Compare
to Visual Inspect.
native mode. The operational environment in which Itanium and native-compiled RISC
instructions execute. Compare to TNS accelerated mode and TNS mode.
object file. A file, generated by a compiler or binder, that contains machine instructions and
other information needed to construct the executable code spaces and initial data for a
process. The file can be a complete program ready for execution, or it can be
incomplete and require binding with other object files before execution. Compare to
source file.
offset. Represents, when used in place of an index, the distance in bytes of an item from
either the location of a direct variable or the location of the pointer of an indirect
variable, not from the location of the data to which the pointer points.
parameter mask. A means by which the compiler keeps track of which actual parameters
are passed by a procedure to an EXTENSIBLE procedure or VARIABLE procedure.
parameter pair. Two parameters connected by a colon that together describe a single data
type to some languages.
pathname. In the Open System Services (OSS) file system and Network File System
(NFS), the string of characters that uniquely identifies a file within its file system. A
pathname can be either relative or absolute. See also ISO/IEC IS 9945-1:1990
(ANSI/IEEE Std. 1003.1-1990 or POSIX.1), Clause 2.2.2.57.
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.
pointer. A variable that contains the address of another variable. Pointers include simple
pointer and structure pointers that you declare and manage. See also extended pointer
and standard pointer.
private data block. A BLOCK declaration that specifies the PRIVATE keyword. Global data
declared within such a BLOCK declaration is accessible only to procedures within the
current compilation unit. Compare to named data block.
procedure. A program unit that can contain the executable parts of a program and that is
callable from anywhere in a program; a named sequence of machine instructions.
procedure declaration. Declaration of a program unit that can contain the executable parts
of a program and that is callable from anywhere in a program. Consists of a procedure
heading and either a procedure body or the keyword FORWARD or EXTERNAL.
process.
1. A program that has been submitted to the operating system for execution, or a
program that is currently running in the computer.
2. An address space, a single thread of control that executes within that address
space, and the system resources required by that thread of control.
process environment. The software environment that exists when the processor module is
executing instructions that are part of a user process or a system process.
process identification number (PIN). A number that uniquely identifies a process running
in a processor. The same number can exist in other processors in the same system.
processor.
1. A functional unit of a computer that reads program instructions, moves data
between processor memory and the input/output controllers, and performs
arithmetic operations. Because a processor is composed of several hardware
components that reside in different enclosures, it is sometimes called a logical
processor. A processor is sometimes called a central processing unit (CPU), but
HP NonStop™ servers have multiple cooperating processors rather than a single
CPU.
2. One or more computer chips, typically mounted on a logic board, that are designed
to perform data processing or to manage a particular aspect of computer
operations.
program file. An executable object code file containing a program’s main routine plus
related routines statically linked together and combined into the same object file. Other
routines shared with other programs might be located in separately loaded libraries. A
program file can be named on a RUN command; other code files cannot.
pTAL compiler. The compiler that takes pTAL source code as input and generates TNS/R
native object code. Compare to EpTAL compiler and TAL compiler.
quadrupleword. A 64-bit storage unit for the REAL(64) or FIXED data type.
read-only array. An array that you can read but cannot modify.
referral structure. A declaration that allocates storage for a structure whose layout is the
same as the layout of a specified structure or structure pointer. Compare to definition
structure and template structure.
HP pTAL Reference Manual—523746-006
Glossary -10
Glossary register
register. A facility that stores information about a running process. Registers include the
program register, the instruction register, the local register, the stack register, the
register stack, and the environment register.
relational operator. A signed (<, =, >, <=, >= <>) or unsigned ('<', '=', '>', '<=', '>=', '<>')
operator that performs signed or unsigned comparison, respectively, of two operands
and then returns a true or false state.
root operator. The last operator executed on the right side of an assignment statement.
scope. The set of levels—global, local, or sublocal—at which you can access each
identifier.
signal. The method by which an environment notifies a process of an event. Signals are
used to notify a process when an error that is not related to input or output has
occurred. A signal is often an indication of a run-time event that requires immediate
attention. Many such events preclude continuing the interrupted instruction stream.
Signals are generated for TNS/R native Guardian processes. (TNS Guardian
processes receive traps instead.) A SIGILL signal indicates that an instruction cannot
be executed because the instruction or its data are invalid. Compare to trap.
simple pointer. A variable that contains the address of a memory location, usually of a
simple variable or an array element, that you can access with this simple pointer.
simple variable. A variable that contains one item of a specified data type.
source file. A file that contains source text such as data declarations, statements, compiler
directives, and comments. The source file, together with any source code read in from
other source files by SOURCE directives, compose a compilation unit that you can
compile into an object file.
standard pointer. A 16-bit simple pointer or structure pointer. A standard pointer can
contain a 16-bit address.
structure. A variable that can contain different kinds of variables of different data types. A
definition structure, a template structure, or a referral structure.
structure data item. An accessible structure field declared within a structure, including a
simple variable, array, substructure, simple pointer, structure pointer, or redefinition.
Compare to structure item.
structure item. Any structure field, including a structure data item, a bit filler, or a byte filler.
structure pointer. A variable that contains the address of a structure that you can access
with this structure pointer.
sublocal variable. A variable that has sublocal scope; that is, a variable that is declared in
a subprocedure (including its formal parameters). A sublocal variable is visible only in
the subprocedure that declares it, after the point where it is declared. Compare to local
variable and global variable.
system. All the processors, controllers, firmware, peripheral devices, software, and related
components that are directly connected together to form an entity that is managed by
one HP NonStop™ operating system image and operated as one computer.
system procedure. A procedure provided by the operating system for your use. System
procedures, for example, manage files, activate and terminate programs, and monitor
the operations of processes.
TAL compiler. The compiler that takes TAL or pTAL source code as input and generates
TNS object code. Compare to pTAL compiler and EpTAL compiler.
template structure. A declaration that describes a structure layout but allocates no storage
for the structure. Compare to definition structure and referral structure.
TNS architecture. NonStop Series architecture. HP computers that are based on CISC
technology. TNS architecture implements the TNS instruction set.
TNS mode. The operational environment in which unaccelerated TNS instructions execute.
Compare to TNS accelerated mode and native mode.
TNS object code. The TNS instructions that result from processing program source code
with a TNS compiler. TNS object code executes on TNS, TNS/R, and TNS/E systems.
TNS Object Code Accelerator (OCA). A program optimization tool that processes a TNS
object file and produces an accelerated file for the TNS/E architecture. OCA augments
a TNS object file with equivalent Intel® Itanium® instructions. TNS object code that is
accelerated runs faster on TNS/E systems than TNS object code that is not
accelerated.
TNS/E native object code. The Intel®® Itanium® instructions that result from processing
program source code with a TNS/E native compiler. TNS/E native object code
executes only on TNS/E systems, not on TNS systems or TNS/R systems.
TNS/R native object code. The MIPS RISC instructions that result from processing
program source code with a TNS/R native compiler. TNS/R native object code
executes only on TNS/R systems, not on TNS systems or TNS/E systems.
trap. A software interrupt that provides a way of handling certain events, such as detection
of a hardware (or software) fault, a timer expiration, or a lack of system resources. A
trap is often an indication of a run-time event that requires immediate attention. Most
such events preclude continuing the interrupted instruction stream. Traps are
generated for TNS Guardian processes. (TNS/R native Guardian processes receive
signals instead.) An Instruction Failure trap indicates that an instruction cannot execute
because the instruction or its data are invalid. Compare to signal.
VARIABLE procedure. A procedure that you declare using the VARIABLE keyword; a
procedure to which you can add formal parameters but then you must recompile all its
callers; a procedure for which the compiler considers all parameters to be optional,
even if some are required by your code. Compare to EXTENSIBLE procedure.
virtual memory. A range of addresses that processes use to reference physical memory
and disk storage.
Visual Inspect. The HP interactive symbolic debugging tool for TNS/R programs. Compare
to Native Inspect.
FOR statement
description of 12-20/12-21
G
Global data
nested 12-21
See also System global data
optimized 12-22
blocked
standard 12-21
allocating 16-15
Formal parameters
declaring 16-12/16-15
indirection symbols and 2-7
SECTION directive and 16-16
of DEFINEs 6-3
sharing 16-16
of procedures 14-3, 14-10
SOURCE directive and 16-16
of subprocedures 14-10, 14-19
map of 17-37
passing by reference 2-7
saving and using 17-8/17-13
procedure pointers as 14-26, 14-32
unblocked 16-14
specifying 14-10/14-15
Global scope 2-10
FORTRAN procedure attribute 14-5
GLOBALIZED directive 17-36
FORWARD keyword
GMAP directive 17-37
in procedure declaration 14-2, 14-4
GOTO statement 12-23/12-25
in procedure entry-point
declaration 14-23 GP_OK directive 17-38/17-39
Greater than operator
in subprocedure declaration 14-19,
14-21 signed (>)
in subprocedure entry-point in conditional expression 5-18
declaration 14-24 operand types for 5-18
fpoint precedence of 5-4
changing 15-82 without operands 5-19
obtaining 15-78 unsigned (’>’)
rounding 17-55 in conditional expression 5-18
scaling 12-7 operand types for 5-19
specifying 15-60 precedence of 5-4
FREEZE routine 15-51 with INT(32) operands 5-10
Functions without operands 5-19
See also Procedures Greater than or equal operator
See also Routines signed (>=)
atomic in conditional expression 5-18
See Atomic operations operand types for 5-18
definition of 14-1 precedence of 5-4
RETURN statement and 12-34 without operands 5-19
with two return values D-1/D-3 unsigned (’>=’)
in conditional expression 5-18
operand types for 5-19
precedence of 5-4
O Operators (continued)
logical
OBJECT file 16-6 description of 5-10
Object files
in arithmetic expressions 5-5
content directives for 17-16
NOT
creating 16-7/16-11
description of 5-17
generating 16-4
condition codes and 5-18
hybrid 16-11
OR
linking 16-7/16-11
description of 5-17
OCCURS routine 15-69/15-71
condition codes and 5-18
Odd-byte references 10-14, 10-17
precedence of 5-3/5-4
OF keyword
relational
in labeled CASE statement 12-13
See Relational operators
in unlabeled CASE statement 12-15
signed
OFFSET routine
description of 15-71/15-73 See Signed operators
structure pointers and 10-18 unsigned
Online help for cross compilers 18-8 See Unsigned operators
Operands OPTIMIZE directive 17-47
in arithmetic expressions 5-5 OPTIMIZEFILE directive 17-47/17-49
scaling FIXED 5-7 Optional parameters 15-73/15-76
OPTIONAL routine 15-73/15-76
Operating systems 1-2
OR operator
Operations
description of 5-17
See also Operators
atomic condition codes and 5-18
in conditional expression 5-15
See Atomic operations
operand types for 5-17
bit
precedence of 5-4
See Bit operations
truth table for 5-15
data 1-6
OTHERWISE keyword
listed by data type 3-4
in labeled CASE statement 12-13
nonatomic
in unlabeled CASE statement 12-15
See Nonatomic operations
OUT file option 16-4
Operators
Output files 16-3
description of 2-5/2-6
Overflow
AND
managing
description of 5-17
generally 13-1/13-3
condition codes and 5-18
GOTO statement and 12-24/12-25
arithmetic
testing 15-76
See Arithmetic operators
concatenation (&) 12-30
Substructures (continued)
redefining
T
TACL commands
definition 9-56/9-59
See HP TACL commands
referral 9-59/9-60
TACL DEFINE tool 18-7
Subsystem Control Facility
TAL
See SCF user interface
compatibility with pTAL 1-1
Subtraction operator
procedures that return two values D-1
signed (-)
TARGET directive 17-68/17-69
in arithmetic expression 5-5
Target file option 16-6
operand types for 5-6
Template structures, declaring 9-35/9-38
precedence of 5-3
Temporary files B-7
unsigned (’-’) Temporary variables
in arithmetic expression 5-5 creating 12-45
operand types for 5-8 dropping 12-20
precedence of 5-3 THEN keyword 12-26
result types for 5-9 TNS architecture RVUs 1-2
with INT(32) operands 5-11 TNSMISALIGN attribute (SCF) 4-3
Subvolume names B-3 TNS/E architecture RVUs 1-2
SUPPRESS directive 17-65/17-66 TNS/R architecture RVUs 1-2
Swap volume B-7 TNS/R native mode 4-3
SWAPVOL command B-7 TO keyword 12-20
SYMBOLS directive 17-66/17-67 Toggles
Symbols, base address 2-7 description of 17-5
Syntax turning off 17-54
checking 17-67/17-68 turning on 17-58
conventions for -xxxvii/-xl Tracing facility 4-1/4-2
summary of A-1/A-119 Transfer Tool 18-7
SYNTAX directive 17-67/17-68 Traps, managing
System clock setting 15-80 generally 13-1/13-3
System global data GOTO statement and 12-24/12-25
See also Global data TRIGGER routine 15-88
declaring TYPE routine 15-88/15-89
equivalenced 11-22/11-29 Typed procedures
pointers 10-20 See Functions
pointers to 10-9 Type-conversion routines 15-12/15-13
System names B-2
System procedures U
description of 1-7
UDBL routine 15-89/15-90
SOURCE directive and 17-63
UDIVREM16 routine 15-90/15-91
System services 1-6 UDIVREM32 routine 15-91/15-92
HP pTAL Reference Manual—523746-006
Index -23
Index V
< ’-’
See Less than operator, signed (<) See Subtraction operator, unsigned (’-’)
< > (angle brackets) 2-4 ’<<’ (unsigned left bit shift) 5-3
<...> (bit extraction) 5-3 ’<=’
<...> := (bit deposit operator) 5-4 See Less than or equal operator,
<< (signed left bit shift) 5-3 unsigned (’<=’)
<= ’<>’
See Less than or equal operator, signed See Not equal operator, unsigned (’<>’)
(<=) ’<’
<> See Less than operator, unsigned (’<’)
See Not equal operator, signed (<>) ’=’
= See Equal sign, as equal operator,
See Equal sign unsigned
=: (right-to-left move) 12-28 ’>=’
> See Greater than or equal operator,
See Greater than operator, signed (>) unsigned (’>=’)
>= ’>>’ (unsigned right bit shift) 5-3
See Greater than or equal operator, ’>’
signed (>=) See Greater than operator, unsigned
>> (signed right bit shift) 5-3 (’>’)
? (question mark) 2-5 ’\’
@ operator See Remainder operator (’\’)
in entry-point identifiers ’⁄ ’
for procedures 14-23 See Division operator, unsigned (’⁄ ’)
for subprocedures 14-24 ⁄
in pointers 10-14 See Division operator, signed (⁄ )
in PROC parameters 14-16
in reference parameters 14-14
precedence of 5-3
[ ] (square brackets) 2-4
’ (single quotation mark) 2-5
’P’ (read-only array symbol)
See Read-only arrays
’SG’-equivalenced variables
See Equivalenced variables
’*’
See Multiplication operator, unsigned
(’*’)
’+’
See Addition operator, unsigned (’+’)