pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
$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.
NopTAL privileged procedure
NoCan be executed only by privileged procedures
NoSets condition code
NoSets $CARRY
Yes, if the divisor is 0 or the quotient is too largeSets $OVERFLOW
dividend
input
INT(32):value
divisor
input
sINT:value
quotient
output
sINT:variable
remainder
output
sINT:variable
The compiler checks the following conditions during compilation:
• If the value of divisor is a constant value of zero, the compiler reports an error that division
by zero is not valid:
$UDIVREM16(dividend, 2 / 2 - 1, quot, rem); ! Report error
• If both dividend and divisor have constant values whose unsigned quotient is greater
than 16 bits, the compiler reports overflow:
INT quot, rem;
$UDIVREM16(65536 * 1024, 256, quot, rem); ! Report error
• If both dividend and divisor are constants, and you test $OVERFLOW following the
call to $UDIVREM16, the compiler reports a warning that overflow cannot occur:
$UDIVREM16(32767, 256, quot, rem);
Nonatomic Operations 347