SPL to HP C/XL Migration Guide (30231-90001)
5-33
mem... functions do not use NUL. See the
HP C/XL Library Reference
Manual
for details.
Unconditional byte moves may be emulated in HP C/XL by the MOVEB
function, shown in Figure 5-21.
___________________________________________
| |
| int MOVEB(to,from,count,sdec,source_adr,dest_adr)|
| char *to, *from, **source_adr, **dest_adr; |
| int count, sdec; |
| { |
| 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-21. HP C/XL MOVEB Function: MOVE Bytes Statement
In MOVEB, to is the
target
address, from is the
source
address, count
isthe number of bytes to be moved (a positive value means a left-to-right
move, negative means right-to-left), and sdec is is the value which
would have been used as an SPL stack decrement. In this context, sdec
= 3 will cause the function to ignore the last two parameters, which
need not be present. An sdec = 2 will set the value for dest_adr, sdec
= 1 or 0 will set both dest_adr and source_adr. The parameter source_adr
is the address of the next character beyond the final character moved,
dest_adr is the address of the next character beyond the final character
moved, and the return value of the function is the number of bytes moved.
The following emulates the MOVE statement in SPL for byte moves with no
information removed from the stack:
MOVE A1 := A2, (CNT), 0
LEN := TOS;
will always be zero
@S1 := TOS;
@D1 := TOS;
NUM := @D1 - @A1;
number of bytes moved
This may be converted to HP C/XL as:
NUM = MOVEB(&A1,&A2,CNT,0,&S1,&D1);