HP 3000 Manuals

HP C/XL MOVEBW Function: Move Bytes While [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation


SPL to HP C/XL Migration Guide

HP C/XL MOVEBW Function:  Move Bytes While 

     /**************************************************************
       MOVEBW            SPL MOVE BYTES WHILE

       This emulates the MOVE while statement in SPL
               MOVE B1 := B2, WHILE A, 0;
               @S1 := tos;
               @D1 := tos;
       which may be converted to C with:
               LEN := MOVEBW(B1,B2,A,0,&S1,&D1);

       The parameters to moveb are:
         to          --  The address to be moved into.
         from        --  The address to be moved from.
         cond        --  The move while condition, where:
                           A    means alphabetic
                           AN   means alphanumeric
                           AS   means alphabetic, upshift
                           N    means numeric
                           ANS  means alphanumeric, upshift
         sdec        --  The SPL stack decrement.  In this context, the
                        value of this parameter will determine if
                        the function accesses the last two
                        parameters, as follows:
                        sdec = 3  -- Ignore the last two parameters
                                    (in SPL, this is the default
                                    case, deleting 3 stack words).
                        sdec = 2  -- Expect only one parameter
                                    after this, dest_addr.
                        sdec = 1  -- Expect two parameters after
                                    this, dest_addr and source_addr.
                        sdec = 0  -- Same as 1.  This is not a
                                    meaningful operation in SPL,
                                    as the TOS, or count value,
                                    is always zero after the MOVE
                                    instruction.
         source_addr --  The address of the next char of from beyond
                        the final character moved.
         dest_addr   --  The address of the char of from beyond the
                        final character moved.

       The return value of the function is the number of bytes moved.

     *************************************************************/

     enum COND {A, AN, AS, N, ANS};
     short int MOVEBW(to,from,cond,sdec,source_addr,dest_addr)
       enum COND cond;
       char *to, *from, **source_addr, **dest_addr;
       int sdec;
     {
       char *temp;
       temp = to;
       switch (cond)  {
         case   A:  while (isalpha(*from)) *to++ = *from++;
                         break;
         case  AN:  while (isalnum(*from)) *to++ = *from++;
                         break;
         case  AS:  while (isalpha(*from)) *to++ = toupper(*from++);
                         break;
         case   N:  while (isdigit(*from)) *to++ = *from++;
                         break;
         case ANS:  while (isalnum(*from)) *to++ = toupper(*from++);
                         break;
       }
       switch (sdec) {
         case 0:  ;  /*  fall through to case 1  */
         case 1:  *source_addr = from;
         case 2:  *dest_addr = to;
       }
       return(to-temp);
     }



MPE/iX 5.0 Documentation