HP pTAL Reference Manual HP Part Number: 523746-009 Published: Feb 2012 Edition: D44.
© Copyright 2012 Hewlett-Packard Development Company, L.P. Legal Notice Confidential computer software. Valid license from HP required for possession, use or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor’s standard commercial license. The information contained herein is subject to change without notice.
Contents About This Document...................................................................................16 Supported Release Version Updates (RVUs)................................................................................16 Intended Audience..................................................................................................................16 New and Changed Information................................................................................................
3 Data Representation..................................................................................46 Data Types............................................................................................................................46 Specifying Data Types........................................................................................................47 Data Type Aliases..............................................................................................................
Passing Actual Parameters to DEFINEs.....................................................................................100 7 Simple Variables....................................................................................103 Declaring Simple Variables....................................................................................................103 Specifying Simple Variable Address Types...............................................................................
Declaring Simple Pointers in Structures.....................................................................................148 Using Simple Pointers.......................................................................................................149 Assigning Addresses to Pointers in Structures........................................................................150 Declaring Structure Pointers in Structures..................................................................................
ASSERT...............................................................................................................................200 Assignment..........................................................................................................................201 Pointer Assignment...........................................................................................................203 Assigning Numbers to FIXED Variables..........................................................................
Returning the Value of $OVERFLOW or $CARRY to the Calling Procedure...............................245 14 Procedures, Subprocedures, and Procedure Pointers..................................246 Procedure Declarations..........................................................................................................246 Procedure Attributes..............................................................................................................248 Parameters and VARIABLE and EXTENSIBLE Procedures....
$BADDR_TO_WADDR......................................................................................................294 $BITLENGTH...................................................................................................................295 $BITOFFSET....................................................................................................................296 $CARRY.........................................................................................................................
$OPTIONAL...................................................................................................................333 $OVERFLOW..................................................................................................................335 $PARAM........................................................................................................................336 $POINT.........................................................................................................................
Example.........................................................................................................................369 Toggles...............................................................................................................................370 Named Toggles...............................................................................................................370 Numeric Toggles...................................................................................................
Effect of Other Directives...................................................................................................418 Including System Procedure Declarations.............................................................................419 Examples........................................................................................................................419 SRL................................................................................................................................
Bit Deposit Assignment.....................................................................................................456 CALL..............................................................................................................................457 Labeled CASE.................................................................................................................457 Unlabeled CASE............................................................................................................
PROFGEN......................................................................................................................509 PROFUSE........................................................................................................................510 REFALIGNED...................................................................................................................510 RESETTOG...................................................................................................................
$PROC32ADDR..............................................................................................................533 $PROC64ADDR..............................................................................................................533 $UFIX.............................................................................................................................533 $XADR...........................................................................................................................
About This Document The Portable Transaction Application Language for HP NonStop systems (pTAL) is a high-level, block-structured language used to write systems software and transaction-oriented applications.
• • • ◦ $EXTADDR_TO_EXT64ADDR (page 308) ◦ $FIXED0_TO_EXT64ADDR (page 310) ◦ $IS_32BIT_ADDR (page 321) ◦ $PROC32ADDR (page 337) ◦ $PROC64ADDR (page 338) ◦ $UFIX (page 349) ◦ $XADR32 (page 352) ◦ $XADR64 (page 353) Updated the following directives: ◦ DEFINETOG (page 388) ◦ ENDIF (page 390) ◦ IF and IFNOT (page 398) ◦ RESETTOG (page 411) ◦ SETTOG (page 415) Updated the following built-in routines: ◦ $INT (page 317) ◦ $PROCADDR (page 337) ◦ $XADR (page 352) Updated the follow
• ◦ Declaring Procedure Pointers in Structures (page 267) ◦ Assignments to Procedure Pointers (page 269) ◦ Syntax Summary (page 432) ◦ Differences Between the pTAL and EpTAL Compilers (page 525) Updated the following tables with 64-bit addressing functionality: ◦ Data Types (page 33) ◦ Reserved Keywords (page 37) ◦ Base Address Symbols (page 40) ◦ Indirection Symbols (page 41) ◦ Data Types and Their Address Types (page 49) ◦ Valid Address Conversions (page 53) ◦ Expressions (page 69)
New and Changed Information for 523746–007 • In Chapter 16: Compiling and Linking pTAL Programs (page 355), updated the overview of the Code Profiling Utilities to include the profile-guided optimization capability.
Table 1 Summary of Contents (continued) Chapter This chapter . . . Chapter 11: Equivalenced Variables Describes equivalenced variables. Equivalencing lets you declare more than one identifier and description for a location in a storage area. Chapter 12: Statements Describes statements. Statements — also known as executable statements — perform operations in a program. They can modify the program’s data or control the program’s flow. Chapter 13: Hardware Indicators Describes hardware indicators.
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 lowercase. Replace item with a value that fits its description, which follows the syntax diagram. Type content (punctuation mark, symbol, or letter) as shown. You can type a letter in uppercase or lowercase.
means that you type: $NEWVOL not $ NEWVOL • An “ns” on the top line of a choice structure applies to the lower lines in the choice structure as well. For example: means that you type one of the following: "^RETURN^SORT^ERRORS" "RETURN_SORT_ERRORS_" • If two diagram pieces are not separated by a separator character (such as a comma, semicolon, or parenthesis), separate the syntactic items that they represent by at least one space or a new line.
• Diagram elements need not be on the same line. For example: BLOCK DATA BEGIN is equivalent to: BLOCK DATA BEGIN • Explicit spacing rules given for individual railroad diagrams override the aforementioned rules. General Syntax Notation This list summarizes the notation conventions for syntax presentation in this manual. UPPERCASE LETTERS Uppercase letters indicate keywords and reserved words. Type these items exactly as shown. Items not enclosed in brackets are required.
A group of items enclosed in brackets is a list from which you can choose one item or none. The items in the list can 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: FC [ num ] [ -num ] [ text ] K [ X | D ] address { } Braces A group of items enclosed in braces is a list from which you are required to choose one item.
ALTER [ / OUT file-spec / ] LINE [ , attribute-spec ]… !i and !o In procedure calls, the !i notation follows an input parameter (one that passes data to the called procedure); the !o notation follows an output parameter (one that returns data to the calling program). For example: CALL CHECKRESIZESEGMENT ( segment-id , error ) ; !i !o !i,o In procedure calls, the !i,o notation follows an input/output parameter (one that both passes data to the called procedure and returns data to the calling program).
proc-name trapped [ in SQL | in SQL file system ] { } 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 can 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.
• Table 4 (page 27) • Table 5 (page 28) Table 2 Related Manuals Manual Description pTAL Conversion Guide Provides information needed to convert TAL programs to pTAL programs. pTAL Guidelines for TAL Programmers Gives guidelines for writing TAL code that you can migrate later to pTAL code with as few changes as possible. TAL Programmer’s Guide Helps you get started in creating, structuring, compiling, running and debugging programs.
Table 4 Programming Manuals (continued) Manual Description Guardian Programmer’s Guide Explains how to use the programmatic interface of the operating system H-Series Application Migration Guide Explains how to migrate programs from TNS/R to TNS/E TAL Programmer’s Guide Contains information that you need about the HP Transaction Application Language (TAL) if you plan to call TAL routines from TNS HP COBOL programs TAL Programmer’s Guide Data Alignment Addendum Documents the data alignment requireme
Table 5 Program Development Manuals (continued) Manual Description noft Manual Explains how to use the noft utility to display TNS/R object files (PIC and non-PIC) Object Code Accelerator Manual Explains how to accelerate TNS and TNS/R object files for a TNS/E system.
1 Introduction to pTAL pTAL is based on the HP Transaction Application Language (TAL). You can compile pTAL source code with either the pTAL or EpTAL compiler.
Table 6 EpTAL, pTAL, and TAL Compiler Characteristics Compiler Object Code Generated EpTAL TNS/E object code—PIC (position-independent code) pTAL TNS/R object code—Non-PIC (default) or PIC TAL TNS object code—Non-PIC Difference between pTAL and EpTAL compilers: pTAL Compiler EpTAL Compiler On Guardian platforms, object files have the file code 700 On Guardian platforms, object files have the file code 800 pTAL code cannot use 64-bit addressing functionality added to TNS/E pTAL starting with SPR T0
• ◦ Special subsystems ◦ Special routines that support data communication activities Transaction-oriented applications ◦ Server processes used with HP data management software ◦ Conversion routines that allow data transfer between HP software and other applications ◦ Procedures that are callable from programs written in other languages ◦ Applications that require optimal performance You cannot embed SQL/MP or SQL/MX statements in pTAL source code.
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.
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.
called from a program with an HP C main routine. There are additional restrictions on what operations can be performed in the pTAL routines. For complete details on writing pTAL routines that run in the CRE, see the CRE Programmer’s Guide.
2 Language Elements The elements that make up the pTAL language include: • Character Set (page 36) • Keywords (page 37) • Delimiters (page 38) • Operators (page 39) • Base Address Symbols (page 40) • Indirection Symbols (page 41) • Declarations (page 41) • Typed Integer Constants (page 44) • Statements (page 45) Character Set pTAL supports the complete ASCII character set, which includes: • Uppercase and lowercase alphabetic characters (A through Z.
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 9 (page 37)) for your identifiers. Nonreserved You can use nonreserved keywords anywhere identifiers are allowed except as noted in the Restrictions column of Table 10 (page 37).
Table 10 Nonreserved Keywords (continued) Keyword Restrictions NAME None NODEFAULT None PRIVATE Not to be used as an identifier in a source file that contains the NAME declaration RETURNSCC None SHARED2 None SHARED8 None UNSPECIFIED None WORDS Not to be used as an identifier of a LITERAL or DEFINE Delimiters Delimiters are symbols that begin, end, or separate fields of information. Delimiters tell the compiler how to handle the fields of information.
Table 11 Delimiters (continued) Symbol Character Representation Uses -> Hyphen plus right angle bracket • Begins one or more labels in a labeled CASE statement • Begins a next-addr clause in a SCAN or RSCAN statement • Begins a next-addr clause in a move statement • Begins a next-addr clause in a group comparison expression "string" Quotation marks Delimit a character string "" Consecutive quotation marks The first quotation mark indicates that the second quotation mark is not a delimiter in a cha
Table 12 Operators (continued) Context Arithmetic expression Relational expression Operator Description '>>' Unsigned right shift + Signed addition - Signed subtraction * Signed multiplication / Signed division '+' Unsigned addition '-' Unsigned subtraction '*' Unsigned multiplication '/' Unsigned division '\' Unsigned modulo division LOR Logical OR bit-wise operation LAND Logical AND bit-wise operation XOR Exclusive OR bit-wise operation < Signed less than = Signed equal t
Table 13 Base Address Symbols (continued) Symbol Description 'G' References data relative to the beginning of the Global data area (not supported by pTAL). 'L' References data relative to the beginning of the Procedure (not supported by pTAL). 'S' References data relative to the beginning of the Subprocedure (not supported by pTAL). Indirection Symbols Indirection symbols determine the address types of variables.
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 (page 389). • 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.
Table 15 Identifier Classes (continued) Class Description Template Template structure * Available only on Guardian platforms. 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.
int k := i + j; ! k has sublocal scope and is visible only ! in subprocedure s. end; ! k is not visible here. It is created and destroyed every ! time subprocedure s is called. end; ! j is not visible here. It is created and destroyed every time ! procedure p is called. ! i is accessible here and exists as long as the program is ! running. Variables that have different scopes can have the same name, but they are different variables.
Number Base Example INT(16) Octal %57 INT(32) Octal %57D or %57%D or %57 D FIXED Octal %57D or %57%F or %57 F INT(16) Hexadecimal %H2F INT(32) Hexadecimal %H2F%D or %H2F D (space or % required) FIXED Hexidecimal %H2F%F or %H2F F (space or % required) Statements A statement specifies operations to be performed on declared objects. Statements are discussed in Chapter 12 (page 199), and summarized in Table 55 (page 199).
3 Data Representation A program operates on data—variables and constants—which it stores in the storage units that Table 17 (page 46) describes. Table 17 Storage Units Storage Unit Number of Bits Description Byte 8 Smallest addressable unit of memory.
Table 18 Data Types (continued) Data Type Storage Unit1 Values the Data Type Can Represent REAL(64) Quadrupleword 64-bit floating-point number in the same range as data type REAL but precise to approximately 16.5 significant decimal digits.
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.
Table 19 Operations by Data Type (continued) Operation STRING INT(32) or INT or UNSIGNED UNSIGNED (1-16) (17-31) Bit shifts Yes Yes Yes No No Byte scans Yes Yes Yes Yes Yes FIXED REAL or REAL(64) The data type of a variable also determines which built-in routines you can use with the variable (see Chapter 15 (page 274)). Address Types Every identifier that you declare has both a data type and an address type. The data type describes the data item itself.
Table 20 Data Types and Their Address Types (continued) Pointer Declaration STRUCT SUBSTRUCT .EXT32 t; .EXT32 v; Data Type Address Type Storage Unit1 none EXT32ADDR4 Byte none 4 Byte 4 addr-type .EXT32 a; address_type EXT32ADDR Byte STRING .EXT64 s; STRING EXT64ADDR4 Byte INT .EXT64 i; INT EXT64ADDR4 Byte INT(32) .EXT64 k; INT(32) EXT64ADDR4 Byte 4 Byte 4 REAL .EXT64 r; REAL EXT64ADDR FIXED .EXT64 f; FIXED EXT64ADDR Byte STRUCT .
1 Table 17 (page 46) describes storage units. 2 addr-type is any of the ten address types. 3 address_type is the same address type as specified in the declaration. 4 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). You can compare addresses using the relational operators described in Table 12 (page 39).
Converting Between Address Types You can convert an address from one address type to another using either: • Built-in address-conversion functions (see Table 61 (page 283)) • Shift operations and low-level built-in routines These conversions are supported for compatibility with TAL. HP recommends that you use the equivalent pTAL routine when you write pTAL code.
Table 21 Valid Address Conversions FROM TO B A D D R W A D D R C B A D D R C W A D D R S G B A D D R S G X B A D D R S G W A D D R S G X W A D D R E X T A D D R E X T 32 A D D R P R O C A D D R * P R O C 32 A D D R E X T 64 A D D R * * P INT R O C 64 A D D R = r7 r r c r1 WADDR r9 = r r c r2 = 9 CWADDR 9 = SGBADDR = = R7 r7 c y3 SGXBADDR = = R7 r7 c y3 SGWADDR r8 r8 = = c y4 SGXWADDR r8 r8 = = c y4 EXTADDR F I (32) X E D 0 * BADDR CBADDR IN
NOTE: 1. In assignment statements, only INT constants are allowed. They are interpreted as a ‘G’-relative byte address. 2. In assignment statements, only INT constants are allowed. They are interpreted as a ‘G’-relative word address. 3. Input INT interpreted as ‘SG’-relative byte address. 4. Input INT interpreted as ‘SG’-relative word address. 5. Output INT holds ‘SG’-relative byte address. 6. Output INT holds ‘SG’-relative word address. 7.
Using Arithmetic Operations to Adjust Addresses You can add an integer value to any address type except PROCADDR, PROC32ADDR, and PROC64ADDR. The address can be on either side of the operator. Example 7 Adding Integer Values to Addresses INT .p; @p := @p '+' 4; @p := 4 '+' @p; @p := @p[2]; ! Increment WADDR pointer by four 16-bit words ! Increment WADDR pointer by four 16-bit words You can subtract an integer value from any address type except PROCADDR, PROC32ADDR, and PROC64ADDR.
Comparing Addresses to Addresses You can compare addresses only if both addresses are the same address type, except that: • SGBADDR and SGXBADDR are interchangeable with one another • SGWADDR and SGXWADDR are interchangeable with one another You must use signed relational operators (<, =, >,<=, <>, >=) to compare EXTADDR, EXT32ADDR, and EXT64ADDR addresses.
Constants • Character String (page 57) • STRING Numeric (page 58) • INT Numeric (page 58) • INT(32) Numeric (page 59) • FIXED Numeric (page 61) • REAL and REAL(64) Numeric (page 62) • Constant Lists (page 63) • Constant List Alignment Specification (page 64) Character String A character string constant consists of one or more ASCII characters stored in a contiguous group of bytes. string is a sequence of one or more ASCII characters enclosed in quotation mark delimiters.
Example 10 Assigning Character Strings to Variables STRING s; INT i; s := "a"; s := "ab"; s := "abc"; i := "a"; i := "ab"; I := "abc"; ! ! ! ! ! ! OK OK: same as s := "b" ERROR: too big OK OK ERROR: too big STRING Numeric Representation Unsigned 8-bit integer Range 0 through 255 base indicates a number base as follows: Octal % Binary %b Hexadecimal %h If you omit the base, the default base is decimal.
base indicates a number base as follows: Octal % Binary %b Hexadecimal %h The default base is decimal. 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) Examples of INT numeric constants: Decimal 3 -32045 Octal %177 -%5 Binary %B01010 %b1001111000010001 Hexadecimal %H1A %h2f The system stores signed integers in two’s complement notation.
base indicates a number base as follows: Octal % Binary %b Hexadecimal %h The default base is decimal.
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 base indicates a number base as follows: Octal % Binary %B Hexadecimal %H The default base is decimal. 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.
Binary %B1010111010101101010110F Hexadecimal %H298756%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.
Decimal Value -17.2 REAL REAL(64) 20.0E-1 20.0L-1 -17.2E0 -1720.0E-2 -17.2L0 -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.
repetition-constant-list 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 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.
A1 ':=' [1,2,3,4]; A1 ':=' FIELDALIGN(SHARED2) [1,2D,4]; ! No alignment specification ! required ! Alignment specification required ! to specify 2-byte alignment for ! 2D Examples of constant lists: 1. In each of the following pairs, the list on the left is equivalent to the list on the right: 2. [ "A", "BCD" , "...", "Z" ] [ "ABCD...
4 Data Alignment 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 address is a multiple of four. An address that is not aligned is called misaligned. In native mode, a compiler requires data to be aligned unless otherwise indicated. Unexpected misalignment causes the program to run slowly, but usually with the expected results.
Because a process can run for a long time, the tracing facility samples the process (that is, checks its exception data) periodically (approximately once an hour). If the process recorded an exception since the previous sample, the tracing facility records an entry in the EMS log. If the process ends and an exception has occurred since the last sample, the operating system produces a final Event Management Service (EMS) event.
NOTE: ROUND misalignment handling is intended as a temporary solution, not as a substitute for changing your atomic calls to ensure that they have only aligned addresses. ROUND misalignment handling cannot be migrated to past and future NonStop OS platforms.
5 Expressions An expression is a sequence of operands and operators that, when evaluated, produces a single value. Operands in an expression include variables, constants, and routine identifiers. Operators in an expression perform arithmetic or conditional operations on the operands.
• Comparing Addresses (page 77) • Constant Expressions (page 81) • Conditional Expressions (page 81) • Special Expressions (page 85) • Bit Operations (page 92) Data Types of Expressions The result of an expression can be any data type or address type except STRING or UNSIGNED. The compiler determines the data type of the result from the data type of the operands in the expression.
Table 23 Precedence of Operators (continued) Operator Operation Precedence / Signed division '*' Unsigned multiplication '/' Unsigned division '\' Unsigned remainder + Signed addition - Signed subtraction '+' Unsigned addition '-' Unsigned subtraction LOR Bitwise logical OR LAND Bitwise logical AND XOR Bitwise exclusive OR < Signed less than = Signed equal to > Signed greater than <= Signed less than or equal to >= Signed greater than or equal to <> Signed not equal to '
Arithmetic Expressions An arithmetic expression is a sequence of operands and arithmetic operators that computes a single numeric value of a specific data type. +, are unary plus and minus operators. The default is unary plus. operand is one of the elements in Table 24 (page 72).
Table 25 Arithmetic Expressions (continued) Syntax Example expression operand expression 2 * 3 + var / 2 expression operand expression 2 * var * 4 A condition code cannot appear inside an arithmetic expression; for example, the following is not valid in pTAL: a := <; !Illegal Signed Arithmetic Operators Table 26 Signed Arithmetic Operators Operator Operation Operand Type* Example + Unary plus Any data type +5 - Unary minus Any data type -5 + Binary signed addition Any data type alpha
Topics: • Scaling of FIXED Operands (page 74) • Using FIXED(*) Variables (page 74) Scaling of FIXED Operands When you declare a FIXED variable, you can specify an implied fixed-point (fpoint ) setting (see Specifying Data Types (page 47)). When FIXED operands in an arithmetic expression have different fixed-points, the system “scales” them, depending on the operation: Operation Scaling Addition or subtraction The system adjusts the smaller fixed-point to match the larger fixed-point.
Unsigned Arithmetic Operators Typically, you use binary unsigned arithmetic on operands with values in the range 0 through 65,535. For example, you can use unsigned arithmetic with pointers that contain standard addresses.
Bitwise Logical Operators Use bitwise logical operators (LOR, LAND, and XOR) to perform bit-by-bit operations on STRING, INT, UNSIGNED(1-16) operands. Use INT(32) operands to return INT(32) results. 16-bit operands produce a 16-bit result. 32-bit operands produce a 32-bit result. Bitwise logical operators are not defined for 64-bit operands.
The quotient or remainder of an FIXED dividend and an INT(32) divisor is an INT(32) quotient in the range 0 to 232-1. $OVERFLOW (page 335) returns false after an unsigned division or remainder operator unless either of the following is true: ◦ The divisor is 0 ◦ The quotient is greater than 216-1 for an INT quotient, 232-1 for an INT(32) Comparing Addresses pTAL rules for comparing address types are more restrictive than the rules for comparing nonaddress types.
Example 11 Extended Addresses EXTADDR e; EXT32ADDR e32; EXT64ADDR e64; INT .EXT i; INT .EXT32 j; INT .EXT64 k; IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF IF e < @i THEN ... e < @j THEN ... e < @k THEN ... @i >= 0D THEN ... @j >= 0D THEN ... @k >= 0F THEN ... e = 0D THEN ... e <> 0D THEN ... e THEN ... NOT e THEN ... e32 = 0D THEN ... e32 <> 0D THEN ... e32 THEN ... NOT e32 THEN ... e64 = 0F THEN ... e64 <> 0F THEN ... e64 THEN ... NOT e64 THEN ... e > i THEN ... e32 > i THEN ...
IF @s = b THEN ... IF @s = @b THEN ... • ! OK: @s is BADDR, b is BADDR ! ERROR: @s is BADDR, @b is WADDR If one operand of a relational operator is a nonextended address and the other is a constant, the constant must be 16 bits in length: INT .p; IF @p = 100 THEN ... IF @p = 100D THEN ... ! OK ! ERR Table 32 Valid Address Expressions Template Result Type Examples atype [k]; atype * INT .EXT p; @p := @p[2]; atype '+' INT atype * INT .
Table 32 Valid Address Expressions (continued) Template Result Type Examples INT(32) i32; i32 := @bp - @b; EXT64ADDR - EXT64ADDR FIXED(0) .EXT64 b bp; FIXED i64; i64 := @pb - b; atype relational atype INT INT BADDR b1, b2; INT i; IF b1 '<' b2 THEN ...; i := b1 '<' b2; relational must be an unsigned relational operation ('<', '=', '>', '<=', '<>', '>=') or signed equal or not equal (=, <>).
Table 32 Valid Address Expressions (continued) Template Result Type Examples IF 20d < e32a THEN ... IF 0D <> e64a THEN ... * atype represents any address type except PROCADDR or EXTADDR. ** 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). Constant Expressions A constant expression is an arithmetic expression that contains only constants, LITERALs, or DEFINEs as operands.
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 Table 33 Conditional Expressions Syntax Example condition a NOT condition NOT a condition OR condition a OR b condition AND condition a AND b condition AND NOT condition a AND NOT b OR c Table 34 Conditions in Conditional Expressions Element Description Example Relational expressi
Table 35 Results of NOT, OR, and AND Operators Operator Operation Operand Type Result Example NOT Negation; tests condition for false state STRING, INT, or UNSIGNED(1-16) True/False NOT a OR Disjunction; produces true state if either adjacent condition is true STRING, INT, or UNSIGNED(1-16) True/False a OR b AND Conjunction; produces STRING, INT, or true state if both UNSIGNED(1-16) adjacent conditions are true True/False a AND b Topics: • Evaluating NOT, OR, and AND Operations (page 83)
Table 36 Signed Relational Operators Operator Meaning Operand Type* Result < Signed less than Any data type True/False = Signed equal to Any data type True/False > Signed greater than Any data type True/False <= Signed less than or equal to Any data type True/False >= Signed greater than or equal Any data type to True/False <> Signed not equal to True/False Any data type * The data type of the operands must match except as noted in Data Types of Expressions (page 70).
Relational Operator Result Returned <= or '<=' True if CCL or CCE >= or '>=' True if CCE or CCG Examples of unsigned operators are as follows: IF VAR '>' 10 THEN ... ELSE IF < THEN -- Unsigned less than ... ; IF VAR '<' 5 THEN ... ELSE IF '>' THEN -- Unsigned greater than ... ; Special Expressions Special expressions allow you to perform specialized arithmetic or conditional operations.
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. 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.
Example 14 CASE Expression INT x, a, b, c, d; !Code to initialize variables x := CASE a OF BEGIN b; ! If a is c; ! If a is d; ! If a is OTHERWISE -1; ! If a is END; ! assign 0, assign 1, assign 2, assign any other -1 to x. value of b to X. value of c to X. value of d to X. value, IF The IF expression selects one of two expressions, usually for assignment to a variable. condition is either: • A conditional expression • An INT arithmetic expression.
You can nest IF expressions within an IF expression or within other expressions. The IF expression resembles the IF (page 217) 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.
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 (including those declared in structures) STRING INT INT(32) or REAL FIXED or REAL(64) Bytes Words Doublewords Quadruplewords Structure Not applicable Words Substructure Not applicable Bytes Structure pointer STRING INT Bytes Words count-unit is BYTES, WORDS, or ELEMENTS.
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 Chapter 3 (page 46). 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.
Figure 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 ...
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 15 (page 92) 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.
Table 39 Bit Operations Bit Operation Description Extraction Accesses a bit-extraction field in an INT expression without altering the expression Deposit Assigns a bit value to a bit-deposit field in a variable Shift Shifts a bit-shift field in an INT or INT(32) expression to the left or to the right by a specified number of bits Topics: • Bit Extractions (page 93) • Bit Shifts (page 94) Bit Extractions int-expression is an INT(32) expression.
Example 18 Bit Extraction INT i; UNSIGNED(4) j; STRING k; INT(32) l; i := j.<7:11>; i := k.<0:7>; i := l.<8:31>; ! ERROR: You can reference only bits 12 ! through 15 of j ! ERROR: You can reference only bits 8 ! through 15 of k ! OK: You can reference any of bits 0 ! through 31 of l Example 19 Bit Extraction From an Array STRING right_byte; INT array[0:7]; right_byte := array[5].<8:15>; Example 20 (page 94) assigns bits 4 through 7 of the sum of two numbers to RESU<.
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.
Bit-shift operations include: Operation User Action Multiplication by powers of 2 For each power of 2, shift the field one bit to the left. (Some data might be lost.) Unsigned division by powers of 2 For each power of 2, shift the field one bit to the right (Some data might be lost.) Word-to-byte address conversion Shift the word address one bit to the left by using an unsigned shift operator. Bit shift examples: 1.
6 LITERALs and DEFINEs A LITERAL declaration associates identifiers with constant values. A DEFINE declaration associates identifiers (and parameters if any) with text. You can declare LITERALs and DEFINEs once in a program, and then refer to them by identifier many times throughout the program. They allow you to efficiently make significant changes in the source code. You only need to change the declaration, not every reference to it in the program.
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.
param-list param-name is 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.
INT item1; INT item2; INT yrname; END; mystruct.myname := 1; mystruct.yrname := 2; ! Structure item has same ! identifier as a DEFINE ! OK: 1 is assigned to mystruct.item1 ! 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.
The number of actual parameters can be less than the number of formal parameters. If actual parameters are missing, the corresponding formal parameters expand to empty text. For each missing actual parameter, you can use a placeholder comma, as in Example 27 (page 101).
Example 32 Assignment Statement Using DEFINE Macro Identifier DEFINE cube (x) = ( x * x * x ) #; INT result; result := cube (3) '>>' 1; ! Expands to: (3 * 3 * 3) '>>' 1 = 27 '>>' 1 = 13 Example 33 Incrementing and Decrementing Utilities DEFINE increment (x) = x := x + 1 #; DEFINE decrement (y) = y := y - 1 #; INT index := 0; increment(index); ! Expands to: index := index + 1; Example 34 Filling an Array With Zeros DEFINE zero_array (array, length) = BEGIN array[0] := 0; array[1] ':=' array FOR length - 1;
7 Simple Variables A simple variable is a single-element data item of a specified data type that is not an array, a structure, or a pointer. After you declare a simple variable, you can use its identifier in statements to access or change the data contained in the variable. You must declare variables before you use them. This section defines the syntax for declaring simple variables.
• EXTADDR • EXT32ADDR • EXT64ADDR • INT • INT(32) • FIXED • FIXED (fpoint ) • PROCADDR • PROC32ADDR • PROC64ADDR • REAL • REAL • REAL(64) • SGBADDR • SGWADDR • SGXBADDR • SGXWADDR • STRING • UNSIGNED (width ) • WADDR NOTE: The data types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
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.
Example 36 Declaring Simple Variables Without Initializing Them STRING b; INT(32) dblwd1; REAL(64) long; UNSIGNED(5) flavor; BADDR ba; WADDR wa; EXTADDR ea; Example 37 Declaring and Initializing Simple Variables STRING y := "A"; STRING z := 255; INT a := "AB"; INT b := 5 * 2; INT c := %B110; INT(32) dblwd2 := %B1011101D; INT(32) dblwd3 := $DBL(%177775); REAL flt1 := 365335.6E-3; REAL(64) flt2 := 2718.
Example 38 Effect of fpoint on FIXED Simple Variables FIXED(-3) f := 642987F; FIXED(3) g := 0.642F; FIXED(2) h := 1.234F; ! Stored as 642; accessed as 642000 ! Stored as 642, accessed as 0.642 ! Stored as 123; accessed as 1.
8 Arrays An array is a one-dimensional set of elements of the same data type. Each array is stored as a collective group of elements. You use arrays to store constants, especially character strings. After you declare an array, you can use its identifier to access the array elements individually or as a group. You can declare: • Arrays • Read-only arrays • Address arrays The declaration includes initializing the array as well as allocating storage for the array.
• CWADDR • EXTADDR • EXT32ADDR • EXT64ADDR • FIXED (fpoint ) • INT • INT(32) • FIXED • PROCADDR • PROC32ADDR • PROC64ADDR • REAL • REAL • REAL(64) • SGBADDR • SGWADDR • SGXBADDR • SGXWADDR • STRING • UNSIGNED (width ) • WADDR NOTE: The data types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP.
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.
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 Example 45 Initializing Arrays INT(32) a[0:1] := [5D, 7D]; PROC my_procedure; BEGIN STRING b[0:1] := ["A","B"]; FIXED EXT c[0:3]; SUBPROC my_subproc; BEGIN INT d[0:2] := ["Hello!"]; ! Lots of code END; END; ! Initialize global array ! Initialize local standard array ! Cannot initialize
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.
Example 49 Declaring and Initializing a Read-Only Array STRING prompt = 'P' := ["Enter Character: ", 0]; INT error = 'P' := ["INCORRECT INPUT"]; Using Constant Lists in Array Declarations pTAL requirements for array declarations are: • If an array declaration includes an initialization string, the size of a constant list must be less than or equal to the size of the array. If the constant list is larger than the array, an error occurs.
9 Structures A structure is a collectively stored set of data items that you can access individually or as a group. Structures contain structure items (fields) such as simple variables, arrays, simple pointers, structure pointers, and nested structures (called substructures). The structure items can be of different data types. Structures usually contain related data items such as the fields of a file record.
• Declaring Filler (page 147) • Declaring Simple Pointers in Structures (page 148) • Declaring Structure Pointers in Structures (page 151) • Declaring Redefinitions (page 153) • Simple Variable (page 153) • Array (page 154) • Definition Substructure (page 155) • Referral Substructure (page 157) • Simple Pointer (page 158) • Structure Pointer (page 159) Equivalenced structures are discussed in Chapter 11 (page 177).
• 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.
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. Structures Aligned at Odd-Byte Boundaries If you attempt to access data at an odd-byte address, the results are undefined, whether the data is a simple variable or a field of a structure. Your program might or might not trap.
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.
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. Differences Between PLATFORM and AUTO PLATFORM structures and substructures can contain UNSIGNED and STRING items within a 2-byte word.
Structure Alignment Examples The following examples illustrate how your structure data layout is affected by structure alignment. Only SHARED8 structures are shown because SHARED2 structures are not well-aligned. pTAL always generates conservative code for references to fields of a SHARED2 structure that are more than 16 bits long. Figure 4 (page 120) shows a structure, s1, that specifies FIELDALIGN(SHARED8). Because the widest field in the structure, f, is a FIXED field, the base alignment of s1 is 8.
Figure 5 Well-Aligned and Misaligned SHARED8 Structures With Base Alignment of 8 Figure 6 (page 121) shows a structure that is declared FIELDALIGN(SHARED8). The widest fields in s2, i32a and i32b, are each four bytes; therefore, although the field alignment of s2 is SHARED8, the base alignment of s2 is four, not eight. s2 is well-aligned in memory if the base of the structure begins at any address that is a multiple of four.
Figure 7 Well-Aligned and Misaligned SHARED8 Structures With Base Alignment of 4 Array Alignment in Structures When you declare an array in a structure, the alignment of the beginning of the array is the alignment of the base type of the array. Thus, for example, the field alignment of an array of INTs is the same as the field alignment of a single INT, which is 2. Declaring an array in a structure is the same as explicitly declaring individual fields, each with the same data type as the array’s base type.
An array of structures or substructures is the same as an array of a pTAL data type. The width of the widest field of an element of such an array, combined with the FIELDALIGN parameter you specify, determines the required alignment of the structure or substructure and of its fields.
INT(32) c; END; STRUCT s3 FIELDALIGN(SHARED8); BEGIN STRING a; STRING b; FILLER 6; FIXED c; END; ! c is field with widest ! alignment: 4 ! Base alignment of structure is ! 8 because of FIXED c ! c is field with widest ! alignment: 8 Substructure Alignment The rules for field alignment of substructures are the same as the rules for structures.
Example 58 SHARED8 Structures With SHARED2 Substructures STRUCT t_s2(*) FIELDALIGN(SHARED2); BEGIN INT(32) j; END; STRUCT t_s8(*) FIELDALIGN(SHARED8); BEGIN INT(32) j; END; ! Base alignment of t_s2 ! is 2 ! Base alignment of t_s8 ! is 4 Example 59 SHARED2 Structures With SHARED8 Substructure STRUCT s1 FIELDALIGN(SHARED2); BEGIN INT i; STRUCT s2(t_s8); ! END; ! INT .p2(t_s8) REFALIGNED(2); ! INT .p3(t_s8); ! ! PROC p; BEGIN INT i; @p2 := @s1.s2 '>>' 1; @p3 := @s1.s2 '>>' 1; i := p2.j; i := p3.j; ...
Example 60 SHARED8 Structure With SHARED2 Substructure STRUCT s3 FIELDALIGN(SHARED8); BEGIN ! Base alignment of s3 is 4 INT i; STRUCT s4(t_s2); ! s2 has SHARED8 alignment END; ! Base alignment of s2 is 4 INT .p4(t_s2); ! Uses default alignment: 2 The compiler always generates conservative code. In Example 60 (page 126), 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.
substructure but might not be well-aligned with respect to the base of the SHARED2 structure. Performance will be somewhat degraded when fields in the substructure are referenced. If a SHARED2 substructure is contained in a SHARED8 structure (or in an AUTO structure), fields in the SHARED2 substructure will be well-aligned with respect to the base of the SHARED2 substructure but might not be well-aligned with respect to the base of the SHARED8 structure.
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: ◦ An UNSIGNED(1-16) field cannot cross an even-byte address boundary.
Example 63 FIELDALIGN(SHARED2) and REFALIGNED(2) Directives ?FIELDALIGN(SHARED2) ?REFALIGNED(2) INT(32).ptr; PROC p; BEGIN @ptr := @str.F32; ... := ptr + END; 3D; ! Global pointer ! str.F32 might or might not be aligned ! at a 32-bit address. REFALIGNED ! directive ensures that pTAL ! generates conservative code for ! references to ptr.
Table 45 Variable Alignment (continued) Data Type Alignment Notes .SGX pointers 4 Allowed in structures only with AUTO field alignment.** Other 16-bit pointers 4 Allowed in structures only with AUTO field alignment.** 32-bit Pointer 4 64-bit Pointer*** 8 INT(32) 4 REAL 4 UNSIGNED(17-31) 4 FIXED 8 REAL(64) 8 Multiple UNSIGNED fields can be packed into a doubleword.
STRING END; s; ! ERROR: BADDR pointer is not valid NOTE: The address types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
Example 66 Structure With SHARED2 Field Alignment STRUCT s1 FIELDALIGN(SHARED2); BEGIN INT i; ! i begins at offset: 0 INT(32) j; ! j begins at offset: 2 STRING s1; ! s1 begins at offset: 6 STRING s2; ! s1 begins at offset: 7 FIXED f; ! f begins at offset: 8 INT k; ! k begins at offset: 16 END; ! Total length of s1: 18 bytes Structures that specify SHARED8 field alignment, however, require you to explicitly declare filler items to force fields to be well-aligned, as previously described.
Example 69 Structures That Need Filler STRUCT s1 BEGIN FIXED INT(32) FILLER END; STRUCT s2 BEGIN INT(32) INT FILLER END; FIELDALIGN(SHARED8); i; j; 4; ! Structure's widest field is 8 bytes ! j is 4 bytes FILLER 4 ! Pad with 4 bytes FIELDALIGN(SHARED8); i; j; 2; ! Structure's widest field is 4 bytes ! j is 2 bytes ! Pad with 2 bytes UNSIGNED(1-16) fields cannot cross an even-byte address.
Example 73 SHARED8 Structure With Correctly Aligned UNSIGNED Fields STRUCT s FIELDALIGN(SHARED8); BEGIN INT i; FILLER 2; ! Forces u to begin at a 4-byte address UNSIGNED(28) u; BIT_FILLER 4; ! Makes length of s an integral multiple of END; ! 4 bytes Reference Alignment With Structure Pointers When you declare a structure pointer, you can specify a REFALIGNED clause as part of the declaration. (For the syntax of a structure pointer, see Chapter 11 (page 177).
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, EXTADDR, EXT32ADDR, EXT64ADDR, PROC32ADDR, or PROC64ADDR. NOTE: The address types, EXT32ADDR, EXT64ADDR, PROC32ADDR, and PROC64ADDR are available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
To ensure good performance, use REFALIGNED(2) to access the field, even if it happens to be well-aligned. Always use REFALIGNED(2) unless you are certain that nearly all fields referenced by the pointer are well-aligned. Example 77 REFALIGNED(2) WADDR a_str; STRUCT s_templ(*) FIELDALIGN(SHARED8); BEGIN INT i; FILLER 2; INT(32) j; END; STRUCT s(s_templ); PROC p(struct_addr, p1); WADDR struct_addr; INT .p1(s_templ); BEGIN INT .
Example 78 REFALIGNED(8) STRUCT t1 (*) FIELDALIGN(SHARED2); BEGIN INT(32) i; END; STRUCT t2 (*) FIELDALIGN(SHARED8); BEGIN STRUCT s (t1); INT(32) i; END; INT .EXT p1 (t1) REFALIGNED (8) := extended-address; INT .EXT p2 (t2) REFALIGNED (2) := extended-address; INT .EXT p3 (t2) := extended-address; INT(32) i32; i32 := p1.i; i32 := p2.i; i32 := p3.s.i; 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).
Do not use STRUCT(MAXALIGN) within a SHARED2 structure. 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.
field-alignment 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.
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 (page 137)). field-alignment 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.
Example 80 Template Structure Declaration STRUCT inventory (*); BEGIN INT item; FIXED(2) price; INT quantity; END; ! Template structure ! Structure layout In Example 81 (page 141): • a and b are template structures. The compiler does not allocate space for them. • a1 and b1 are definition structures, defined using the layouts of template structures a and b, respectively. The compiler allocates space for a1 and b1.
Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). 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 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.
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 Chapter 3 (page 46). identifier is the identifier of the simple variable.
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 85 (page 144).
identifier is the identifier of the definition substructure. field-alignment 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.
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.
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. Example 87 Declaring a Referral Substructure STRUCT temp(*); BEGIN STRING a[0:2]; INT b; STRING c; END; STRUCT .
Example 88 Filler Byte Declarations LITERAL last = 11; STRUCT .x[1:last]; BEGIN STRING byte[0:2]; FILLER 1; INT word1; INT word2; INT(32) integer32; FILLER 30; END; ! Last occurrence ! Document word-alignment pad byte ! Place holder for unused space See also the filler byte example in Definition Substructure (page 155). Example 89 Filler Bit Declaration STRUCT .
Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). NOTE: Indirection symbols, .EXT32 and .EXT64 are available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). identifier is the identifier of the simple pointer. REFALIGNED specifies the base alignment of the structures that the structure pointer will reference.
Table 47 Addresses in Simple Pointers (continued) Addressing Mode Data Type Kind of Address Extended Any except STRING 32-bit or 64-bit* even-byte address, normally in the automatic extended data segment (if you specify an odd-byte address, results are undefined) * 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
Example 92 Assigning Addresses to Pointers in Structures STRUCT .s1; BEGIN INT var1; INT var2; END; STRUCT .s2; BEGIN INT .std_ptr (s1); INT .EXT ext_ptr (s1); INT .EXT32 ext32_ptr (s1); INT .EXT64 ext64_ptr (s1); END; PROC g MAIN; BEGIN @s2.std_ptr := @s1; @s2.ext_ptr := $XADR(s1); @s2.ext32_ptr := $WADDR_TO_EXTADDR(@s1); @s2.ext32_ptr := $XADR(s1); @s2.ext32_ptr := $XADR32(s1); @s2.ext64_ptr := $WADDR_TO_EXTADDR(@s1); @s2.ext64_ptr := $XADR32(s1); @s2.
INT is the INT attribute Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). NOTE: Indirection symbols, .EXT32 and .EXT64 are available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). identifier is the identifier of the structure pointer. referral is the identifier of a structure that provides the structure layout.
Example 93 Declaring a Structure Pointer Within a Structure STRUCT struct_a; BEGIN INT a; INT b; END; STRUCT struct_b; BEGIN INT .EXT struct_pointer (struct_a); STRING a; END; 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.
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 94 (page 154) redefines the left byte of int_var as string_var.
Example 95 Array Redefinition STRUCT .s; BEGIN INT a[0:3]; INT(32) b[0:1] = a; END; ! Redefine INT array as INT(32) array Definition Substructure A definition substructure redefinition associates a new definition substructure with a previous item at the same BEGIN-END level of a structure. identifier is the identifier of the new substructure.
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.
Example 96 Definition Substructure Redefinition STRUCT a; BEGIN STRING x; STRUCT b; BEGIN STRING y; END; STRUCT c = b; BEGIN STRING z; END; END; ! b starts on odd byte ! Redefine b as c, also on odd byte Example 97 Definition Substructure Redefinition STRUCT mystruct; BEGIN STRUCT mysub1; BEGIN INT int_var; END; STRUCT mysub2 = mysub1; BEGIN STRING string_var; END; END; ! Redefine mysub1 as mysub2 Referral Substructure A referral substructure redefinition associates a new referral substructure with a p
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.
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. Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). 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.
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. Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). 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.
10 Pointers This section describes the syntax for declaring and initializing pointers you manage yourself. You can declare the following kinds of pointers: • Simple pointer—a variable into which you store a memory address, usually of a simple variable or array, which you can access with this simple pointer. • Structure pointer—a variable into which you store the memory address of a structure which you can access with this structure pointer. The compiler allocates 32 bits for all pointers except .SG.
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.
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 (page 410).
! ! are volatile. Program reads from memory p1, p2, a, and element of array b referenced by p1 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.
Table 49 Address Types Data Type Address Type Target Data Pointer Size Example BADDR Byte 16-bit address to 1-byte-aligned data 32 STRING .s; WADDR Word 16-bit address to 2-byte-aligned data 32 INT .i; CBADDR Byte 16-bit address to 32 1-byte-aligned, read-only data STRING s ='P':="A"; CWADDR Word 16-bit address to 32 2-byte-aligned, read-only data INT i = 'P' := 123; SGBADDR Byte 16-bit address to 1-byte-aligned, 'SG'-relative data 16 STRING .
Example 103 Determining Address Types INT .j; INT i; ! Pointer: address type is WADDR ! Simple variable: address type is WADDR Example 104 STRING .EXT s; EXTADDR STRING INT .EXT i; EXTADDR INT INT(32) .EXT j; EXTDDR INT(32)REAL .EXT r; EXTADDR REAL REAL(64) .EXT s; EXTADDR REAL(64)FIXED .EXT f; EXTADDR FIXED UNSIGNED(n) .EXT u; EXTADDR UNSIGNED STRUCT .EXT t; EXTADDR none SUBSTRUCT .EXT v; EXTADDR none address_typeaddr-type .
Table 50 Object Data Types and Their Addresses (continued) Declaration Address Type 3 STRUCT .EXT64 t; 3 Object Data Type 3 none 3 EXT64ADDR SUBSTRUCT .EXT64 v; EXT64ADDR none addr-type1 .
Example 106 SGBADDR, SGWADDR, SGXBADDR, and SGXWADDR STRING INT STRING INT .SG .SG .SGX .SGX s; i; t; j; ! ! ! ! s i t j is is is is 16 16 32 32 bits bits bits bits PROCADDR, PROC32ADDR, and PROC64ADDR (Procedures, Procedure Pointers, and Procedure Entry Points) The address type of procedures, procedure pointers (PROCPTRs), and procedure entry points is PROCADDR.
p64a := $PROCADDR (pa); p64a := $PROCADDR (p32a); END; NOTE: PROC32ADDR, PROC64ADDR, PROC32PTR, and PROC64PTR are 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
Example 109 EXTADDR, EXT32ADDR, and EXT64ADDR Declarations INT STRING INT REAL INT STRING INT REAL INT STRING INT REAL .EXT i; .EXT s; .EXT g = 'SG' + 0; .EXT r; .EXT32 i32; .EXT32 s32; .EXT32 g32 = 'SG' + 0; .EXT32 r32; .EXT64 i64; .EXT64 s64; .EXT64 g64 = 'SG' + 0; .EXT64 r64; Declaring Simple Pointers A simple pointer declaration associates an identifier with a memory location that contains the user-initialized address of a simple variable or array.
• FIXED [ (fpoint ) ] • INT • INT (16) • INT (32) • INT (64) • PROCADDR • PROC32ADDR • PROC64ADDR • 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; Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). identifier is the identifier of the pointer.
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 49 (page 165) and Table 50 (page 166). 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.
Example 110 Declaring But Not Initializing a Simple Pointer INT(32) .ptr; Example 111 Declaring and Initializing a Simple Pointer STRING .bytes[0:3]; STRING .s_ptr := @bytes[3]; ! Indirect array ! Simple pointer initialized with ! address of bytes[3] Example 112 Declaring and Initializing a STRING Simple Pointer INT .a[0:39]; STRING .
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, .EXT32, .EXT64, .SG, .
Global structure pointers receive their initial values when you compile the source code. Local and sublocal structure pointers receive their initial values each time the procedure or subprocedure is activated. Example 116 Declaring and Initializing a Structure Pointer, Using $OFFSET STRUCT t (*); ! Template structure BEGIN INT k; END; STRUCT .st; ! Definition structure BEGIN INT j; STRUCT ss (t); END; INT .ip := @st '+' $OFFSET (st.j) '>>' 1; ! Simple pointer INT .stp (t) := @st '+' $OFFSET (st.
STRING first[0:3]; STRING last[0:3]; END; STRUCT .record; BEGIN STRUCT name (name_def); ! Declare substructure INT age; END; STRING .my_name (name_def) := @record.name; ! Structure pointer ! contains address ! of substructure my_name ':=' ["Sue Law"]; Example 120 Declaring and Initializing a Local STRING Structure Pointer BEGIN INT array[0:7]; STRUCT a_struct (*); BEGIN INT var; INT buffer1[0:3]; STRING buffer2[0:4]; END; INT .
11 Equivalenced Variables Equivalencing lets you declare more than one identifier and description for a location in a storage area. Equivalenced variables that represent the same location can have different data types and byte-addressing and word-addressing attributes. For example, you can refer to an INT(32) variable as two separate words or four separate bytes. You can equivalence any variable in the first column of Table 51 (page 177) to any variable in the second column.
• Declaring Equivalenced Definition Structures (page 188) • System Global Equivalenced Variable Declarations (page 193) Declaring Equivalenced Variables Table 53 Valid Equivalenced Variable Declarations Equivalenced Variable Category Equivalenced Variable Variable Example Previous Variable Category Direct Simple Variable INT i; Direct or Pointer Direct array INT i[0:3]; Direct structure STRUCT s; BEGIN INT i; END; Indirect array INT .
1 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). 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.
! standard indirect variable END; Declaring Nonstructure Equivalenced Variables Nonstructure equivalenced declarations include simple variables, pointers, and arrays. 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.
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.
Indirect Arrays Figure 8 (page 182) 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. Figure 8 Indirect Array pTAL Indirect Array INT .
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.
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.
You can equivalence standard pointers to indirect arrays and indirect structures, but you can only read the value of the pointer. You cannot store an address into the pointer. You can, however, read or write the data to which the pointer points. You can equivalence extended pointers to extended arrays and extended structures, but you can only read the value of the pointer. You cannot store an address into the pointer. You can, however, read or write the data to which the pointer points.
Table 54 Data Types for Equivalenced Variables (continued) Example Object Data Type Address Type BADDR .b; BADDR WADDR BADDR .EXT c; BADDR EXTADDR BADDR EXT32 d;1 BADDR EXT32ADDR1 BADDR EXT64 .e;1 BADDR EXT64ADDR1 EXTADDR a; EXTADDR WADDR EXTADDR .b; EXTADDR WADDR EXTADDR .EXT c; EXTADDR EXTADDR 1 EXTADDR .EXT32 d; EXTADDR EXT32ADDR1 EXTADDR .EXT64 e;1 EXTADDR EXT64ADDR1 EXT32ADDR .EXT f; EXT32ADDR1 EXTADDR EXT32ADDR .EXT32 g;1 EXT32ADDR1 EXT32ADDR1 EXT32ADDR .
pTAL does not verify that the lengths of the objects to which an equivalenced pointer refers are equal. pTAL accepts the declaration in Example 126 (page 187) because the address types of both pointers are WADDR. Example 126 Equivalenced Objects of Unequal Length INT .a; FIXED .
Example 128 Equivalencing Procedure Addresses and Pointer Variables PROCPTR pp; END PROCPTR; PROC32PTR p32p; END PROCPTR; PROC64PTR p64p; END PROCPTR; ! pp is a 32-bit procedure pointer PROCADDR pae = pp; ! ! ! ! ! ! pa is a procedure address equivalenced to a procedure pointer pa is a procedure address equivalenced to a procedure pointer p64a is a procedure address equivalenced to a procedure pointer PROCPTR ppe; END PROCPTR = pa; PROC32PTR p32pe; END PROCPTR = p32a; PROC64PTR p64pe; END PROCPTR = p64
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 specifies the memory alignment for the base of the structure and for fields within the structure. For details about the FIELDALIGN clause, see Chapter 9 (page 114). SHARED2 specifies that the base of the structure and each field in the structure must begin at an even byte address except STRING fields.
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.
New Structure Previous 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.
Example 131 Structure Variants STRUCT s FIELDALIGN(AUTO); BEGIN STRUCT v1; BEGIN INT .EXT e; ! e is 4 bytes END; STRUCT v2 FIELDALIGN(SHARED8) = v1; BEGIN INT .p; ! p is 4 bytes INT q; ! Compiler reports a warning END; END; In Example 131 (page 192), 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.
Example 133 Memory Usage for Structured Equivalenced Variables (Correct) STRUCT b BEGIN INT i; STRING END; STRUCT a BEGIN STRING STRING STRING END; FIELDALIGN(AUTO); j; ! pTAL adds a byte after the declaration of j FIELDALIGN(SHARED2) = b; i; j; k; FIELDALIGN Clause The FIELDALIGN clause specifies the alignment of the fields of a structure and the alignment of the structure itself in memory.
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.
Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). 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.
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.
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.
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.
12 Statements Statements—also known as executable statements—perform operations in a program. They can modify the program’s data or control the program’s flow.
Compound Statements A compound statement is a BEGIN-END block that groups statements to form a single logical statement. 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.
1. 2. Put an ASSERTION directive in the source code, specifying an assertion-level and an error-handling procedure. Put an ASSERT statement at each place where you want to execute the error-handling procedure when an error occurs.
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.
Topics: • Pointer Assignment (page 203) • Assigning Numbers to FIXED Variables (page 203) • Assigning Character Strings (page 203) • Examples (page 203) 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.
FIXED fixed_var; array[2] := 255; @ptr := @array[1]; ptr := array[2]; real_var := 36.
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 (:=).
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 is an expression of the type STRING . or STRING .EXT. length is an INT expression that specifies the length, in bytes, of string.
Example 146 CALL Statement PROC p (a, b, c); INT(32) a; REAL b; REAL(64) c; BEGIN END; PROC q; BEGIN CALL p(1.0E0, ! ERROR: Cannot pass REAL to INT(32) 1D, ! ERROR: Cannot pass INT(32) to REAL 1F); ! ERROR: Cannot pass FIXED to REAL(64) END; 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.
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 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.
BEGIN ! formal parameter CASE area_code OF ! Selector is area_code BEGIN 408, 415 -> location := bay_area; 213, 818 -> location := los_angeles; 808 -> location := hawaii; OTHERWISE -> location := elsewhere; END; ! End CASE statement END; ! End area_proc 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.
Example 150 Unlabeled CASE Statement INT(32) i; CASE i OF BEGIN ... END; CASE i OF BEGIN 0-> ... 1-> ... END; If you omit the OTHERWISE clause and selector is out of range (negative or greater than n), a divide-by-zero instruction trap occurs.
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 (page 232)).
Example 155 DO-UNTIL Statement With Hardware Indicator INT exit_loop; ... exit_loop := FALSE; DO BEGIN ... READ(...); IF <> THEN exit_loop := TRUE; END UNTIL exit_loop; Example 156 DO-UNTIL Statement With GOTO Statement DO BEGIN ... READ(...); IF <> THEN GOTO out; END UNTIL false; out: ... DROP The DROP statement removes either a label (from the symbol table) or a temporary variable that was created by the statement USE (page 232). identifier is the identifier of either a label or a temporary variable.
index is a value that increments or decrements automatically. In Standard (page 214), index is the identifier of an INT or INT(32) simple variable, array element, simple pointer, or structure data item. In Optimized (page 214), index is the identifier of an index register you have reserved with the USE (page 232). 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).
Example 157 Nested FOR Statement INT .multiples[0:10*10-1]; INT row; INT column; FOR row := 0 TO 9 DO FOR column := 0 TO 9 DO multiples [row * 10 + column] := column * (row + 1); 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: ◦ The step value is 1. ◦ You use the TO keyword (not DOWNTO). ◦ The limit value (not a GOTO statement) terminates the looping.
RETURN 10; END; INT PROC p2; BEGIN USE i; y := 0; FOR i := 1 to q() DO ... ; RETURN x; END; ! p2 has optimized FOR statement ! q is called 1 time ! i=10 here ! p2 returns 1 GOTO The GOTO statement unconditionally transfers control to a labeled target statement. label-name is the label that precedes the target statement (see Labels in Procedures (page 273)). A GOTO statement can be either local or nonlocal.
int i; label L1; int subproc s (x); int (x); begin label L2: if x = 0 then goto L1; if x > 10 goto L2; return 1; L2: return x; end; i := s (global_var); if i <> 1 then goto L1; ! Processing occurs here L1: end; ! Nonlocal goto ! Local goto ! Local goto GOTO and Target Statements With Different Trapping States A GOTO statement, local or nonlocal, must have the same trapping state as its target statement.
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.
Topics: • Testing Address Types (page 218) • Testing Hardware Indicators (page 218) Testing Address Types An IF statement can test the following as if they were Boolean values: • • Any 16-bit-compatible value: ◦ INT ◦ STRING ◦ UNSIGNED(1-16) All address-typed variables except: ◦ CBADDR ◦ CWADDR ◦ PROCADDR ◦ PROC32ADDR ◦ PROC64ADDR NOTE: The procedure address types, PROC32ADDR, and PROC64ADDR are available in the 64-bit addressing functionality added to the EpTAL compiler starting with
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.
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 Simple pointer (including structure item) INT(32) or REAL FIXED or REAL(64) Doublewords Quadruplewords Structure Not applicable Structure occurrences Substructure Not applicable Substructure occurrences Structure Pointer (STRING and INT have meaning only in group comparison expressions and move statements.
Example 165 INT INT INT INT .EXT ea; .EXT64 e64a; .EXT64 n64a; .EXT na; e64a ‘:=’ ea FOR 10 words -> @n64a; ! OKAY e64a ‘:=’ ea FOR 10 words -> @na; ! Error: can’t store an address ! of type EXT64ADDR in a variable of type EXTADDR Example 166 (page 221) 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.
BEGIN d.s_sub ':=' s.s_sub FOR copies ELEMENTS; END; !Byte move of three ! substructure ! occurrences Destination Shorter Than Source The compiler reports a warning when it can detect that there are more bytes in the source of a move than in the destination of the move. For example, if the number of bytes to move is a constant or constant expression whose value is larger than the number of bytes in the destination.
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 poi
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.
CALL IF < CALL IF < p1 (i); THEN ... ; p2 (i); THEN ... ; ! Test return value ! Test condition code Procedures and Subprocedures In procedures and subprocedures that are not functions, a RETURN statement is optional. A nonfunction procedure or subprocedure that returns a condition code value, however, must return to the caller by executing a RETURN statement that includes cc-expression.
Example 177 Procedure Without RETURNSCC PROC p; BEGIN END; PROC q; BEGIN CALL p; IF < THEN ... ! ERROR: p did not return a condition code ! or a return value END; Example 178 (page 226) is similar to Example 177 (page 226), but is syntactically correct because p specifies RETURNSCC and returns a condition code value. Example 178 Procedure With RETURNSCC PROC p RETURNSCC; BEGIN INT i; ... RETURN i; END; PROC q; BEGIN CALL p; IF < THEN ...
Example 180 Function With RETURNSCC INT i; BEGIN INT cc_result; ... cc_result := IF i < max_val THEN -1 ELSE IF i = max_val THEN 0 ELSE 1; RETURN i, cc_result; ! Return a function value and a END; ! condition code that indicates ! whether the function value is ! less than, equal to, or ! greater than some maximum 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 (page 528).
Example 182 Condition Code Based on Numeric Value INT PROC p(i); INT i; BEGIN ... RETURN i; ! Return i and set the condition code END; ! based on the numeric value of i Example 183 Condition Code That Is Independent of the Function’s Value INT PROC p(i) RETURNSCC; INT i; BEGIN ...
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.
Determining What Stopped a Scan To determine what stopped a scan, test $CARRY in an IF statement immediately after the SCAN or RSCAN statement. Example 186 Determining What Stopped a Scan IF $CARRY THEN ... ; IF NOT $CARRY THEN ... ; ! If test character not found ! If test character found 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.
Data Layout Considerations Example 188 Scanning Adjacent Fields Within a Structure STRUCT s FIELDALIGN(SHARED2); BEGIN STRING buffer[0:99]; STRING stopper; END; BADDR end_addr; ... s.stopper := 0; SCAN s.buffer UNTIL char -> end_addr; IF end_addr = @s.stopper THEN ! Target character was not found BEGIN ... END; Data Passed to Procedures in Reference Parameters The rules in of the preceding subsection about data layouts apply if the buffer scanned in a SCAN statement is a reference parameter.
INT c := 3, z := -1; SCAN s UNTIL c -> t_start; t_start := t_start '+' 1; SCAN s[t_start '-' @s] UNTIL z -> t_end; ! ! ! ! ! Value to scan for in s Value to stop the scan? Scan s for c and store c's address in t_start Skip character in c ! Find end of message USE The USE statement creates a temporary variable. identifier is the name of the temporary variable being created.
Example 191 WHILE Statement LITERAL len = 100; INT .array[0:len - 1]; INT item := 0; WHILE item < len DO BEGIN array[item] := 0; item := item + 1; END; ! item equals len at this point The WHILE statement in Example 192 (page 233) increments index until a nonalphabetic character occurs. Example 192 WHILE Statement LITERAL len = 255; STRING .array[0:len - 1]; INT index := -1; WHILE (index < len - 1) AND ($ALPHA(array[index := index + 1])) DO ...
13 Hardware Indicators Table 56 Hardware Indicators Hardware Indicator Representation Meaning Overflow bit $OVERFLOW Carry bit $CARRY Condition code < or ‘<’ Less than > or ‘>’ Greater than = or ‘=’ Equal <= or ‘<=’ Less than or equal >= or ‘>=’ Greater than or equal <> or ‘<>’ Not equal In TNS architecture, a “hardware indicator” is one of three fields of the environment (ENV) register.
Example 193 OVERFLOW_TRAPS Compiler Directive and Procedure Attribute ?OVERFLOW_TRAPS PROC x NOOVERFLOW_TRAPS; BEGIN ... END; PROC y; BEGIN ... END; PROC z NOOVERFLOW_TRAPS; BEGIN SUBPROC s OVERFLOW_TRAPS; BEGIN ... END; ... s; ...
Hardware Indicators After Assignments Topics: • $OVERFLOW (page 236) • $CARRY (page 236) • Condition Codes (page 237) $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: ◦ Overflow traps are disabled.
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.
RETURN "A"; END; BEGIN PROC p1; INT i; i := p; END; ! P is an INT function but the ! expression in the RETURN statement ! yields a single byte ! Condition code is accessible because ! p returns an INT value The left side of the assignment statement must be one of: ◦ A local or sublocal simple variable: PROC p; BEGIN INT i; i := i + 1; END; ◦ ! Declare a local simple variable ! Condition code accessible The address cell of a local pointer: INT i; INT .
! not accessible ! Index: condition code is not accessible ! Bit Selection: condition code is ! not accessible a[9] := i; i.<3:5> := a; Example 195 Assignments After Which You Can Test Condition Codes INT m; PROC p(x, y); INT x; INT .y; BEGIN INT a[0:9]; INT i; INT .EXT k; INT(32) j; STRING str; REAL r; EXTADDR SUBPROC f(x) RETURNSCC; INT x; BEGIN RETURN %200000D, x; END; STRUCT s; BEGIN INT s1[0:4]; INT s2; END; i := k; i := i + 1; x := x + 1; @k := f(0); y := i + 1; a[i] := a[i+1]; s.s1[0] := i; s.
IF $OVERFLOW THEN ... IF $CARRY THEN ... IF < THEN ... • WHILE (page 232) Both the statement preceding the WHILE statement and the last statement in the WHILE statement must set the condition code indicator. See Example 197 (page 240). Example 196 Hardware Indicators in DO-UNTIL Statements proc p returnscc; begin ... end; proc q; begin ... end; do call p () until = ; ! Sets condition code indicator ! OK do begin ... call p (); end until = ; ! OK do begin ... call q (); end until > ; int i := 0; ...
call p (); ! Sets condition code indicator while > do begin ... call p (); end; ! OK call q (); while > do begin ... call p (); end; ! Doesn't set the condition code indicator ! ERROR: statement preceding WHILE ! and last statement of WHILE ! must both set condition code indicator ! Sets condition code indicator call p (); while >= do begin ...
a := a + 1; END; IF $CARRY THEN ... ! ERROR: intervening END is invalid CALL WRITEREAD(...); firstchar := str_buff; IF <= THEN... ! ERROR: intervening assignment ! statement is invalid CALL WRITEREAD(...); IF < THEN ... ! ERROR: previous statement does not ! set condition code • Be part of a nest of IF statements as described in Nesting Condition Code Tests (page 242) The hardware indicator in the conditional expression of an IF statement must be the first operand in the expression. IF $CARRY THEN ...
The following rules apply to nested IF statements: • Neither $OVERFLOW nor $CARRY can appear in the conditional expression of any IF statement in a nest of IF statements. I := i + 1; IF > THEN IF $OVERFLOW THEN ... ! ERROR: cannot test $OVERFLOW in ! nest of IF statements i := i + 1; IF $CARRY THEN IF > THEN ...
WADDR w1, w2; EXTADDR e1, e2; IF e1 <> e2 THEN BEGIN IF < THEN ... END; IF w1 '<>' w2 THEN BEGIN IF < THEN ... END; IF w1 <> w2 THEN BEGIN IF < THEN ...
For more information: Topic Source Procedure declarations Procedure Declarations (page 246) Subprocedure declarations Subprocedure Declarations (page 257) RETURNSCC procedure attribute Procedure Attributes (page 248) RETURN statement RETURN (page 223) Returning the Value of $OVERFLOW or $CARRY to the Calling Procedure A called procedure cannot return the value of $OVERFLOW or $CARRY to its caller.
14 Procedures, Subprocedures, and Procedure Pointers Procedures are program units that contain the executable portions of a pTAL program and that are callable from anywhere in the program. Procedures allow you to segment a program into discrete parts that each perform a particular task such as I/O or error handling. An executable program contains at least one procedure. One procedure in the program has the attribute MAIN, which identifies it as the first procedure to execute when you run the program.
public-name-spec If a procedure declaration includes public-name-spec, it must also include EXTERNAL. If a procedure declaration includes LANGUAGE, it must also include public-name-spec. 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.
Example 200 Procedure Declaration INT var; WADDR PROC p(i), RETURNSCC,; INT .i; BEGIN RETURN @var, i+1; END; ! var is a global INT ! Attributes: empty, RETURNSCC, ! and empty ! Return address and ! condition code value Example 200 (page 248) illustrates the following procedure declarations: • p specifies three attributes, the first and third of which are empty.
CALL that_proc; END; PROC main_proc2 MAIN; BEGIN CALL some_proc; END; ! This MAIN procedure is not MAIN ! in the object file 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; NOTE: The EpTAL compiler ignores INTERRUPT.
! 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.
Memory is allocated for all parameters to VARIABLE procedures or EXTENSIBLE procedures; therefore, your program can store default values for parameters the caller does not pass. VARIABLE, EXTENSIBLE and RETURNSCC Procedures as Actual Parameters You can pass a procedure or procedure pointer that includes an EXTENSIBLE, VARIABLE, or RETURNSCC attribute as a parameter to a procedure whose formal parameter is a PROC, but you cannot reference the PROC formal parameter identifier in a CALL statement.
Descriptions for STRUCT, PROC, PROC(32), and type, are included below. You can find descriptions of the remaining data types in Chapter 3 (page 46). 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.
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 UNSIGNED parameters must be passed by value; you cannot use an indirection symbol (see Table 14 (page 41)) with UNSIGNED parameters. fpoint is an integer in the range -19 through 19 that specifies the implied decimal point position.
Table 57 Formal Parameter Specification Formal Parameter Characteristics Expected Actual Parameter Declare Formal Parameter As: Parameter Type Indirection Symbol Referral Simple variable A value or reference parameter STRING* INT INT(32) REAL REAL(64) FIXED(n) FIXED(*) Value, no; reference, yes No Simple variable A value parameter UNSIGNED No No Array or simple pointer A reference parameter STRING INT INT(32) REAL REAL(64) FIXED(n) Yes No Definition structure, referral structure, or struc
Example 202 Function With Value and Reference Formal Parameters PROC mult (var1, var2); INT var1, .var2; BEGIN var2 := var2 + var1; END; ! Value parameter ! Reference parameter ! Manipulate parameters Example 203 Reference Structure as a Formal Reference Parameter STRUCT template (*); ! Template structure BEGIN INT a; INT b; END; PROC .
Example 205 Converting the extended address of I to a WADDR address INT .EXT ea; INT .EXT32 e32a; INT .EXT64 e64a; PROC p(a); INT .a; BEGIN ... END; ... p(ea); ! OKAY p(e32a); ! OKAY p(e64a); ! ERROR: EXT64ADDR not assignment compatible with WADDR NOTE: The “Indirection Symbols” (page 41), .EXT32 and .EXT64 are 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
• simple pointer • structure pointer • equivalenced variable • LITERAL • DEFINE • label • entry point • FORWARD subprocedure subproc-decl is a subprocedure declaration, as described in Subprocedure Declarations (page 257). statement is any statement described in Chapter 12 (page 199). Example 206 Procedures INT c; PROC first; BEGIN INT a, b; ... END; PROC second; BEGIN ... CALL first; ...
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 Chapter 3 (page 46). identifier is the identifier of the subprocedure. parameter-list 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.
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 (page 251). subproc-body is a BEGIN-END block that contains sublocal declarations and statements—see Subprocedure Body (page 259). FORWARD means the subprocedure body is declared later in this procedure.
Sublocal Variable Example Direct array INT array[0:5]; Read-only array INT ro_array = 'P' := [0,1,2,3,4,5]; Example 208 Function Subprocedure PROC p; BEGIN SUBPROC p1; BEGIN INT .a[0:9]; INT .ext b[0:9]; a[0] := 1; b[9] := 2; END; CALL p1; END; PROC q; BEGIN SUBPROC q1; BEGIN STRUCT .s; BEGIN INT i; INT j; END; END; END; Entry-Point Declarations The entry-point declaration associates an identifier with a secondary location in a procedure or subprocedure where execution can start.
• You cannot use a GOTO statement to branch to a procedure entry-point identifier. • To obtain the address of a procedure entry-point identifier, preface the identifier with @. • You can specify FORWARD or EXTERNAL procedure entry-point declarations, which look like FORWARD procedure declarations and EXTERNAL procedure declarations. Example 209 Procedure Entry-Point Identifiers INT to_this := 314; ! PROC add_3 (g2); INT .
Subprocedure Entry-Point Identifiers Here are guidelines for using subprocedure entry-point identifiers: • Declare all entry-point identifiers for a subprocedure within the subprocedure. • Place each entry-point identifier and a colon (:) at a point in the subprocedure at which execution is to start. • You call a subprocedure entry-point identifier from anywhere in the encompassing procedure, including from within the same subprocedure.
Example 211 Subprocedure Entry-Point Identifiers literal write_op, read_op, writeread_op, readwrite_op; int proc io (op, buf); int op; int .ext buf; begin int subproc do_read_op (buf); int .ext buf; forward; int subproc do_write_op (buf); int .ext buf; forward; int subproc do_writeread_op (buf); int .ext buf; begin entry do_read_op; call do_write_op (buf); do_read_op: ! Perform read operation end; int subproc do_readwrite_op (buf); int .
procptr-size specifies the size of the procedure pointer and can be any one of: • PROCPTR • PROC32PTR • PROC64PTR PROCPTR and PROC32PTR are 32-bits in length and PROC64PTR is 64-bits in length.
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 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.
procptr is a procedure pointer identifier. param-type is any data type described in the data-type parameter of this syntax description. Indirection ., .EXT, .EXT32, .EXT64, .SG, and .SGX are indirection symbols (see Table 14 (page 41)). NOTE: The “Indirection Symbols” (page 41), .EXT32 and .EXT64 are 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
The object data type of a reference to a function procedure pointer is the data type returned by the procedure pointer. You can equivalence a procedure pointer (PROCPTR, PROC32PTR, or PROC64PTR) to any previously declared variable, if the width of the previous variable is greater than or equal to the width of the procedure pointer. You can assign and pass procedure pointers of smaller or equal size to other procedure pointers, provided that the parameters and attributes match.
Example 213 Procedure Pointers in a Structure STRUCT s1 [0:9]; BEGIN REAL PROCPTR f(x); REAL x; END PROCPTR; PROC32PTR g; END PROCPTR; PROC64PTR h (x, y, z) EXTENSIBLE; INT x, y, z; END PROCPTR; END; Example 214 (page 268) declares a template structure s2 with three components. When s2 is the referent of a referral structure, pTAL allocates space for procedure pointer f. pTAL does not allocate space for procedure pointers g or h because they redefine procedure pointer f.
Example 216 Procedure Pointers as Formal Parameters PROC a(i); INT i; EXTERNAL; PROC b(p); PROCPTR p(a); INT a; END PROCPTR; EXTERNAL; PROC c(p); PROC64PTR p(a); INT a; END PROCPTR; EXTERNAL; PROC d(pa); PROCADDR pa; BEGIN END; PROC e(pa); PROC32ADDR pa; BEGIN END; PROC f; BEGIN CALL b(a); CALL b(@a); CALL c(a); CALL c(@a); CALL d(a); CALL d(@a); CALL e(a); CALL e(@a); END; ! ! ! ! ! ! ! ! OK ERROR: OK ERROR: ERROR: OK ERROR: OK @ character is not valid @ character is not valid @ character is required @
Example 217 Assignments to procedure pointers, First Example PROCPTR pp1 (a, b) RETURNSCC; INT a, b; END PROCPTR; PROCPTR pp2 (a) RETURNSCC; INT a; END PROCPTR; PROCPTR pp3 (a, b); INT a, b; END PROCPTR; PROC p(i, j) RETURNSCC; INT i, j; BEGIN RETURN ,j; END; PROCADDR paddr; paddr := @p; ! OK: PROCADDR variable is assigned PROC addr @pp1 := @p; ! OK: Left side is PROCPTR, right side is PROC @pp1 := @pp2; ! ERROR: pp1 has two parameters, pp2 has one @pp1 := @pp3; ! ERROR: pp1 specifies RETURNSCC, pp3 does no
Example 219 Assignments to Procedure Pointers, Third Example PROCPTR pp; END PROCPTR; PROC32PTR p32p; END PROCPTR; PROC64PTR p64p; END PROCPTR; PROCADDR pa; PROC32ADDR p32a; PROC64ADDR p64a; @pp := @pp; @pp := pa @pp := @p32p; @pp := p32a; @pp := @p64p; @pp := p64a; @p32p := @p32p; @p32p := p32a; @p32p := @pp; @p32p := pa; @p32p := @p64p; @p32p := p64a; @p64p := @p64p; @p64p := p64a; @p64p := @pp; @p64p := pa; @p64p := @p32p; @p64p := p32a; pa := @pp; pa := pa; pa := @p32p; pa := p32a; pa := @p64p; pa := p6
Example 220 Dynamically Selected Procedure Call LITERAL dev_6530, dev_3270, dev_dove; INT device_type; INT param1, param2; PROC device_6530(i, j); INT i, j; EXTERNAL; PROC device_3270(i, j); INT i, j; EXTERNAL; PROC device_dove(i, j); INT i, j; EXTERNAL; PROCPTR p(i, j); INT i, j; END PROCPTR; CASE device_type of BEGIN dev_6530 -> @p := @device_6530; dev_3270 -> @p := @device_3270; dev_dove -> @p := @device_dove; END; CALL p(param1, param2); Although you cannot create an array of procedure pointers, you ca
Labels in Procedures A label is the target location of a GOTO statement. identifier is as described in Identifiers (page 42). 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.
15 Built-In Routines Topics: • Privileged Mode (page 274) • Parameters (page 275) • Hardware Indicators (page 276) • Atomic Operations (page 276) • Nonatomic Operations (page 281) 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.
Parameters Parameters of built-in routines are always passed by value. Topics: • Addresses as Parameters (page 275) • Expressions as Parameters (page 275) 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 223 (page 275), the built-in routine $BUI<_IN_1 has one formal parameter whose data type is BADDR.
• 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.
Sets condition code Yes (according the final value of var ) Sets $CARRY Yes, if traps are disabled Sets $OVERFLOW Yes, if traps are disabled; otherwise, traps on overflow var input,output sINT:variable is the variable that $ATOMIC_ADD increments. value input sINT:value is the value $ATOMIC_ADD adds to var. $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.
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.
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.
Example 228 $ATOMIC_GET Routine INT var1; INT var2; var1 := $ATOMIC_GET(var2); if < then ... ! OK: $ATOMIC_GET sets condition code $ATOMIC_OR $ATOMIC_OR performs an atomic LOR on two INT values. Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No var input,output INT:variable is the variable to which $ATOMIC_OR applies mask. mask input INT:value is a 16-bit mask that $ATOMIC_OR applies to var.
Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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.
The EpTAL compiler supports no pTAL privileged routines except $TRIGGER.
Table 60 Built-In Type-Conversion Routines (continued) Routine Converts ...
Table 61 Built-In Address-Conversion Routines (continued) Routine Converts ... To ...
Minimum and Maximum Routines Minimum routines return the minimum of two arguments. Maximum routines return the maximum of two arguments. Table 63 Built-In Minimum and Maximum Routines Arguments are of the type ...
Table 67 Built-In Variable-Characteristic Routines (continued) Routine Returns an INT value that is the ...
Table 70 Built-In Routines for Nonatomic Operations (continued) Routine Description Can Set ...
Table 70 Built-In Routines for Nonatomic Operations (continued) Routine Description Can Set ...
Table 70 Built-In Routines for Nonatomic Operations (continued) Routine Description Can Set ... Converts a REAL or REAL(64) value to a rounded INT value $IS_32BIT_ADDR 4 Returns INT typed value -1 if the specified address can be represented by 32-bits and 0 otherwise.
Table 70 Built-In Routines for Nonatomic Operations (continued) Routine Description Can Set ...
Table 70 Built-In Routines for Nonatomic Operations (continued) Routine Description Can Set ... $WADDR_TO_EXTADDR Converts a WADDR address to an EXTADDR address $WRITEPTE1, 2, 3 Writes a segment-page table entry $XADR Returns the address of the specified variable or struct as type EXTADDR.6 $XADR324 Returns the address of the specified variable or struct as type EXT32ADDR4.6 $XADR644 Returns the address of the specified variable or struct as type EXT64ADDR4.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No int-expression is an INT expression. $ALPHA inspects bits <8:15> of int-expression and ignores bits <0:7>.
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.
pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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. Example 234 $AXADR Routine PROC myproc PRIV; BEGIN STRING .
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is a BADDR address. The result of $BADDR_TO_WADDR is undefined if the least significant bit of expression is 1. The least significant bit of an address is not truncated when a byte address is converted to a word address—the address is not rounded down to the preceding even-byte address.
Example 237 $BITLENGTH Routine INT s_len; STRUCT .s[0:3]; BEGIN UNSIGNED(1) flags[0:15]; UNSIGNED(2) status; BIT_FILLER 14; END; s_len := $BITLENGTH (s); ! Declare four occurrences of a ! structure ! Return 32, the number of bits ! in one structure occurrence $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.
Example 238 $BITOFFSET Routine STRUCT a; BEGIN INT array[0:40]; STRUCT ab[0:9]; BEGIN UNSIGNED(1) flag; UNSIGNED(15) offset; END; END; INT c; c := $BITOFFSET (a.ab[2]); ! Return offset of 3rd occurrence ! of ab $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.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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.
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.
Example 243 $DBL Routine INT .EXT i; EXTADDR e; INT(32) j; j := $DBL(e); j := $DBL(@i); j := $DBL(i); j := $DBL(@j); j := $DBL(@e); ! ! ! ! ! OK: e is type EXTADDR OK: @i is type EXTADDR OK: i is type INT ERROR: @j is type WADDR ERROR: @e is type WADDR $DBLL $DBLL converts to INT values an INT(32) value. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No int-expression is an INT expression.
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 Chapter 13 (page 234)); otherwise, $DBLR ignores the problem. Example 245 $DBLR Routine REAL r2 := 1.5e0; INT(32) b32; REAL realnum := 123.456E0; INT(32) dblnum; b32 := $DBLR (r2); dblnum := $DBLR (realnum); ! Return 2d ! Return 123D $DFIX $DFIX converts an INT(32) value to a FIXED(fpoint ) value.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an 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. Example 247 $EFLT Routine REAL(64) dbrlnum; FIXED(3) fixnum := 12345.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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.
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.
Example 250 $EXTADDR_TO_BADDR Routine PROC p(x); STRING .EXT x; BEGIN STRING .j; @j := $EXTADDR_TO_BADDR(@x); @j := $EXTADDR_TO_BADDR(x); END; ! ERROR: x is STRING, ! not EXTADDR $EXTADDR_TO_WADDR $EXTADDR_TO_WADDR converts an EXTADDR address to an WADDR address. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an EXTADDR address.
expression is an expression whose value is an EXT64ADDR address. $EXT64ADDR_TO_EXT32ADDR NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). $EXT64ADDR_TO_EXT32ADDR converts an EXT64ADDR address to an EXT32ADDR address. No check is performed to see if the resulting EXT32ADDR address is valid.
$EXTADDR_TO_EXT64ADDR NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). $EXTADDR_TO_EXT64ADDR converts an EXTADDR address to an EXT64ADDR address. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an EXTADDR or EXT32ADDR address.
$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.
Sets $CARRY No Sets $OVERFLOW Yes 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 Chapter 13 (page 234)); otherwise, $FIXD ignores the problem.
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.
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.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW Yes 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 Chapter 13 (page 234)); otherwise, $FIXL ignores the problem.
Example 259 $FIXR Routine FIXED rfixnum; REAL(64) bigrealnum := -1.5L0; FIXED rndfnum; REAL realnum := 123.456E0; rfixnum := $FIXR (bigrealnum); rndfnum := $FIXR (realnum); ! Return -1F ! Return 123F $FLT $FLT converts its argument to a REAL value.
Example 261 $FLTR Routine REAL rrlnum; INT(32) dblnum := 147D; rrlnum := $FLTR (dblnum); ! Return rounded REAL value $FREEZE NOTE: • The EpTAL compiler does not support this procedure. Use $TRIGGER (page 345) instead. (The EpTAL compiler does allow $FREEZE as a DEFINE name.) • Execution does not return from this call. $FREEZE halts the processor in which its process is running and any other processors on the same node that have FREEZE enabled.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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. Example 262 $HIGH Routine INT a;INT(32) INT .
Example 263 $IFIX Routine FIXED(2) fixnum; INT intnum := 12345; fixnum := $IFIX (intnum, 2); ! Return 123.45 $INT $INT converts its argument to an INT value. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an INT, INT(32), UNSIGNED(1-16), UNSIGNED(17-31), FIXED, REAL, REAL(64), SGBADDR, SGWADDR, SGXBADDR, SGXWADDR, or EXTADDR value.
Example 265 $INT Routine PROC p; BEGIN INT .SG a; SGXBADDR b; INT i; INT .EXT e; i := $INT(a); i := $INT(@a); i := $INT(b); i := $INT(i); i := $INT(@b); i := $INT(@i); i := $INT(@e); END; ! ! ! ! ! ! ! OK: a is INT OK: @a is SGWADDR OK: b is SGXBADDR OK: i is INT ERROR: @b is WADDR ERROR: @i is WADDR OK: @e is EXTADDR $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.
$INTERROGATEHIO stores cause and status information from a high-priority I/O interrupt, which the operating system uses to reset the interrupt pTAL privileged procedure No Can be executed only by privileged procedures Yes Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No 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.
Example 267 $INTERROGATEHIO Routine INT select; INT rank_channel; INT ric_interrupt_status; INT rist_interrupt_cause; INT channel_status; $INTERROGATEHIO(select, rank_channel, ric_interrupt_status, rist_interrupt_status, channel_status); $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.
sINT:variable is an integer variable that holds the status returned by the controller.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is any of the address types, except SGWADDR and SGBADDR which are 16-bits in length. $LEN $LEN returns an INT value that is the length, in bytes, of a variable.
Example 270 $LEN Routine INT b; INT a [0:11]; b := $LEN (a); ! Return 2 Example 271 $LEN Routine INT s_len; STRUCT .s[0:99]; BEGIN INT(32) array[0:2]; END; s_len := $LEN (s); ! Return 12 Example 272 $LEN Routine INT array_length; INT(32) array[0:2]; array_length := $LEN (array) * $OCCURS (array); ! Return 12, the length of the entire array in bytes $LFIX $LFIX converts an unsigned INT value to a FIXED(fpoint ) value.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No int-expression is an unsigned INT expression. Example 274 $LMAX Routine INT intval := 3; max := $LMAX (intval, 5); ! Return 5 $LMIN $LMIN returns the minimum of two unsigned INT values.
pTAL privileged procedure No Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY Yes Sets $OVERFLOW No 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.
Sets condition code Yes Sets $CARRY Yes Sets $OVERFLOW No 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.
Example 278 $MAX Routine REAL realval := -3E0; max := $MAX (realval, 5E0); ! Return 5E0 $MIN $MIN returns the minimum of two signed values. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an INT, INT(32), FIXED(fpoint ), REAL, or REAL(64) expression. Both expressions must be of the same data type.
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.
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.
Example 282 $NUMERIC Routine STRING char; IF $NUMERIC (char) THEN ... ; ! Test for numeric character $OCCURS $OCCURS returns an INT value that is the number of elements in an array. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No variable is the name of a variable, array, structure, or structure field. variable cannot be the name of a structure template.
Table 72 $OCCURS for Structure Arrays and Arrays Within Structures (continued) $OCCURS Argument Entire structure Example $OCCURS Returns $OCCURS (a[7].t[3].i); $OCCURS (a[7].t[3].i[v]); 5 1 STRUCT s; BEGIN INT f; END; or nonarray field of a structure or substructure $OCCURS (s); $OCCURS (s.f); Structure template 1 1 STRUCT s; BEGIN INT f[0:9]; END; Compile-time err $OCCURS (s); $OCCURS (s.f); $OCCURS (s.f[5]); 10 1 Example 283 $OCCURS Routine With Nonstructure Arrays PROC p(x, y); INT x, .
Example 285 $OCCURS Routine With Template Structure Arrays INT i; STRUCT s(*); BEGIN INT f[0:9]; END; i := $OCCURS(s); i := $OCCURS(s.f); i := $OCCURS(s.f[5]); ! ERROR: Template structure not OK ! OK: f is an array ! WARNING: $OCCURS returns 1 $OFFSET $OFFSET returns an INT value that is the offset, in bytes, of a structure item from the beginning of the structure.
INT i; INT(32) d; STRING s; END; STRUCT .st; BEGIN INT i; INT j; INT .st_ptr(tt); ! Declare structure pointer END; ! that points to structure tt INT x; x := $OFFSET (st.j); ! x gets 2 x := $OFFSET (tt.s); ! x gets 6 x := $OFFSET (st.st_ptr.s); ! x gets 6 Example 288 $OFFSET Routine Applied to a Template Structure INT x; STRUCT st[-1:1]; BEGIN INT item; FIXED(2) price; END; x := $OFFSET (st[-1].
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 (j > 2, j) ); ! Pass j if j > 2 END; You can use $OPTIONAL when one procedure provides a front-end interface for another procedure that does the actual work, as Example 292 (page 335) shows. Example 292 $OPTIONAL Routine for a Front-End Interface PROC p1 (i, j) EXTENSIBLE; INT .i; INT .j; BEGIN ! Lots of code END; PROC p2 (p, q) EXTENSIBLE; INT .p; INT .
• $INT of a FIXED, REAL, or REAL(64) value • $INT of a FIXED, REAL, or REAL(64) value • $INTR of a FIXED, REAL, or REAL(64) value • $SCALE, for which: 1 <= exponent <= 4 Example 293 $OVERFLOW Routine I := i + 1; IF $OVERFLOW THEN ... For more information about overflow, see Chapter 13 (page 234). $PARAM $PARAM checks for the presence or absence of an actual parameter in the call that called the current procedure or subprocedure.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No 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.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is an INT(32), PROCADDR, PROC32ADDR, or PROC64ADDR address. $PROC64ADDR NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
Sets $CARRY No Sets $OVERFLOW No 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. Example 296 $READBASELIMIT Routine INT(32) xbase; INT(32) xlimit; $READBASELIMIT(xbase, xlimit); $READCLOCK $READCLOCK returns the current setting of the system clock as a FIXED value.
Sets $CARRY Yes Sets $OVERFLOW No 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. Example 298 $READSPT Routine EXTADDR virtual_addr; INT .EXT spt_entry(spt_template) := spt_entry_addr; $READSPT(virtual_addr, @spt_entry); $READTIME $READTIME returns the number of microseconds since the last cold load.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW Yes 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.
expression is an expression whose value is an SGBADDR or SGXBADDR address. $SGBADDR_TO_EXTADDR returns expression converted to an EXTADDR address. Example 302 $SGBADDR_TO_EXTADDR Routine STRING .SG s; INT .EXT i; INT j; @i := $SGBADDR_TO_EXTADDR(@s[j]); !??: OK if @s[j] is at an ! even-byte offset; ! otherwise, @i is undefined. $SGBADDR_TO_SGWADDR $SGBADDR_TO_SGWADDR converts an SGBADDR or SGXBADDR address to an SGWADDR address.
Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is n SGWADDR or SGXWADDR address. $SGWADDR_TO_EXTADDR returns expression converted to an EXTADDR address. Example 304 $SGWADDR_TO_EXTADDR Routine STRING .EXT s; INT .SG i; @s := $SGWADDR_TO_EXTADDR(@i); $SGWADDR_TO_SGBADDR $SGWADDR_TO_SGBADDR converts an SGWADDR or SGXWADDR address to an SGBADDR address.
Sets $CARRY No Sets $OVERFLOW No 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 (page 275)).
$STACK_ALLOCATE does not clear the allocated data area. $STACK_ALLOCATE does not return error conditions, but stack overflow can occur within $STACK_ALLOCATE or on a subsequent procedure call from within the procedure that calls $STACK_ALLOCATE. When a procedure or routine returns to its caller, the system deallocates all memory allocated by $STACK_ALLOCATE within that procedure. pTAL does not support calls to $STACK_ALLOCATE from subprocedures and reports a syntax error if it encounters one.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No variable is the identifier of a simple variable, array, simple pointer, structure, structure data item, or structure pointer.
$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. Example 310 $UDBL Routine INT a16 := -1;s INT(32) a32; a32 := $UDBL (a16); ! Return 65535D $UDIVREM16 $UDIVREM16 divides an INT(32) dividend by an INT divisor to produce an INT quotient and INT remainder.
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); IF $OVERFLOW THEN....
$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); IF $OVERFLOW THEN....
Sets $CARRY No Sets $OVERFLOW No . 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. Example 313 $UNLOCKPAGE Routine INT unlockcount; EXTADDR addr; $UNLOCKPAGE(unlockcount, addr); $WADDR_TO_BADDR $WADDR_TO_BADDR converts a WADDR address to a BADDR address.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No expression is an expression whose value is a WADDR address. Example 315 $WADDR_TO_EXTADDR Routine STRING .EXT s; INT t; @s := $WADDR_TO_EXTADDR(@t); ! @t is a WADDR address $WRITEPTE NOTE: The EpTAL compiler does not support this procedure. $WRITEPTE writes a segment-page-table entry.
Example 316 $WRITEPTE Routine INT ptetag; INT(32) pageframe; EXTADDR abs; $WRITEPTE(ptetag, pageframe, abs); $XADR $XADR converts a standard address to an EXTADDR address. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No variable is a variable that has a standard, extended, or system-global address. $XADR returns an EXTADDR address. If the argument to $XADR is not a variable, the compiler reports an error.
pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No variable is a variable that has a standard, extended, or system-global address. $XADR returns an EXT32ADDR address. The compiler reports an error if there is no explicit conversion defined from the address type of the variable to EXT32ADDR or EXTADDR.
$XADR64 returns an EXT64ADDR address. The compiler reports an error if there is no explicit conversion defined from the address type of the variable to EXT64ADDR. $XADR64 returns an absolute extended EXT64ADDR address in absolute segment 1 if variable is an extended system global address (an SGBADDR, SGWADDR, SGXBADDR, or SGXWADDR). Variable can be the name of a pointer preceded by an “@” operator. In this case, $XADR64 returns the EXT64ADDR address of the pointer.
16 Compiling and Linking pTAL Programs Input to the compiler is a source file containing pTAL source text (such as data declarations, statements, compiler directives, and comments). Output from the compiler is a linkfile consisting of relocatable code and data blocks. To produce an executable pTAL program, link one or more linkfiles into a single loadfile (see Figure 13).
Example 320 Compiler Command Lines ptal / in test, out $s.#test, nowait/ testobj; symbols eptal / in test, out $s.#test, nowait/ testobj; symbols The compiler reads input only from a single edit-format disk file. You can use the SOURCE (page 514) 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.
Difference between pTAL and EpTAL compilers: pTAL Compiler EpTAL Compiler On Guardian platforms, object files have the file code 700 On Guardian platforms, object files have the file code 800 Running the Compiler To run the compiler on Guardian platforms, issue a compilation command at the HP TACL prompt.
By default, the compiler and its processes can run at a high PIN. If your compilation accesses files on systems running C-series software, you must run the compiler at a low PIN. To run the compiler at a low PIN, set HIGHPIN OFF, as shown in the following HP TACL command: SET HIGHPIN OFF When you set HIGHPIN OFF in the HP TACL program, the program runs all processes at a low PIN except processes that explicitly specify the HIGHPIN ON option when the process is created.
The compiler and compiler directives you use determine the linker you must use and the kind of executable object code that is produced: Compiler Compiler Directive Linker Object Code EpTAL CALL_SHARED (default) eld PIC CALL_SHARED ld PIC NOCALL_SHARED (default) nld Non-PIC NOCALL_SHARED (error) pTAL The linker can also strip nonessential information from an object file and modify the object file’s process attributes (such as HIGHPIN).
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 13 (page 355).) Figure 15 Creating Loadfiles on TNS/R for TNS/R The source code can be in one or more files. From each source code file, the compiler generates a single nonexecutable object code file.
Figure 16 Creating a Loadfile on TNS for TNS/R 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 13 (page 355) illustrates this concept, but uses a linker instead of Binder.
Figure 17 Producing Hybrid Loadfiles AXCEL is available on TNS/E, TNS/R, and TNS processors. OCA is available on TNS/E and TNS/R processors. Non-PIC hybrid loadfiles run on the TNS/R architecture. PIC hybrid loadfiles run on the TNS/E architecture.
compilation unit. If you include a BLOCK declaration in a compilation unit, you must assign an identifier to the compilation unit by using a NAME declaration. Unblocked global data declarations are those appearing outside a BLOCK declaration. Such declarations are also relocatable and shareable among all compilation units in a program. If you do not use the BLOCKGLOBALS directive, then all separate compilations must specify exactly the same list of unblocked global data declarations.
Example 323 Data Block and Variable With the Same Name BLOCK c_var; INT c_var; END BLOCK; Declaring Private Data Blocks A private data block is a global data block that is shareable only among the procedures within a compilation unit. You can include only one private data block in a compilation unit. The private data block inherits the identifier you specify in the NAME declaration; therefore, the NAME declarations in all compilations that you use to assemble an executable program must have unique names.
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; INT .ptr := @var; ! Declare var ! Declare ptr by referring to var If the reference is not in the same block, the compiler issues an error message.
NAME input_file; ?SOURCE calcsrc(unblocked_globals) ?SOURCE calcsrc(default) 3. ! Specify implicit block ! Specify named block If you then change any declaration within a data block that has a section name, you must recompile all source files that include SOURCE directives listing the changed data block. Compiling With Saved Global Data NOTE: This topic applies only to the pTAL compiler. If you are using the EpTAL compiler, see Migrating from TNS/R to TNS/E (page 375).
17 Compiler Directives Topics: • Specifying Compiler Directives (page 367) • File Names as Compiler Directive Arguments (page 368) (Guardian platforms only) • Directive Stacks (page 369) • Toggles (page 370) • Saving and Using Global Data Declarations (page 372) • Summary of Compiler Directives (page 377) • Topics for individual compiler directives, beginning with ASSERTION (page 381) Specifying Compiler Directives You can specify compiler directives either in the compilation command or in a d
? indicates a directive line, and can appear only in column 1. directive is a directive listed in Table 74 (page 377) or Table 75 (page 379), except OPTIMIZEFILE, which can appear only in the command line (see Compilation Command (page 367)). Rules for directive lines: • Begin each directive line by specifying ? in column 1. (? is not part of the directive name.) • Place the name of the directive and its arguments on the same line unless the directive description says you can use continuation lines.
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 (page 384) • DEFEXPAND (page 386) • DO_TNS_SYNTAX (page 389) • GP_OK (page 397) • INNERLIST (page 400) • LIST (page 401) • MAP (page 402) • OVERFLOW_TRAPS (page 406) • REFALIGNED (page 410) Each directive stack is 31 levels deep.
Example 327 Pushing and Popping a Directive Stack ! LIST is the default setting for the source file ?PUSHLIST, NOLIST, SOURCE $SYSTEM.SYSTEM.EXTDECS ( ? PROCESS_GETINFO_, FILE_OPEN_, WRITEREADX, READX) ?POPLIST 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.
Examples • Example 328 (page 372) • Example 329 (page 372) • Example 330 (page 372) • Example 331 (page 372) • Example 332 (page 372) Toggles 371
Example 328 DEFINETOG, IF, and ENDIF Directives ?DEFINETOG scanner ... ?IF scanner PROC skipped; BEGIN ... END; ?ENDIF scanner ! Define toggle ! Test toggle for on state ! Find it off, skip procedure ! End of skipped procedure Example 329 DEFINETOG, IFNOT, and ENDIF Directives Directive ?DEFINETOG emitter ... ?IFNOT emitter PROC kept; BEGIN ...
Directive Description SAVEGLOBALS Saves global data declarations and initial values in one file USEGLOBALS Reads global data declarations and initial values saved in a file BEGINCOMPILATION Marks the point in the source file where compilation is to begin if the USEGLOBALS directive is active NOTE: • The EpTAL compiler does not accept the SAVEGLOBALS or USEGLOBALS directive. • The EpTAL compiler ignores the BEGINCOMPILATION directive.
Retrieving Global Data Declarations After a SAVEGLOBALS compilation completes successfully, you can specify the following directives in a USEGLOBALS compilation to retrieve the global data declarations and initializations: Directive in USEGLOBALS Compilation Effect in Same USEGLOBALS Compilation USEGLOBALS • Retrieves global data declarations • Suppresses compilation of text lines and SOURCE directives (but not other directives) until BEGINCOMPILATION appears BEGINCOMPILATION Begins compilation of text
Example 334 Saving Global Data Declarations and Data Initializations pTAL /IN myprog/ myobj; SAVEGLOBALS ptalsym A USEGLOBALS compilation (Example 335 (page 375)) 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.
?source FILEn int i1 struct s(*); begin ... end; ! All other common declarations and directives in the ! compilation ... ! End of global declarations ?BEGINCOMPILATION ! All nonglobal declarations, ! including procedure declarations ! End of COMP1 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 339 (page 376)).
Summary of Compiler Directives Table 74 summarizes directives by categories. Table 75 (page 379) lists directives by name in alphabetical order.
Table 74 Compiler Directives by Category (continued) Category Conditional compilation 378 Compiler Directives Directive Operation BASENAME Specifies that the raw data file (used for code profiling) generated by the executing process is to contain only the base part ot the file name.
Table 74 Compiler Directives by Category (continued) Category Directive Operation RESETTOG Turns toggles off SETTOG Turns toggles on TARGET3 Specifies the architecture on which the program will run Run-time environment SYMBOLS Generates a symbol table for a symbolic debugger Feature control __EXT64 Enables 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see “64-bit Addressing Functionality” (page 531).
Table 75 Compiler Directives by Name (continued) Directive Operation GMAP Lists the global map in the compiler listing 1 GP_OK Generates code that has GP-relative addressing IF and IFNOT Identifies the beginning of code that is to be conditionally compiled INNERLIST Lists mnemonics after each source statement INVALID_FOR_PTAL Causes errors for TAL constructs that are not valid in pTAL LINES Specifies the maximum number of output lines per page if the list file is a line printer or a process LI
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-level is an unsigned decimal constant in the range 0 through 32,767.
Dependencies: Use the BASENAME option only with the PROFGEN option References: PROFGEN BEGINCOMPILATION NOTE: The EpTAL compiler ignores this directive. See Migrating from TNS/R to TNS/E (page 375). BEGINCOMPILATION marks the point in the source file where: • The information saved by the SAVEGLOBALS operation ends • Compilation is to begin if the USEGLOBALS directive is active.
Table 76 Data Block Names Declaration Without BLOCKGLOBALS With BLOCKGLOBALS INT a; _GLOBAL A INT .a; _GLOBAL A INT .EXT a; _GLOBAL A INT a[0:9] _GLOBAL A STRUCT a; BEGIN INT i; END _GLOBAL A int .ext a [0:9] $_GLOBAL A struct .ext a; begin int i; end; $_GLOBAL A 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.
• If both CALL_SHARED and NOCALL_SHARED appear in the same compilation unit, the compiler uses the one that appears last Dependencies: • Do not use CALL_SHARED with GP_OK References: GP_OK (page 397) CHECKSHIFTCOUNT 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 (page 94).
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. See the caution under Debugging (page 429), which indicates how CODECOV affects debugging applications. CODECOV causes the compiler to generate instrumented object code for use by the Code Coverage Utility.
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.
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 (page 401) • SUPPRESS (page 420) 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.
DEFINETOG DEFINETOG specifies toggles for use in conditional compilation. If DEFINETOG is specifying a toggle for the first time, its setting is off. DEFINETOG has no effect on toggles already in use. toggle-name is an identifier with a maximum of 31 characters in length. The only characters allowed in a toggle-name are alphabetic (“A” through “Z” and “a” through “z’), numeric (‘0” through “9”), underscore (“_”), and circumflex (“^”); the first character must be alphabetic.
The __EXT64 directive controls the availability of 64-bit addressing functionality; for more details, see Appendix E “64-bit Addressing Functionality” (page 531). The toggle __EXT64 is used with the directives “IF and IFNOT” (page 398) to conditionally compile source code containing 64-bit addressing functionality. This toggle is not supported by the EpTAL compilers prior to SPR T0561H01^AAP nor is it supported by any pTAL or TAL compiler.
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 (page 423) ENDIF ENDIF identifies the end of code that is to be conditionally compiled.
-- compiled because tog1 is on ?IF tog2 -- Statements for true condition -- skipped because tog2 is off ?ENDIF tog1 – Not compiled, part of skipped code for tog2 ?ENDIF tog2 -- End of conditional code for tog2 ?ENDIF tog1 -- End of conditional code for tog1 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 t
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. NOTE: MAP DEFINEs are available only on Guardian platforms. assign-name is a logical file name you have equated with an error file by issuing an ASSIGN command.
Example 342 FIXERRS Macro [#DEF MYFIXERRS MACRO |BODY| FIXERRS %1%; SET , NEXTERR; SET , PREVERR ] Example 343 ERRORFILE Directive ! MYSOURCE file ?ERRORFILE myerrors ! Compiler reports errors and warnings ! to the file myerrors !Global declarations ERRORS ERRORS sets the maximum number of error messages to allow before the compiler terminates the compilation.
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.
EXT64ADDR addr; ?ENDIF __EXT64 ?IFNOT __EXT64 EXTADDR addr; ?ENDIF __EXT64 -- Use a 64-bit address type. -- EpTAL prior to SPR AAP, pTAL or TAL Default: off Placement: Must appear either on the compiler command line or in the compiled source code before the first source code token is scanned by the compiler.
NODEFAULT specifies that every structure declaration must include a FIELDALIGN (page 395). 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 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.
Default: Generate non-preemptable object code Placement: On the command line Scope: Applies to the compilation unit Dependencies: None GMAP 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.
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 (page 369).
Names are case-insensitive (For example, abc is the same as Abc.) toggle-number is an unsigned decimal constant in the range 1 through 15. Leading zeros are ignored. target is as defined in “TARGET” (page 516). PTAL is a toggle implicitly defined and set by the TAL, pTAL and EpTAL compilers. It is set on if the compiler in use is any pTAL or EpTAL compiler, otherwise it is set off. See “DEFINETOG” (page 388).
• SETTOG • TARGET References: • DEFINETOG (page 388) • ENDIF (page 390) • “__EXT64” (page 394) • RESETTOG (page 411) • SETTOG (page 415) • TARGET (page 423) • Toggles (page 370) An asterisk (*) appears in column 11 of the listing for any statements not compiled because of the IF or IFNOT directive. INNERLIST 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.
Example 348 INNERLIST and NOINNERLIST Directives PROC any; BEGIN INT x, y, z; ! No innerlisting here ! Statements that initialize variables ?INNERLIST ! Start innerlisting here ! Statements that manipulate variables ?NOINNERLIST ! Stop innerlisting here END; 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.
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. For an explanation of directive stacks, see Directive Stacks (page 369).
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 (page 369).
OPTIMIZE 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.
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.
OVERFLOW_TRAPS 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.
Example 351 OVERFLOW_TRAPS Compiler Directive ?OVERFLOW_TRAPS PROC p; BEGIN ?NOOVERFLOW_TRAPS ... END; ?NOOVERFLOW_TRAPS PROC q; BEGIN ... END; ! Correct ! Incorrect: OVERFLOW_TRAPS must appear ! between procedure declarations ! Correct NOTE: OVERFLOW_TRAPS directive does not control the effects of the $EXT64ADDR_TO_EXT32ADDR_OV directive (See directive“$EXT64ADDR_TO_EXT32ADDR_OV ” (page 307)). PAGE The first PAGE sets the string to be printed as part of the heading for each page.
Example 352 PAGE Directive ! MYSOURCE file ?PAGE "Here are global declarations for MYSOURCE" ! Global declarations ?PAGE "Here are procedure declarations for MYSOURCE" ! Procedure declarations PRINTSYM PRINTSYM lists symbols in the compiler listing. NOPRINTSYM suppresses symbols in the compiler listing.
Default: Default subvolume Placement: Only on the command line Scope: Applies to the compilation unit Dependencies: PROFDIR is ignored if PROFGEN or CODEDOV is not also specified References: • PROFGEN (page 409) • CODECOV (page 385) PROFGEN This directive can be used only with the EpTAL compiler. PROFGEN directs the compiler to generate instrumented object code for use in performing profile-guided optimization.
REFALIGNED 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 (page 369).
RESETTOG RESETTOG turns off either specified toggles or all numeric toggles. toggle-name is an identifier with a maximum of 31 characters in length. The only characters allowed in a toggle-name are alphabetic (“A” through “Z” and “a” through “z’), numeric (‘0” through “9”), underscore (“_”), and circumflex (“^”); the first character must be alphabetic. Names are case-insensitive (For example, abc is the same as Abc.) toggle-number is an unsigned decimal constant in the range 1 through 15.
RESETTOG with no arguments turns off all numeric toggles but does not affect named toggles.
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.
NOTE: MAP DEFINEs are available only on Guardian platforms.
Example 355 SECTION Directive APPLLIB File ! File ID APPLLIB ?SECTION sort_proc PROC sort_on_key(key1, key2, key3, length); INT .key1, .key2, .key3, length; BEGIN ... END; ?SECTION next_proc SOURCE directive that includes section sort_proc of the preceding file: ?SOURCE appllib (sort_proc) SETTOG SETTOG turns on either specified toggles or all numeric toggles. toggle-name is an identifier with a maximum of 31 characters in length.
PTAL is a toggle implicitly defined and set by the TAL, pTAL and EpTAL compilers. It is set on if the compiler in use is any pTAL or EpTAL compiler, otherwise it is set off. See “DEFINETOG” (page 388). The TAL compiler emits a warning if PTAL is specified and the SETTOG directive is ignored. In pTAL and EpTAL, an error is emitted if you specify PTAL in a SETTOG directive. __EXT64 is a toggle implicitly defined and set by the EpTAL compiler starting with SPR T0561H01^AAP.
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. NOTE: MAP DEFINEs are available only on Guardian platforms.
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.
USEGLOBALS and BEGINCOMPILATION (pTAL Compiler Only) If USEGLOBALS is active, the compiler ignores all SOURCE directives until it encounters BEGINCOMPILATION. For more information about how these directives interact, see Saving and Using Global Data Declarations (page 372). Including System Procedure Declarations You can use SOURCE directives to read in external declarations of system procedures from the EXTDECS files. In these files, the procedure name and the corresponding section name are the same.
Example 360 SOURCE Directive ?SOURCE $src.current.routines (sec1) ?SOURCE $src.current.routines (sec2) ?SOURCE $src.current.routines (sec3) 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.
Dependencies: Overrides all the listing directives (referenced in the next row) References: • DEFEXPAND (page 386) • FMAP (page 396) • GMAP (page 397) • INNERLIST (page 400) • LIST (page 401) • MAP (page 402) • PAGE (page 407) • PRINTSYM (page 408) The compilation command in Example 361 (page 421) starts the compilation and suppresses all source code listings and maps from printing in the compiler output. Example 361 SUPPRESS Directive PTAL /IN mysrc, OUT $s.
NOTE: These linker options discard information that SYMBOLS saves: • -x discards line number information. • -s discards information needed for future linking (use it only in building an executable file). 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.
Example 364 SYNTAX Directive pTAL /IN myprog/; USEGLOBALS ptalsym, SYNTAX TARGET TARGET specifies the architecture on which you will run the object file produced by the current compilation. 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.
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. NOTE: MAP DEFINEs are available only on Guardian platforms.
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.
18 pTAL Cross Compiler The optional pTAL cross compiler runs on the PC platforms in Table 77 (page 426). Table 77 pTAL Cross Compiler Platforms Platform Windows Operating System PC Guardian Cross Compiler Name NT 4.0 2000 XP ETK1 TNS/R NonStop pTAL Yes Yes Yes NonStop pTAL No Yes Yes ptal Yes Yes Yes eptal No Yes Yes 2 TNS/E 3 PC command line TNS/R TNS/E2 1 HP Enterprise Toolkit—NonStop Edition 2 H06.01 and later RVUs 3 G06.
NonStop pTAL components are: File Component Name TNS/R TNS/E Driver executable ptal.exe eptal.exe Driver DLL ptaldvr.dll (No driver) Front end ptalc.dll eptalcom.exe External declaration file extdec.tal eextdec.tal The directory structure of NonStop pTAL is: Files Directory TNS/R TNS/E bin ptal.exe nld.exe ld.exe eptal.exeeld.exe cmplr ptaldvr.dll ptalc.dll uopt.dll ugen.dll as1.dll nld.dll ld.dll eptalcom.exe include extdec.tal extdec.
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.
Directives Sources -[no]overflow_traps OVERFLOW_TRAPS (page 508) -[no]printsym PRINTSYM (page 509) -refaligned(n) REFALIGNED (page 510) -resettog(value) RESETTOG (page 511) -[no]round ROUND (page 512) -settog(value) SETTOG (page 513) -[no]symbols SYMBOLS (page 515) -[no]syntax SYNTAX (page 516) -warn=n WARN (page 517) The command-line interface allows you to create batch scripts for use on multiple platforms.
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 (page 431)).
TACL DEFINE Tool (ETK) On the ETK platform, this GUI-based tool allows you to add ADD, MODIFY, SET, and DELETE statements to a DEFINE file. The TACL DEFINE tool automatically sets the first entry in the DEFINE obey file to be SET DEFMODE ON. You can leave this default or change it to SET DEFMODE OFF. Files created by the TACL DEFINE tool have the extension .tdf. PC-to-NonStop-Host Transfer Tools ETK The Deploy command builds and copies each project in the active solution to the NonStop host.
A Syntax Summary • Data Types (page 432) • Constants (page 432) • Expressions (page 434) • Declarations (page 436) • Statements (page 455) • Overflow Traps (page 460) • Built-in Routines (page 460) • Compiler Directives (page 494) Data Types More information: Specifying Data Types (page 47) Constants • Character String (page 432) • STRING Numeric (page 432) • INT Numeric (page 433) • INT(32) Numeric (page 433) • FIXED Numeric (page 433) • REAL and REAL(64) Numeric (page 433) •
INT Numeric More information: INT Numeric (page 58) INT(32) Numeric More information: INT(32) Numeric (page 59) FIXED Numeric More information: FIXED Numeric (page 61) REAL and REAL(64) Numeric More information: REAL and REAL(64) Numeric (page 62) Constants 433
Constant List repetition-constant-list constant-list-seq More information: Constant Lists (page 63) Expressions • Arithmetic (page 434) • Conditional (page 435) • Assignment (page 435) • CASE (page 435) • IF (page 435) • Group Comparison (page 435) • Bit Extraction (page 436) • Bit Shift (page 436) Arithmetic More information: Arithmetic Expressions (page 72) 434 Syntax Summary
Conditional More information: Conditional Expressions (page 81) Assignment More information: Assignment (page 85) CASE More information: CASE (page 86) IF More information: IF (page 87) Group Comparison More information: Group Comparison (page 88) Expressions 435
Bit Extraction More information: Bit Extractions (page 93) Bit Shift More information: Bit Shifts (page 94) Declarations • LITERAL (page 436) • DEFINE (page 436) • Simple Variable (page 437) • Array (page 437) • Read-Only Array (page 438) • Structures (page 438) • Redefinition (page 442) • Pointer (page 444) • Equivalenced Variable (page 445) • Procedure and Subprocedure (page 449) LITERAL More information: Declaring Literals (page 97) DEFINE 436 Syntax Summary
item-list param-list More information: Declaring DEFINEs (page 98) Simple Variable More information: Declaring Simple Variables (page 103) Array range More information: Declaring Arrays (page 108) Declarations 437
Read-Only Array range More information: Declaring Read-Only Arrays (page 111) Structures • Definition Structure (page 438) • Template Structure (page 439) • Referral Structure (page 439) • Simple Variables Declared in Structure (page 440) • Arrays Declared in Structure (page 440) • Definition Substructure (page 440) • Referral Substructure (page 440) • Filler in Structure (page 441) • Simple Pointers Declared in Structure (page 441) • Structure Pointers Declared in Structure (page 441)
field-alignment More information: Declaring Definition Structures (page 138) Template Structure field-alignment More information: Declaring Template Structures (page 139) Referral Structure range More information: Declaring Referral Structures (page 141) Declarations 439
Simple Variables Declared in Structure More information: Declaring Simple Variables in Structures (page 142) Arrays Declared in Structure range More information: Declaring Arrays in Structures (page 143) Definition Substructure field-alignment range More information: Definition Substructures (page 144) Referral Substructure 440 Syntax Summary
range More information: Referral Substructures (page 146) Filler in Structure More information: Declaring Filler (page 147) Simple Pointers Declared in Structure More information: Declaring Simple Pointers in Structures (page 148) Structure Pointers Declared in Structure Declarations 441
More information: Declaring Structure Pointers in Structures (page 151) Redefinition • Simple Variable (page 442) • Array (page 442) • Definition Substructure (page 442) • Referral Substructure (page 443) • Simple Pointer (page 443) • Structure Pointer (page 444) Simple Variable More information: Simple Variable (page 153) Array range More information: Array (page 154) Definition Substructure range 442 Syntax Summary
field-alignment More information: Definition Substructure (page 155) Referral Substructure range More information: Referral Substructure (page 157) Simple Pointer More information: Simple Pointer (page 158) Declarations 443
Structure Pointer More information: Structure Pointer (page 159) Pointer • Simple (page 444) • Structure (page 445) • System Global (page 445) Simple More information: Declaring Simple Pointers (page 170) 444 Syntax Summary
Structure More information: Declaring Structure Pointers (page 173) System Global More information: Declaring System Global Pointers (page 176) Equivalenced Variable • Nonstructure (page 446) • Simple Variable (page 446) • Simple Pointer (page 447) • Definition Structure (page 447) • 'SG'-Equivalenced Simple Variable (page 448) • 'SG'-Equivalenced Definition Structure (page 448) • 'SG'-Equivalenced Referral Structure (page 448) • 'SG'-Equivalenced Simple Pointer (page 449) • 'SG'-Equiva
Nonstructure More information: Declaring Nonstructure Equivalenced Variables (page 180) Simple Variable More information: Equivalenced Simple Variables (page 182) 446 Syntax Summary
Simple Pointer More information: Equivalenced Simple Pointers (page 183) Definition Structure field-alignment More information: Declaring Equivalenced Definition Structures (page 188) Declarations 447
'SG'-Equivalenced Simple Variable More information: Equivalenced Simple Variables (page 182) 'SG'-Equivalenced Definition Structure More information: Equivalenced Definition Structure (page 194) 'SG'-Equivalenced Referral Structure More information: Equivalenced Referral Structure (page 195) 448 Syntax Summary
'SG'-Equivalenced Simple Pointer More information: Equivalenced Simple Pointer (page 196) 'SG'-Equivalenced Structure Pointer More information: Equivalenced Structure Pointer (page 197) Procedure and Subprocedure • Procedure (page 450) • Subprocedure (page 452) • Formal Parameters (page 453) • Entry Point (page 454) • Label (page 454) • Procedure Pointer (page 454) Declarations 449
Procedure type See Data Types (page 432).
proc-attribute 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. More information: Procedure Attributes (page 248) param-spec See Formal Parameters (page 453).
Subprocedure type See Data Types (page 432). parameter-list param-pair param-spec See Formal Parameters (page 453).
Formal Parameters param-type NOTE: The EpTAL compiler does not allow you to assign label or subprocedure addresses to CBADDR and CWADDR address types.
type More information: Formal Parameter Specification (page 251) Entry Point More information: Entry-Point Declarations (page 260) Label More information: Labels in Procedures (page 273) Procedure Pointer formal-param-names param-pair 454 Syntax Summary
attributes 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.
• Labeled CASE (page 457) • Unlabeled CASE (page 457) • DO-UNTIL (page 458) • DROP (page 458) • FOR (page 458) • GOTO (page 458) • IF (page 458) • Move (page 459) • RETURN (page 459) • SCAN and RSCAN (page 459) • USE (page 459) • WHILE (page 460) Compound More information: Compound Statements (page 200) ASSERT More information: ASSERT (page 200) Assignment The assignment statement assigns a value to a previously declared variable.
CALL param-pair More information: CALL (page 205) Labeled CASE case-alternative More information: Labeled CASE (page 207) Unlabeled CASE Statements 457
More information: Unlabeled CASE (page 209) DO-UNTIL More information: DO-UNTIL (page 210) DROP More information: DROP (page 212) FOR More information: FOR (page 212) GOTO NOTE: Nonlocal GOTO statements are are inefficient and not recommended.
Move More information: Move (page 218) 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.
WHILE More information: WHILE (page 232) Overflow Traps OVERFLOW_TRAPS Directive See OVERFLOW_TRAPS (page 508).
$ATOMIC_AND Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No More information: $ATOMIC_AND (page 277) $ATOMIC_DEP Sets condition code Yes (according the final value of var ) Sets $CARRY No Sets $OVERFLOW No More information: $ATOMIC_DEP (page 278) $ATOMIC_GET Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $ATOMIC_GET (page 279) $ATOMIC_OR Sets condition code Yes (according the final value of var ) Sets $CARRY
$ATOMIC_PUT Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $ATOMIC_PUT (page 280) Nonatomic • $ABS (page 464) • $ALPHA (page 464) • $ASCIITOFIXED (page 465) • $AXADR (page 465) • $BADDR_TO_EXTADDR (page 465) • $BADDR_TO_WADDR (page 466) • $BITLENGTH (page 466) • $BITOFFSET (page 466) • $CARRY (page 467) • $CHECKSUM (page 467) • $COMP (page 467) • $COUNTDUPS (page 468) • $DBL (page 468) • $DBLL (page 468) • $DBLR (page 469) • $DFIX (page 469)
• $FIXEDTOASCII (page 474) • $FIXEDTOASCIIRESIDUE (page 474) • $FIXI (page 475) • $FIXL (page 475) • $FIXR (page 475) • $FLT (page 475) • $FLTR (page 476) • $FREEZE (page 476) • $HALT (page 476) • $HIGH (page 477) • $IFIX (page 477) • $INT (page 477) • $INT_OV (page 478) • $INTERROGATEHIO (page 478) • $INTERROGATEIO (page 478) • $INTR (page 479) • $IS_32BIT_ADDR (page 479) • $LEN (page 480) • $LFIX (page 480) • $LMAX (page 480) • $LMIN (page 480) • $LOCATESPTHDR (p
• $SCALE (page 487) • $SGBADDR_TO_EXTADDR (page 487) • pTAL Privileged Routines (page 281) • $SGWADDR_TO_EXTADDR (page 488) • $SGWADDR_TO_SGBADDR (page 488) • $SPECIAL (page 489) • $STACK_ALLOCATE (page 489) • $TRIGGER (page 489) • $TYPE (page 490) • $UDBL (page 490) • $UDIVREM16 (page 490) • $UDIVREM32 (page 491) • $UNLOCKPAGE (page 491) • $WADDR_TO_BADDR (page 492) • $WADDR_TO_EXTADDR (page 492) • $WRITEPTE (page 492) • $XADR (page 493) • $XADR32 (page 493) • $XADR64 (
More information: $ALPHA (page 291) $ASCIITOFIXED pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code Yes Sets $CARRY No Sets $OVERFLOW Yes More information: $ASCIITOFIXED (page 292) $AXADR NOTE: The EpTAL compiler does not support this routine. (The EpTAL compiler does allow $AXADR as a DEFINE name.
$BADDR_TO_WADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $BADDR_TO_WADDR (page 294) $BITLENGTH pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $BITLENGTH (page 295) $BITOFFSET pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition
$CARRY pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $CARRY (page 297) $CHECKSUM pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $CHECKSUM (page 297) $COMP pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY N
$COUNTDUPS pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $COUNTDUPS (page 299) $DBL pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $DBL (page 300) $DBLL pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No
$DBLR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $DBLR (page 301) $DFIX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $DFIX (page 302) $EFLT pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $O
$EFLTR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $EFLTR (page 303) $EXCHANGE pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $EXCHANGE (page 303) $EXECUTEIO NOTE: The EpTAL compiler does not support this routine.
$EXTADDR_TO_BADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $EXTADDR_TO_BADDR (page 305) $EXTADDR_TO_WADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $EXTADDR_TO_WADDR (page 306) $EXT64ADDR_TO_EXTADDR pTAL privileged procedure No Can be executed only by privileged p
Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $EXT64ADDR_TO_EXT32ADDR (page 307) NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
$FILL8, $FILL16, and $FILL32 pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FILL8, $FILL16, and $FILL32 (page 308) $FIX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FIX (page 309) $FIXD pTAL privileged procedure No Can be executed only by privileged procedures No Sets
$FIXED0_TO_EXT64ADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FIXED0_TO_EXT64ADDR (page 310) NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
$FIXI pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FIXI (page 312) $FIXL pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FIXL (page 312) $FIXR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $O
Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FLT (page 314) $FLTR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $FLTR (page 314) $FREEZE NOTE: • The EpTAL compiler does not support this procedure. Use $TRIGGER (page 345) instead. (The EpTAL compiler does allow $FREEZE as a DEFINE name.) • Execution does not return from this call.
pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $HALT (page 315) $HIGH pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $HALT (page 315) $IFIX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFL
Sets $CARRY No Sets $OVERFLOW No More information: $INT (page 317) $INT_OV NOTE: $INT_OV is supported in the D40 and later RVUs. pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW Yes More information: $INT_OV (page 318) $INTERROGATEHIO NOTE: The EpTAL compiler does not support this routine.
pTAL privileged procedure Yes Can be executed only by privileged procedures Yes Sets condition code Yes Sets $CARRY No Sets $OVERFLOW No More information: $INTERROGATEIO (page 320) $INTR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $INTR (page 321) $IS_32BIT_ADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARR
$LEN pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $LEN (page 322) $LFIX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $LFIX (page 323) $LMAX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVE
Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $LMIN (page 324) $LOCATESPTHDR NOTE: The EpTAL compiler does not support this routine. pTAL privileged procedure No Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY Yes Sets $OVERFLOW No More information: $LOCATESPTHDR (page 324) $LOCKPAGE NOTE: The EpTAL compiler does not support this routine.
Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $MAX (page 326) $MIN pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $LMIN (page 324) $MOVEANDCXSUMBYTES pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $MOVEANDCXSUMBYTES (page 327) $MOVENONDUP pTA
More information: $MOVENONDUP (page 328) $NUMERIC pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $NUMERIC (page 329) $OCCURS pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $OCCURS (page 330) $OFFSET pTAL privileged procedure No Can be executed only by privileged procedures
$OPTIONAL param-pair pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $OPTIONAL (page 333) $OVERFLOW pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $OVERFLOW (page 335) $PARAM pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code
$POINT pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $POINT (page 336) $PROCADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $PROCADDR (page 337) $PROC32ADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CA
$PROC64ADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $PROC64ADDR (page 338) NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531). $READBASELIMIT NOTE: The EpTAL compiler does not support this procedure.
pTAL privileged procedure No Can be executed only by privileged procedures Yes Sets condition code No Sets $CARRY Yes Sets $OVERFLOW No More information: $READSPT (page 339) $READTIME pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $READTIME (page 340) $SCALE pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No
Sets $CARRY No Sets $OVERFLOW No More information: $SGBADDR_TO_EXTADDR (page 341) $SGBADDR_TO_SGWADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $SGBADDR_TO_SGWADDR (page 342) $SGWADDR_TO_EXTADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $SGWADDR_TO_EXTADDR (page 3
$SPECIAL pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $SPECIAL (page 343) $STACK_ALLOCATE NOTE: The pTAL and EpTAL compilers behave differently.
$TYPE pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $TYPE (page 345) $UDBL pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $UDBL (page 346) $UDIVREM16 pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Se
$UDIVREM32 pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW Yes, if and only if the divisor is 0 More information: $UDIVREM32 (page 348) $UFIX pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $UFIX (page 349) NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AA
More information: $UNLOCKPAGE (page 349) $WADDR_TO_BADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $WADDR_TO_BADDR (page 350) $WADDR_TO_EXTADDR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $WADDR_TO_EXTADDR (page 350) $WRITEPTE NOTE: The EpTAL compiler does not support
$XADR pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $XADR (page 352) $XADR32 pTAL privileged procedure No Can be executed only by privileged procedures No Sets condition code No Sets $CARRY No Sets $OVERFLOW No More information: $XADR32 (page 352) NOTE: 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP.
Compiler Directives • Directive Line (page 495) • ASSERTION (page 495) • BASENAME (page 495) • BEGINCOMPILATION (page 496) • BLOCKGLOBALS (page 496) • CALL_SHARED (page 496) • CHECKSHIFTCOUNT (page 497) • CODECOV (page 497) • COLUMNS (page 498) • DEFEXPAND (page 498) • DEFINETOG (page 499) • DO_TNS_SYNTAX (page 500) • ENDIF (page 500) • ERRORFILE (page 500) • ERRORS (page 500) • EXPORT_GLOBALS (page 501) • __EXT64 (page 501) • FIELDALIGN (page 502) • FMAP (page 502) •
• SECTION (page 513) • SETTOG (page 513) • SOURCE (page 514) • SRL (page 514) • SUPPRESS (page 515) • SYMBOLS (page 515) • SYNTAX (page 516) • TARGET (page 516) • USEGLOBALS (page 516) • WARN (page 517) Directive Line More information: Directive Line (page 367) ASSERTION 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 n
Dependencies: Use the BASENAME option only with the PROFGEN option References: PROFGEN More information: BASENAME (page 381) BEGINCOMPILATION NOTE: • This directive can appear only in the source file, not in the compilation command. • The EpTAL compiler ignores this directive.
Default: pTAL compiler: NOCALL_SHARED EpTAL compiler: CALL_SHARED Placement: Anywhere Scope: Applies to the compilation unit Dependencies: • If both CALL_SHARED and NOCALL_SHARED appear in the same compilation unit, the compiler uses the one that appears last • Do not use CALL_SHARED with GP_OK References: GP_OK (page 503) More information: CALL_SHARED (page 383) CHECKSHIFTCOUNT Default: NOCHECKSHIFTCOUNT Placement: Anywhere Scope: • CHECKSHIFTCOUNT applies to the shift operators that fo
Scope: Applies to the compilation unit Dependencies: None More information: • See Using the Code Profiling Utilities (page 366). • See the Code Profiling Utilities Manual.
More information: DEFEXPAND (page 386) DEFINETOG 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 and IFNOT • ENDIF • TARGET • __EXT64 References: • SETTOG (page 415) • RESETTOG (page 411) • IF and IFNOT (page 398) • ENDIF (page 390) • “TARGET” (page 423) • “__EXT64”
DO_TNS_SYNTAX 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 (page 516) More information: DO_TNS_SYNTAX (page 389) ENDIF See IF, IFNOT, and ENDIF (page 504).
More information: ERRORS (page 393) EXPORT_GLOBALS 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 t
NOTE: This directive is available in the 64-bit addressing functionality added to the EpTAL compiler starting with SPR T0561H01^AAP. For more information, see Appendix E, “64-bit Addressing Functionality” (page 531).
Scope: Applies to the compilation unit Dependencies: None 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.
IF, IFNOT, and ENDIF target Compiler Implicitly Sets Implicitly Resets pTAL • RISC1 _TNS_E_TARGET • TARGETSPECIFIED EpTAL • _TNS_E_TARGET RISC1 • TARGETSPECIFIED 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: 504 Syntax Summary Everything betwe
Dependencies: Interact with: • DEFINETOG • SETTOG • RESETTOG • TARGET References: • DEFINETOG (page 499) • RESETTOG (page 511) • SETTOG (page 513) • TARGET (page 516) • Toggles (page 370) More information: • IF and IFNOT (page 398) • ENDIF (page 390) INNERLIST 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: INNE
More information: INVALID_FOR_PTAL (page 401) LINES Default: LINES 60 Placement: Anywhere Scope: Applies until overridden by another LINES directive Dependencies: Has no effect if the list file is a terminal More information: LINES (page 401) LIST 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:
• MAP applies to subsequent code it until it is overridden by NOMAP Scope: • NOMAP applies to subsequent code until it is overridden by MAP Dependencies: MAP has no effect if NOLIST or SUPPRESS is active References: • LIST (page 506) • SUPPRESS (page 515) More information: MAP (page 402) OPTIMIZE 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 optim
OVERFLOW_TRAPS Default: pTAL compiler: OVERFLOW_TRAPS EpTAL compiler: NOOVERFLOW_TRAPS Placement: Before or between procedure declarations Scope: From the point it occurs in the compilation until it is overridden or the compilation ends, whichever occurs first Dependencies: OVERFLOW_TRAPS is overridden by: • NOOVERFLOW_TRAPS procedure attribute • DISABLE_OVERFLOW_TRAPS block attributes NOOVERFLOW_TRAPS is overridden by: • OVERFLOW_TRAPS procedure attribute • ENABLE_OVERFLOW_TRAPS block attributes
PRINTSYM 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 (page 506) • SAVEGLOBALS (page 512) • SUPPRESS (page 515) • USEGLOBALS (page 516) More information: PRINTSYM (page 408) PROFDIR NOTE: This directive
Scope: Applies to the compilation unit Dependencies: None More information: PROFGEN (page 409) PROFUSE NOTE: This directive can be used only with the EpTAL compiler.
RESETTOG 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 • ENDIF • __EXT64 • IF and ENDIF • SETTOG • TARGET References: • DEFINETOG (page 388) • ENDIF (page 390) • “__EXT64” (page 394) • IF and IFNOT (page 398) • SETTOG (page 415) • “TARGET” (page 516) • Toggles (page 370) More
ROUND 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 More information: ROUND (page 412) SAVEGLOBALS NOTE: The EpTAL compiler does not accept this directive.
SECTION 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 (page 417)) References: SOURCE (page 416) More information: SECTION (page 414) SETTOG Default: None Placement: • With a parenthesized list, it can appear anywhere • Without a parenthesized
• RESETTOG • TARGET References: • DEFINETOG (page 388) • ENDIF (page 390) • “__EXT64” (page 394) • IF and IFNOT (page 398) • RESETTOG (page 411) • “TARGET” (page 516) • Toggles (page 370) More information: SETTOG (page 415) SOURCE 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 (page 417)) • Inte
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.
Dependencies: Interacts with SAVEGLOBALS and USEGLOBALS References: • SAVEGLOBALS (page 512) • USEGLOBALS (page 516) NOTE: These linker options discard information that SYMBOLS saves: • -x discards line number information. • -s discards information needed for future linking (use it only in building an executable file).
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.
B Disk File Names and HP TACL Commands NOTE: This appendix applies only to Guardian platforms, not Windows platforms. • Disk File Names (page 518) • HP TACL Commands (page 520) For information about process or device file names, see the Guardian Programmer’s Guide. Disk File Names A disk file name identifies a file that contains data or a program. A disk file name reflects the specified file’s location on a NonStop system.
Example 365 Disk File Name \mynode.$myvol.mysubvol.myfileid 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 (page 519).
parts by using your current default values. Following are the optional file-name parts and their default values: File-Name Part Default node (system) Node (system) on which your program is executing volume Current default volume subvolume Current default subvolume Following are all the partial file names you can specify for a disk file named \BRANCH.$DIV.DEPT.EMP: Omitted File-Name Parts Partial File Name D-Series System C-Series System Node (system) $div.dept.
• Guardian User’s Guide (interactive information) • Guardian Programmer’s Guide (programmatic information) DEFINE • Substituting File Names for DEFINE Macros (page 521) • DEFINE Names (page 521) To create a DEFINE message or set its attributes, you must set a CLASS attribute for the DEFINE.
?SOURCE =multi Before running the compiler, you can associate file name \brig.$ullx.cable.port with =multi: ADD DEFINE =multi, FILE \brig.$ullx.cable.port During compilation, the compiler passes the DEFINE name to a system procedure, which makes the file available to the compiler. If the system procedure cannot make the file available, the open operation fails. TAPE DEFINE (D-Series Systems Only) The TAPE DEFINE lets you specify attributes for labeled magnetic tapes.
Ordinary ASSIGN Command The ordinary ASSIGN command equates a file name with a logical file name used in ERRORFILE, SAVEGLOBALS, SEARCH, SOURCE, and USEGLOBALS directives. The compiler accepts only the first 75 ordinary ASSIGN messages. 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.
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.
C Differences Between the pTAL and EpTAL Compilers • General (page 525) • Data Types and Alignment (page 525) • Routines (page 525) • Compiler Directives (page 527) General Topic pTAL Compiler EpTAL Compiler RVU D40 and later G06.20 and laterH06.
Routine or Attribute pTAL Compiler EpTAL Compiler $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.
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 for errors in filename OVERFLOW_TRAPS Default Issues a warning when filename meets one of the“Compiler Directives” (page 527) NOOVERFLOW_TRAPS Default SRL Not accepted TARGET Default an
D RETURN, RETURNSCC, and C/C++ on TNS/E Read this appendix if you write or call pTAL procedures that: • • Return both: ◦ A traditional function value by means of the RETURN statement ◦ An unrelated condition code value by means of the RETURNSCC attribute And are called by C or C++ procedures On the TNS architecture, a TAL procedure can return both a traditional function value and an unrelated condition code value. Both return values are accessible after the procedure call.
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 val_cc_combo.parts.value /* For 16-bit return 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.
return cc; end; Declaration of pTAL procedure P in Example 367 (page 528): 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.
E 64-bit Addressing Functionality 64-bit addressing functionality has been added to the EpTAL compiler starting with SPR T0561H01^AAP. This functionality is accessible only when the directive __EXT64 is specified. Code generated for the 64-bit addressing functionality can be executed on all H-series and J-series RVUs. This functionality is not supported by the TAL and pTAL compilers nor can it be executed on D-series and G-series RVUs.
PROC64PTR p (x,y) INT(16) x; INT(16) y; END PROCPTR; -- Note keyword PROCPTR here. Indirection Symbols .EXT32 An explicit 32-bit extended address type indirection symbol similar to .EXT. INT .EXT I; INT .EXT32 J; ! @I is type EXTADDR ! @J is type EXT32ADDR .EXT64 A 64-bit extended address type indirection symbol similar to .EXT and .EXT32. INT .
Returns -1 if the specified address value can be represented as a 32-bit byte address; otherwise, returns 0. Input values can be any of the address types except SGWADDR and SGBADDR, which are 16-bits in length. $PROCADDR $PROCADDR ( ) This standard function converts an INT(32), PROCADDR, PROC32ADDR, or PROC64ADDR expression to a PROCADDR. The bit pattern is unchanged.
Implicitly Defined Compilation Toggle __EXT64 The state of this toggle reflects whether the __EXT64 directive (see __EXT64) has been specified. If the__EXT64 directive is not specified, the compiler implicitly sets the __EXT64 toggle off. Likewise, if the __EXT64 directive is specifed, the compiler implicitly sets this toggle on. This toggle is implicitly defined and maintained by all versions of EpTAL starting with SPR T0561H01^AAP.
PROC p; BEGIN e64a := ea; p64a := p32a; @p64p := @p32p; ea := e64a; p32a := p64a; @p32p := @p64p; @p64p1 := @p32p; END; ----- Error: Error: Error: Error: conversion must be explicit. “” “” “” “” “” “” “” “” mismatched prototypes. Implicit conversions to/from INT(32) and EXT32ADDR are allowed. Implicit conversions to/from EXTADDR and EXT32ADDR are allowed.
Index Symbols " (quotation mark), 39 $ (dollar sign), 39 $ABS routine, 291 $ALPHA routine, 291 $ASCIITOFIXED routine, 292 $ATOMIC_ routines, 66, 67 $ATOMIC_ADD routine, 276 $ATOMIC_AND routine, 277 $ATOMIC_DEP routine, 278 $ATOMIC_GET routine, 279 $ATOMIC_OR routine, 280 $ATOMIC_PUT routine, 280 $AXADR routine, 293 $BADDR_TO_EXTADDR routine, 294 $BADDR_TO_WADDR routine, 294 $BITLENGTH routine, 295 $BITOFFSET routine, 296 $CARRY routine description of, 297 after assignments, 236 atomic operation that can set
$UNLOCKPAGE routine, 349 $WADDR_TO_BADDR routine, 350 $WADDR_TO_EXTADDR routine, 350 $WRITEPTE routine, 351 $XADR routine, 352 $XADR32 routine, 352 $XADR64 routine, 353 & (concatenation operator), 220 ' (single quotation mark), 39 (exclamation mark), 38 (semicolon) as delimiter, 38 in statements, 199 ), 38 as delimiter, 38 in statements, 199 * See Asterisk (*), 48 + See Plus sign (+), 70 - see Hyphen (-) See Minus sign (-), 70 -> in labeled CASE statement, 207 in move statement, 218 in RSCAN statement, 228
description of, 49 converting, 52 stored in pointers, 164 Address-conversion routines, 283 Addresses See also Data addresses, 55 arrays of, 108 as parameters to built-in routines, 275 assignment of, 365 extended, 77 in simple pointers, 172, 174 in structure pointers description of, 174 within structures, 152 nonextended, 78 of structures declared in subprocedures, 142 types of see Address types Aliases for data types, 48 Alignment base, 119 of constant lists, 64 of data, 66 of structure fields, 117 of struc
block, 235 procedure, 248 SCF user interface, 67 AUTO parameter description of, 118 compared to PLATFORM parameter, 119 FIELDALIGN clause and, 117 AXADR routine, 293 B Backslash (\\) See Remainder operator (’\\’), 71 BADDR address type description of, 165 converting, 53 parameters of, 251 STRING pointers of, 167 BADDR_TO_EXTADDR routine, 294 BADDR_TO_WADDR routine, 294 Base address symbols, 40 BASENAME directive, 381 Bases of constants, 44 BEGIN keyword in compound statement, 200 in procedure, 256 in struc
in source code, 367 summary of, 377 Compiler input directives, 377 Compiler listing conditionally compiled lines and, 400 Compiler listing directives, 377 Compiler listing:asterisk (*) in, 400 Compilers comparison of EpTAL, pTAL, and TAL, 31 differences between pTAL and EpTAL , 527 Completion codes, 358 Compound statements syntax of, 200 within DEFINE bodies, 99 Concatenation operator (&), 220 Condition codes See also Hardware indicators, 234 after assignments, 237 AND operator and, 83 atomic operations tha
DBLR routine, 301 Debugging cross compilers and, 429, 431 Enterprise Toolkit (ETK) and, 429 OPTIMIZE directive and, 404 with ASSERTION directive and ASSERT statement, 200 Decimal point, implied see Implied decimal point Declarations description of, 41 array See Arrays, declaring, 108 BIT_FILLER, 147 DEFINE, 98 entry point, 260 equivalenced see Equivalenced variables, declaring external, 419 FILLER, 147 function see Procedures, declaring global see Global data LITERAL, 97 NAME, 363 pointer See Pointers, decl
in structure, 115 in subprocedure, 259 ENDIF directive, 390 Enterprise Toolkit (ETK) cross compilers and, 426 debugging and, 429 DEFINE files and, 426 online help for, 431 Entry points declaring, 260 procedure, 168 subprocedure, 169 Equal sign as delimiter, 39 as equal operator signed (=):in conditional expression, 83 signed (=):operand types for, 84 signed (=):precedence of, 71 signed (=):without operands, 84 unsigned (’=’):in conditional expression, 83 unsigned (’=’):operand types for, 84 unsigned (’=’):p
with $FIXD routine, 309 with $FIXED0_TO_EXT64ADDR routine, 310 with $FIXR routine, 313 with $IFIX routine, 316 with $LFIX routine, 323 parameters of, 251, 252 FIXED data type:rounding and, 283 FIXED variables See also FIXED data type, 251 rounding, 412 scaling description of, 74 when assigning numbers to, 203 using, 74 FIXED variables:assigning numbers to, 203 FIXED(0) data type see FIXED data type Fixed-point scaling, 203 FIXED0_TO_EXT64ADDR, 310 FIXEDTOASCII routine, 310 FIXEDTOASCIIRESIDUE routine, 311 F
list of, 234 Hash mark (#), 39 HIGH routine, 315 HP TACL commands description of, 520 ASSIGN see ASSIGN command DEFINE see DEFINEs RUN, 357 Hyphen (-) followed by hyphen (-), 38 followed by right angle bracket (>), 39 I Identifiers description of, 42 classes of, 42 listing with GMAP directive, 397 with MAP directive, 402 with PRINTSYM directive, 408 saving, 421 IF and IFNOT directives, 398 IF expressions, 87 IF statement See also Conditional expressions, 217 description of, 217 hardware indicators in, 239
procedure pointer, 265 subprocedure, 258 passing conditionally, 333 Less than operator signed (<) in conditional expression, 83 operand types for, 84 precedence of, 71 without operands, 84 unsigned (’<’) in conditional expression, 83 operand types for, 84 precedence of, 71 with INT(32) operands, 76 without operands, 84 Less than or equal operator signed (<=) in conditional expression, 83 operand types for, 84 precedence of, 71 without operands, 85 unsigned (’<=’) in conditional expression, 83 operand types
Nonatomic operations, 281 Nonextended addresses, 78 Nonlocal GOTO statement, 215 Nonreserved keywords, 38 NonStop EpTAL, 426 NonStop operating systems, 31 NonStop pTAL, 426 NonStop Series see TNS architecture NonStop Series/Itanium see TNS/E architecture NonStop Series/RISC see TNS/R architecture Nonstring arrays, 113 NOOVERFLOW_TRAPS procedure attribute description of, 234 in procedure, 248, 250 in subprocedure, 257, 259 Not equal operator signed (<>) in conditional expression, 83 operand types for, 84 pre
OVERFLOW_TRAPS directive, 406 OVERFLOW_TRAPS procedure attribute description of, 234 in procedure, 248, 250 in subprocedure, 257, 259 P P-relative arrays see Read-only arrays PAGE directive, 407 Page heading, 407 PARAM routine, 336 PARAM SWAPVOL command, 522 Parameters See also Arguments, 275 actual see Actual parameters extended, 255 of built-in routines, 275 optional, 333 referencing, 256 Parameters:formal:See Formal parameters, 206 Parentheses as delimiters, 38 implied decimal point and, 38 operator pre
declaring, 246 dynamically selected calls to, 271 extensible, 250 EXTERNAL declaration of, 246, 247 formal parameter specification in, 251 FORWARD declaration of, 246, 247 labels in, 273 languages of, 250 main, 248 resident, 249 scope of, 43 system, 34 that return condition codes, 225, 250 typed See Functions, 246 using hardware indicators across, 244 variable, 249 with RETURN statements, 223 with two return values, 528 PROCPTRs see Procedure pointers PROFDIR directive, 408 PROFGEN directive, 409 Profile-gu
ROUND (default) misalignment handling method, 67 ROUND directive, 412 Rounding expressions unaffected by, 283 ROUND directive and, 412 type-conversion routines and, 283 Routines See also Functions, 274 address-conversion, 283 arithmetic, 285 built-in, 274 character-test, 284 maximum, 285 miscellaneous built-in, 286 procedure-parameter, 286 pTAL privileged, 281 type-conversion, 282 variable-characteristic , 285 RSCAN statement, 228 Run-time environment directives, 379 S SAVEGLOBALS directive, 372, 413 SCALE
redefining, 153 within structures, 142 Single quotation mark ('), 39 sINT, 274 Slash (⁄) see Division operator Smear operation, 222, 308 Source code listing, 402 SOURCE directive description of, 416 global data blocks and, 365 NOLIST directive and, 418 system procedure declarations and, 419 Source files checking syntax of, 422 compiling, 355 listing, 402 Spacing rules in syntax diagrams, 21 Special expressions, 85 SPECIAL routine, 343 SPT , 324 SPT (Segment Page Table) address of, 324 copying an entry from,
FORWARD declaration of, 259 sublocal declarations in, 259 that return condition codes, 258 variable, 258 with RETURN statements, 223 Substructures alignment of, 124 data type of, 345 declaring definition, 144 referral, 146 length of in bits, 295 in bytes, 322 number of elements of, 330 redefining definition, 155 referral, 157 Subsystem Control Facility see SCF user interface Subtraction operator signed (-) in arithmetic expression, 72 operand types for, 73 precedence of, 71 unsigned (’-’) in arithmetic expr
Variables description of, 43 equivalenced see Equivalenced variables FIXED, 74 procedure pointers as, 263 scope of, 43 simple see Simple variables storing data addresses in, 51 temporary creating, 232 dropping, 212 types of, 43 Visual Studio .