X2C bug

10 views
Skip to first unread message

Fred van der Windt

unread,
Mar 2, 2021, 6:18:14 AM3/2/21
to z390
Hi,

I collegue of mine discovered what he reckons is a bug in the X2C function in z390. He also proposes a fix. These are his findings. Can you have a look at this conclusions and the  fix he proposes?

Thanks,

Fred!

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Yesterday, after revisiting, all the changes, I did in the z390 library, I found out, one that escape me to tell you ( It was a long time).

That is regarding the use of X2C function within FQM8921C data assembler

 

Its seems, regarding, the test I did, z390 only allows a one byte length, as X2C hex string input.

So looks like a bug, also.

Can you post that on the z390 project?

Antonio Vale Macedo

ORIGINAL CODE:

    private void exec_pc_x2b(){

                /*

                 * convert hex string to binary string

                 */

                check_setc_quotes(1); // RPI 1139

                setc_value1 = get_setc_stack_value();

                seta_value1 = Integer.valueOf(setc_value1,16);

                                setc_value = Integer.toString(seta_value1,2);

                                seta_value = setc_value.length();

                                seta_value = seta_value - seta_value/8*8;

                                if (seta_value != 0){

                                                setc_value = "00000000".substring(seta_value) + setc_value;

                                }

                                put_setc_stack_var();

    }

RESULT: Error

".\input\FQM8921C.AASM"

09:23:49 FQM8921C  MZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

MZ390E abort 84 file=1 line=43 internal system exception - java.lang.NumberFormatException: For input string: "30313233343536373839616263646566414243444546"

MZ390I total mnote warnings = 0

MZ390I total mnote errors   = 0

MZ390I max   mnote level    = 0

MZ390I total mz390 errors   = 1

09:23:49 FQM8921C  MZ390 ENDED   RC=16 SEC= 0 MEM(MB)= 32 IO=344

CHANGED CODE: 

    private void exec_pc_x2c(){

                /*

                 * convert hex string to char string

                 */

                check_setc_quotes(1); // RPI 1139

                setc_value1 = get_setc_stack_value();

                /* AVM

                seta_value = Integer.valueOf(setc_value1,16);

                                setc_value = ""

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 24]

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 16 & 0xff]        

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 8  & 0xff]

                                                       + (char)tz390.ebcdic_to_ascii[seta_value        & 0xff]                                                                                              

                                                       ;

                                */          

                /*AVM-INI*/

                                StringBuilder stb = new StringBuilder("");

                                for (int i = 0; i < setc_value1.length(); i += 2) {

                        String str = setc_value1.substring(i, i + 2);

                        stb.append((char) Integer.parseInt(str, 16));

                    }

                                setc_value = stb.toString();

                                /*AVM-END*/

                                put_setc_stack_var();

    }

RESULT:OK

09:33:05 FQM8921C  MZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

MZ390I total mnote warnings = 0

MZ390I total mnote errors   = 0

MZ390I max   mnote level    = 0

MZ390I total mz390 errors   = 0

09:33:06 FQM8921C  MZ390 ENDED   RC= 0 SEC= 0 MEM(MB)= 39 IO=1311

09:33:08 FQM8921C  AZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

09:33:10 FQM8921C  AZ390 ENDED   RC= 0 SEC= 2 MEM(MB)= 64 IO=6493

09:33:11 FQM8921C  LZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

09:33:11 FQM8921C  LZ390 ENDED   RC= 0 SEC= 0 MEM(MB)= 55 IO=8636########################################################################

    private void exec_pc_x2b(){

                /*

                 * convert hex string to binary string

                 */

                check_setc_quotes(1); // RPI 1139

                setc_value1 = get_setc_stack_value();

                seta_value1 = Integer.valueOf(setc_value1,16);

                                setc_value = Integer.toString(seta_value1,2);

                                seta_value = setc_value.length();

                                seta_value = seta_value - seta_value/8*8;

                                if (seta_value != 0){

                                                setc_value = "00000000".substring(seta_value) + setc_value;

                                }

                                put_setc_stack_var();

    }

########################################################################

".\input\FQM8921C.AASM"

09:23:49 FQM8921C  MZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

MZ390E abort 84 file=1 line=43 internal system exception - java.lang.NumberFormatException: For input string: "30313233343536373839616263646566414243444546"

MZ390I total mnote warnings = 0

MZ390I total mnote errors   = 0

MZ390I max   mnote level    = 0

MZ390I total mz390 errors   = 1

09:23:49 FQM8921C  MZ390 ENDED   RC=16 SEC= 0 MEM(MB)= 32 IO=344

########################################################################

 

    private void exec_pc_x2c(){

                /*

                 * convert hex string to char string

                 */

                check_setc_quotes(1); // RPI 1139

                setc_value1 = get_setc_stack_value();

                /* AVM

                seta_value = Integer.valueOf(setc_value1,16);

                                setc_value = ""

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 24]

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 16 & 0xff]        

                                                       + (char)tz390.ebcdic_to_ascii[seta_value >>> 8  & 0xff]

                                                       + (char)tz390.ebcdic_to_ascii[seta_value        & 0xff]                                                                                              

                                                       ;

                                */          

                /*AVM-INI*/

                                StringBuilder stb = new StringBuilder("");

                                for (int i = 0; i < setc_value1.length(); i += 2) {

                        String str = setc_value1.substring(i, i + 2);

                        stb.append((char) Integer.parseInt(str, 16));

                    }

                                setc_value = stb.toString();

                                /*AVM-END*/

                                put_setc_stack_var();

    }

########################################################################

".\input\FQM8921C.AASM"

09:33:05 FQM8921C  MZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

MZ390I total mnote warnings = 0

MZ390I total mnote errors   = 0

MZ390I max   mnote level    = 0

MZ390I total mz390 errors   = 0

09:33:06 FQM8921C  MZ390 ENDED   RC= 0 SEC= 0 MEM(MB)= 39 IO=1311

09:33:08 FQM8921C  AZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

09:33:10 FQM8921C  AZ390 ENDED   RC= 0 SEC= 2 MEM(MB)= 64 IO=6493

09:33:11 FQM8921C  LZ390 START USING z390 V1.5.06 ON J2SE 1.8.0_211 03/02/21

09:33:11 FQM8921C  LZ390 ENDED   RC= 0 SEC= 0 MEM(MB)= 55 IO=8636


Abe Kornelis

unread,
Mar 3, 2021, 12:41:43 PM3/3/21
to z3...@googlegroups.com

Fred,

Thank you for reporting the issue. I have created RPI 1646 to cover the case:

RPI 1646 2021-02-03 X2C and X2B functions fail on multi-byte input data. See mail by Fred van der Windt dd 2021-02-03 12:18

I am currently focussing on the zVSAM project.
Hopefully Don can find some time to validate and incorporate the proposed change.

Kind regards,
Abe
===



Op 02/03/2021 om 12:18 schreef Fred van der Windt:
--
You received this message because you are subscribed to the Google Groups "z390" group.
To unsubscribe from this group and stop receiving emails from it, send an email to z390+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/z390/2364a13b-f313-48bf-9771-7523b83ca556n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages