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

A- 3
<< sdec = 3 -- Ignore the last three >>
<< parameters (in SPL, this is >>
<< the default case, deleting >>
<< three stack words). >>
<< sdec = 2 -- Expect only one parameter after>>
<< this, cnt. >>
<< sdec = 1 -- Expect two parameters after >>
<< this, cnt and laddr. >>
<< sdec = 0 -- Expect three parameters after >>
<< this, cnt, laddr, and raddr. >>
<< cnt -- The value of "count" at the conclusion of the >>
<< comparison. If the strings compare for count >>
<< bytes, cnt will equal zero. >>
<< laddr -- The address of the char within the left string >>
<< which failed to match. >>
<< raddr -- The address of the char within the right string>>
<< which failed to match. >>
DEFINE LSS=0#, LEQ=1#, EQU=2#, NEQ=3#, GEQ=4#, GTR=5#;
INTEGER PROCEDURE BYTECMP(left,cmp,right,count,sdec,cnt,laddr,raddr);
VALUE left, cmp, right, count, sdec, cnt, laddr, raddr;
LOGICAL left, right, laddr, raddr;
INTEGER cmp, count, sdec, cnt;
BEGIN
DEFINE ADJ =
DO BEGIN
IF count > 0
THEN BEGIN count:=count-1; @lftp:=@lftp+1; @rhtp:=@rhtp+1; END
ELSE BEGIN count:=count+1; @lftp:=@lftp-1; @rhtp:=@rhtp-1; END;
END#;
BYTE POINTER lftp, rhtp, laddrp, raddrp;
INTEGER POINTER cntp;
@lftp := left;
@rhtp := rht;
@cntp := cnt;
@laddrp := laddr;
@raddrp := raddr;
CASE cmp OF
BEGIN
<<LSS: compare < >>
BEGIN WHILE (count <> 0) AND (lftp < rhtp) ADJ END;
<<LEQ: compare <= >>
BEGIN WHILE (count <> 0) AND (lftp <= rhtp) ADJ END;
<<EQU: compare == >>
BEGIN WHILE (count <> 0) AND (lftp == rhtp) ADJ END;
<<NEQ: compare <> >>
BEGIN WHILE (count <> 0) AND (lftp <> rhtp) ADJ END;
<<GEQ: compare >= >>
BEGIN WHILE (count <> 0) AND (lftp >= rhtp) ADJ END;
<<GTR: compare > >>
BEGIN WHILE (count <> 0) AND (lftp > rhtp) ADJ END;
END;
CASE sdec OF
BEGIN
<< 0 >> GOTO sdec 0;
<< 1 >> GOTO sdec 1;
<< 2 >> GOTO sdec 2;
<< 3 >> GOTO sdec 3;
END;
sdec0: raddrp := rhtp;
sdec1: laddrp := lftp;
sdec2: cntp := count;
sdec3: ; << nil >>
BYTECMP := IF count = 0 THEN 1 ELSE 0;
END;