Sounds like Gene is translating his REXX save file checksum-calculating
pgm to C :-)

 http://archive.midrange.com/mi400/200311/msg00014.html

Below is a simple-minded implementation of ADDLC(S) in C.  It assumes
the operands are equal length and that the length is 4 or greater.

--Dave

----------------------------------------------------------------------
void addlcs(unsigned char *sum, unsigned char *addend, int length)
{
  int left;
  unsigned int oflo, *Psum, *Paddend;

  union {
      struct {
            unsigned int Lbin4;
            unsigned int Rbin4;
      } b4s;
      unsigned long long bin8;
      unsigned char cs[8];
  } uni;

  Psum = (unsigned int *)(sum + length - 4);
  Paddend = (unsigned int *)(addend + length - 4);
  oflo = 0;

  for (left=length; left>=4; left-=4)
  {
      uni.bin8 = (long long)*Psum +
                 (long long)*Paddend +
                 (long long)oflo;
      *Psum = uni.b4s.Rbin4;
      oflo = uni.b4s.Lbin4;
      Psum--;
      Paddend--;
  }

  if (left > 0)
  {
      uni.bin8 = 0;
      memcpy(&uni.cs[4-left], sum, left);
      memcpy(&uni.cs[8-left], addend, left);
      uni.b4s.Lbin4 += (uni.b4s.Rbin4 + oflo);
      memcpy(sum, &uni.cs[4-left], left);
  }
  return;
}
----------------------------------------------------------------------

Mark S. Waterbury wrote:
Hi, Gene:

---> private reply to you, off-list ... <---<<<

Does it have to be in ILE C? Why not just declare and use the ADDLC
instruction in-line, in say ILE RPG IV, as a built-in?

(see attached examples ...)

Or of course you could do that in ILE C also ... see the "MI Library
Reference" manual for details ...

What exactly are you trying to do? What is the end result you are trying
to compute?

Regards,

Mark S. Waterbury

Gene_Gaunt@xxxxxxxxxxxxxxx wrote:
What is a good ILE "C" way to do the same as MI's ADDLC on variables
longer
than 8 bytes, for example:

DCL DD A CHAR(68);
DCL DD B CHAR(68);
ADDLC(S) A, B;




This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2020 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].