pTAL Guidelines for TAL Programmers

Coding Guidelines
pTAL Guidelines for TAL Programmers527256-002
2-5
Compilers
Compilers
Whether you intend to run your pTAL code as a TNS process or as a native process,
compile your source code first with a native compiler. If you are going to run your code
only as a TNS process, specify the SYNTAX directive on the command line when you
run the native compiler.
Topics:
Conditional Compilation on page 2-5
DO_PTAL Directive on page 2-6
Conditional Compilation
Guideline: Use the IF PTAL directive to control program compilation.
Native and TAL compilers support a conditional compilation toggle called PTAL, which
is always true for pTAL compilations and always false for TAL compilations. You can
execute an object file generated by the TAL compiler only as a TNS process. You can
execute an object file generated by native compiler only as a native process. By testing
the PTAL toggle at compile time, you can compile different code for different
processes.
Saving the P, L, and S Registers on
page 2-53
Do not implement state machines by saving
and restoring the P, L, and S registers.
Signed (Arithmetic) Left Shifts
on page 2-56 The sign bit is not preserved by signed
(arithmetic) left shifts.
Signed and Unsigned 16-Bit Addition,
Subtraction, and Negation on page 2-9
Use unsigned operators if you expect
modulo-2
16
results.
STACK and STORE Statements
on
page 2-55
Avoid STACK and STORE statements.
Stack Marker Accesses Using Based-
Address Equivalenced Declarations,
Indexing, and Pointers on page 2-26
Do not read or write the contents of the stack
marker.
TNS Registers
on page 2-52 If you must use register operations, localize
the register operations in DEFINEs or
procedures.
TNS Registers and Trap Handlers
on
page 2-53
Use registers in trap handlers only in
programs running as TNS processes.
USE and DROP Statements
on page 2-54 Always assume that the value of a USE
variable is initially undefined.
Topic Guideline (page 5 of 5)