HP C/XL MOVESB Function: Move String Bytes [ SPL to HP C/XL Migration Guide ] MPE/iX 5.0 Documentation
SPL to HP C/XL Migration Guide
HP C/XL MOVESB Function: Move String Bytes
/**************************************************************
MOVESB SPL MOVE STRING BYTES
This emulates the MOVE statement in SPL for string moves,
for example:
MOVE A1 := "constant string",0;
LEN := tos;
S1 := tos;
D1 := tos;
which may be converted to C with:
LEN := MOVESB(A1,"constant string",0,&S1,&D1);
The parameters to MOVESB are:
to -- The address to be moved into,
right to left.
sdec -- The SPL stack decrement. 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 never meaningful
in SPL, because the TOS (count)
is always zero after a MOVE.
source_addr -- The address of the next char of str beyond.
the final character moved.
dest_addr -- The address of the next char of to beyond the
final character moved.
The return value is the number of bytes moved.
**************************************************************/
short int MOVESB(to,str,sdec,source_addr,dest_addr)
char *to, *str, **source_addr, **dest_addr;
int sdec;
{
char *temp;
temp = to;
while (*str != '\0') *to++ = *str++;
switch (sdec) {
case 0: ; /* fall through to case 1 */
case 1: *source_addr = str;
case 2: *dest_addr = to;
case 3: ; /* nil */
}
return(to-temp);
}
MPE/iX 5.0 Documentation