Anonymous user
Four bit adder: Difference between revisions
→{{header|PL/I}}
Line 984:
=={{header|PL/I}}==
<lang PL/I>
/* 4-BIT ADDER */ /* 14 August 2010 */
TEST: PROCEDURE OPTIONS (MAIN);
DECLARE CARRY_IN BIT (1) STATIC INITIAL ('0'B) ALIGNED;
declare (m, n, sum)(4) bit(1) aligned;
Line 992:
get edit (m, n) (b(1));
put edit (m, ' + ', n, ' = ') (
do i = 4 to 1 by -1;
call full_adder ((carry_in), m(i), n(i), sum(i),
end;
put edit (sum) (b);
Line 1,003 ⟶ 1,002:
DECLARE (IN1, IN2, SUM, CARRY) BIT (1) ALIGNED;
SUM =
/* Exclusive OR using only AND, NOT, OR. */
CARRY = IN1 & IN2;
|