pTAL Conversion Guide

Bit Operations
pTAL Conversion Guide527302-002
14-4
Using 32-Bit Operands With Bit Deposit and Bit
Extract Operations
Using 32-Bit Operands With Bit Deposit and
Bit Extract Operations
TAL
You can perform bit extract and bit deposit operations only on 16-bit operands:
INT i;
INT j;
INT(32) k;
i := j.<12:15>; ! OK: j is 16 bits
i := k.<12:15>; ! ERROR: k is 32 bits
i := k.<28:31>; ! ERROR: k is 32 bits
You can reference any bits in an UNSIGNED(1-16) variable, even if the bits are not
declared in the variable’s declaration:
INT i;
UNSIGNED(4) j;
i := j.<12:15>; ! OK
i := j.< 7:11>; ! OK: TAL allows this,
! although only i contains only four bits
The TAL compiler issues a warning if a bit-extract operator accesses any of bits zero
through seven of a STRING field, but allows the reference:
INT i;
STRING j;
i := j.<8:15>; ! OK: i is 16 bits
i := j.<0:7>; ! OK: TAL issues a warning, but allows this,
! although only the low-order eight bits of i
! are defined
pTAL
You can perform bit extractions and deposits on 16-bit and 32-bit items. pTAL reports
an error, however, if you attempt to reference bits outside of the bits declared in the
variable’s declaration:
INT i;
UNSIGNED(4) j;
STRING k;
INT(32) l;
i := j.< 7:11>; ! ERROR: You can reference only
! bits 12 through 15 of j
i := k.<0:7>; ! ERROR: You can reference only
! bits 8 through 15 of k
i := l.<8:31>; ! OK: You can reference
! any of bits 0 through 31 of l