|
On 08/24/2000 at 12:32:29 AM, "Peter Dow" <pdow@earthlink.net> wrote:
What's the difference between H"80000000" in Gene's initial post and
X'80000000' that everyone else used? Is there some significance to using H
and " instead of X and '? Are they supposed to be equivalent?
H'80000000' is a numeric literal. More specifically, it has the attributes
of a signed integer.
X'80000000' is a character literal. It has the attributes of a character
type.
Given the following declaration of FLAG,
DCL DD FLAG AUTO BIN(4) UNSGND;
we've observed several behaviors which can be explained in terms of the
integer vs character attributes of the literal values:
DCL DD FLAG AUTO BIN(4) UNSGND INIT(H"80000000");
-- fails at compile time because the assembler recognizes that the
initial value is negative (recall that H-literals are signed).
DCL DD FLAG BIN(4) UNSGND AUTO INIT(X'80000000');
-- works because the initialization of automatic data is implemented
using "copy bytes"-like instructions, which ignore numeric atrributes of
the data.
CPYNV FLAG, H"80000000";
-- fails at runtime with binary overflow (mch1210). The exception occurs
when the signed integer value (-2147483648) is converted to unsigned in
preparation for the store to FLAG.
CPYNV FLAG, X'80000000';
-- fails at compile time because operand 2 has character attributes
instead of numeric attributes
CPYBLA FLAG, X'80000000';
-- works because CPYBLA ignores the numeric attributes of the receiver
CPYNV FLAG, 2147483648;
-- works because an unsigned literal is specified
DCL DD FLAG AUTO BIN(4) UNSGND INIT(2147483648);
-- works because an unsigned literal is specified
Bob Donovan
+---
| This is the MI Programmers Mailing List!
| To submit a new message, send your mail to MI400@midrange.com.
| To subscribe to this list send email to MI400-SUB@midrange.com.
| To unsubscribe from this list send email to MI400-UNSUB@midrange.com.
| Questions should be directed to the list owner/operator: dr2@cssas400.com
+---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.