SPL to HP C/XL Migration Guide (30231-90001)

5- 34
The other variants of byte moves (removing one, two, or all three of the
words normally left on the stack after a MOVE) may all be emulated by
this function.
Word moves of 16-bit quantities may be emulated by a minor variation of
MOVEB, the HP C/XL function, MOVEW, shown in Figure 5-22.
______________________________________________________________
| |
| int MOVEW(to,from,count,sdec,source_adr,dest_adr) |
| unsigned short *to, *from, **source_adr, **dest_adr;|
| { |
| int c; |
| c = 0; |
| if (count>0) /* left-to-right move */ |
| do *to++ = *from++; while (++c < count); |
| else if (count<0) /* right-to-left move */ |
| { |
| count = -count; |
| do *to-- = *from--; while (++c < count); |
| } |
| |
| switch (sdec) |
| { |
| case 0: ; /* fall through to case 1 */ |
| case 1: *source_adr = from; |
| case 2: *dest_adr = to; |
| case 3: ; /* nil */ |
| } |
| |
| return(c); |
| } |
______________________________________________________________
Figure 5-22. HP C/XL MOVEW Function: MOVE Words Statement
The MOVE statement with a WHILE condition may be emulated by the HP C/XL
MOVEBW function, shown in Figure 5-23.
MOVEBW is used similarly to MOVEW, but, instead of a count, a condition
is supplied. The condition is chosen from the enum declared as COND that
matches the SPL options.
The SPL operation:
LEN := MOVE B1 := B2 WHILE AS;
@S1 := TOS;
@D1 := TOS;
may be replaced with the HP C/XL function call:
LEN = MOVEBW(B1,B2,AS,0,&S1,&D1);
In SPL, a MOVE-WHILE operation sets a condition code to indicate the type
of the last character of the source that was examined (but not moved).
This is easily tested by standard HP C/XL character functions. For
example, if an SPL MOVE-WHILE statement is followed by:
IF > THEN...<<move stopped on a digit 0-9>>