Monday, September 26, 2011

COBOL : comparing alphanumeric field with signed zoned decimal field

When we compare a signed numeric field with a alphanumeric field, the sign from the numeric field is temporarily removed before the comparison.


COBOL statement:- IF A (PIC S9(03)) = B (PIC X(03))

Equivalent Assembler code generated in the COBOL compiler listing

MVC 232(3,13),0(3) : Moving A to a temp storage
OI  234(13),X'F0'  : Removing sign from "A"
CLC 232(3,13),8(3) : Comparing A and B
BC  7,144(0,11)


IF A (PIC S9(03) COMP-3) = B (PIC X(03)) -> This comparison is not allowed. We cannot compare a comp-3 field with a alphanumeric field.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.