Here is another table based scheme which combines sign validation, sign classification (i.e., the sign is negative or positive) and recognition of the preferred sign values.
LLC R14,BYTE Fetch the rightmost byte * of the Zoned Decimal field. * SRL R14,4(0) Convert the Zone bits * to a table index. * LA R14,ZDSTBL(R14) * Fetch the corresponding ICM R14,B'0001',0(R14) * table value. * JZ INVALID Br if the Zone is not a * valid Sign value. * JM NEGATIVE Br if the Zone indicates * a Negative value. * * Fall through when the Sign is considered Positive. * POSITIVE DC 0H'0' TML R14,ZDSTPREF Test for the Preferred * Sign indicator if so * desired. * ... Deal with Positive values ... * J FINISH All done NEGATIVE DC 0H'0' TML R14,ZDSTPREF Test for the Preferred * Sign indicator if so * desired. * ... Deal with Negative values ... * J FINISH All done * ------------------------------------------------------------------ * * The following table is used to validate the 4-bit Zone field of * the rightmost byte of a Zoned Decimal value when interpreting * the Zone value as a Sign value. * * When a table entry is all binary zeros the corresponding Zone * value is not a valid Sign value. * * Preferred Sign values are also indicated. * * The leftmost bit of a table entry is used to indicate the Sign * (Negative or Positive) such that its value (one or zero, * respectively) can be used to set a corresponding Condition Code * when the entry is fetched using the Insert Characters Under Mask * instruction. * * ------------------------------------------------------------------ ZDSTNEG EQU X'80' When one, the sign is * regarded as Negative. * Else, the sign is regarded * as Positive. * ZDSTPREF EQU X'40' When one, the sign is * regarded as the Preferred * sign. * * EQU X'20' *** Reserved * EQU X'10' *** Reserved * EQU X'08' *** Reserved * EQU X'04' *** Reserved * EQU X'02 *** Reserved * ZDSTVAL EQU X'01' When one, the sign is valid. * DC 0D'0' ZDSTBL EQU *,16 DC 10AL1(0) Zone values of x'0' * through x'9' are * invalid. * DC AL1(ZDSTVAL) A: Positive, Valid DC AL1(ZDSTNEG+ZDSTVAL) B: Negative, Valid * DC AL1(ZDSTPREF+ZDSTVAL) C: Positive, Preferred, * Valid. * DC AL1(ZDSTNEG+ZDSTPREF+ZDSTVAL) * D: Negative, Preferred, * Valid. * DC AL1(ZDSTVAL) E: Positive, Valid DC AL1(ZDSTVAL) F: Positive, Valid *