On 2022-04-21 22:43, Seymour J Metz wrote:
The problem is detecting overflow.

Even Intel has overflow.

________________________________________
From: IBM Mainframe Assembler List [[email protected]]
on behalf of Robin Vowels [[email protected]]
Sent: Wednesday, April 20, 2022 10:38 PM
To: [email protected]
Subject: Re: Unexpected C code

From: "Paul Gilmartin" <[email protected]>
Sent: Wednesday, April 20, 2022 10:32 AM

C programmers don't give a damn about overflows. An unfortunate consequence,
probably, of hardware architectures which, unlike 360, lack unsigned
instructions, forcing compilers to generate signed instructions for
unsigned operations.

I think that you will find that in machines that store negative values
in two's complement form will produce a correct sum (or difference)
using "signed" instructions, since all 32 bits* participate in the
addition (or subtraction.

On the S/360, the AL and SL instructions set the condition code
differently from A and S, but the 32-bit sum or difference is the same
as A and S.
__________________________

* [or whatever the word size is]

Reply via email to