Adding fileds.

To execute adding fields procedure bit-by-bit summing of source fields F1 and F2 is performed. Result bits are written to SUM field. Logical expressions for partial sum and carry are similar to sequential binary summator. Capacity of fields F1 and F2 are given in parameters CAP1 and CAP2.

procedure ADDF( refer slice sum[ ], f1[ ], f2[ ]; index cap1, cap2 );

const

andf = 8, orf = 14, xorf = 6, nandf = 2;

index

i, cap;

slice

c;

begin

if cap1 > cap2 then cap := cap1 else cap := cap2;

{ Result capacity = cap + 1 }

CLEAR( c );

for i := 0 to cap-1 do

begin

{ New value for carry: Y = ~c & ( f1&f2 ) | c & ( f1|f2 ) }

LOGF( X, f1[ i ], f2[ i ], andf );

LOGF( Y, f1[ i ], f2[ i ], orf );

LOGF( X, c, X, nandf );

LOGF( Y, c, Y, andf );

LOGF( Y, X, Y, orf );

{ Calculate sum: sum = ( f1^f2 )^c }

LOGF( X, f1[ i ], f2[ i ], xorf );

LOGF( sum[ i ], X, c, xorf );

COPY( c, Y );

end;

i := i+1;

COPY( sum[ i ], c )

end;{ End of ADDF }