Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect processing of arithmetic (SETA) expresions when overflow occurs #549

Open
jyganci opened this issue Aug 9, 2024 · 0 comments
Open
Labels
bug Something isn't working component-core Related to core components (java) component-tests Related to regression test sets for z390

Comments

@jyganci
Copy link
Contributor

jyganci commented Aug 9, 2024

The z390 processing of arithmetic expressions does not properly handle conditions when arithmetic overflow occurs. Following examples of the form (1) set LCLA symbol &A to initial valid value (2) Attempt to set &A to invalid value (3) MNOTE the final value of &A. Both HLASM and z390 results are shown for four examples.

Note the two arithmetic overflows and the two multiplicatoin overflows in HLASM. No errors in z390.

HLASM
                                      49 *************************
                                      50 * &A SET TO 0
                                      51 *
                                      52 &A       SETA  1
                                      53 *
                                      54 *&A      SETA  2147483647+3
                                      55 &A       SETA  2147483647+3
 ** ASMA075E Arithmetic overflow
                                      56 &SA      SETC  SIGNED(&A)
                                      57          MNOTE '&&A=&SA'
                                        +&A=0
                                      58 *
                                      59 &A       SETA  1
                                      60 *
                                      61 *&A      SETA  -2147483648-3
                                      62 &A       SETA  -2147483648-3
 ** ASMA075E Arithmetic overflow
                                      63 &SA      SETC  SIGNED(&A)
                                      64          MNOTE '&&A=&SA'
                                        +&A=0
                                      65 *
                                      66 *************************
                                      67 * &A SET TO 1
                                      68 *
                                      69 &A       SETA  2
                                      70 *
                                      71 *&A      SETA  2*2147483647
                                      72 &A       SETA  2*2147483647
 ** ASMA103E Multiplication overflow; default product=1 - OPENC
                                      73 &SA      SETC  SIGNED(&A)
                                      74          MNOTE '&&A=&SA'
                                        +&A=1
                                      75 *
                                      76 *************************
                                      77 * &A SET TO -2
                                      78 *
                                      79 &A       SETA  1
                                      80 *
                                      81 *&A      SETA  2*1024*1024*1024-3
                                      82 &A       SETA  2*1024*1024*1024-3
 ** ASMA103E Multiplication overflow; default product=1 - OPENC
                                      83 &SA      SETC  SIGNED(&A)
                                      84          MNOTE '&&A=&SA'
                                        +&A=-2
                                      85 *
                                      86 *************************

z390
000000                                      (1/49)39 *************************
000000                                      (1/50)40 * &A SET TO 0
000000                                      (1/51)41 *
000000                                      (1/53)42 *
000000                                      (1/54)43 *&A      SETA  2147483647+3
000000                                      (1/57)44          MNOTE '&A=-2147483646'
000000                                      (1/58)45 *
000000                                      (1/60)46 *
000000                                      (1/61)47 *&A      SETA  -2147483648-3
000000                                      (1/64)48          MNOTE '&A=2147483645'
000000                                      (1/65)49 *
000000                                      (1/66)50 *************************
000000                                      (1/67)51 * &A SET TO 1
000000                                      (1/68)52 *
000000                                      (1/70)53 *
000000                                      (1/71)54 *&A      SETA  2*2147483647
000000                                      (1/74)55          MNOTE '&A=-2'
000000                                      (1/75)56 *
000000                                      (1/76)57 *************************
000000                                      (1/77)58 * &A SET TO -2
000000                                      (1/78)59 *
000000                                      (1/80)60 *
000000                                      (1/81)61 *&A      SETA  2*1024*1024*1024-3
000000                                      (1/84)62          MNOTE '&A=2147483645'
000000                                      (1/85)63 *
000000                                      (1/86)64 *************************

Two existing z390 regression tests, rt/mlc/TESTDC1.MLC and rt/mlc/TESTASC1.MLC have tests that currently do not produce errors but should if z390 is corrected to match HLASM behavior. Comments about this problem appear in the source of the 2 programs.

The code in mz390.java (and possibly az390.java) should correctly process arithmetic expressions, detecting and reporting any overflow errors.

@jyganci jyganci added bug Something isn't working component-core Related to core components (java) component-tests Related to regression test sets for z390 labels Aug 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component-core Related to core components (java) component-tests Related to regression test sets for z390
Projects
None yet
Development

No branches or pull requests

1 participant