Just remember that the mapping from numbers to immediate fields has two steps.
In any numeric context where the assembler would accept an expression, any value is first evaluated as a 31-bit signed binary number. A simple number, regardless of whether in hex, decimal, bit or character form, is just a special case of an expression, and its representation does not affect the interpretation of the resulting value. The expression value is then assigned to the appropriate instruction field, checking that the value lies within the appropriate range, except that this check can be suppressed using TYPECHECK(NOMAGNITUDE) for signed immediate values. Immediate operands which are less than 4 bytes are either unsigned or signed, depending on the instruction definition. For logical operations such as NILL they are unsigned. For arithmetic operations such as AHI they are signed. Immediate operands which are 4 bytes are not currently checked because unsigned 32-bit expressions are not supported so the value is always expected to be signed 31-bit. Assigning a negative value to an unsigned immediate operand of less than 4 bytes is therefore an error. For a signed immediate operand, it is an error to assign a value which exceeds the maximum positive value, so for example LHI 0,-1 is valid but LHI 0,X'FFFF' is not because X'FFFF' is 65535. Jonathan Scott, HLASM IBM Hursley, UK