Article 4965 of comp.sys.handhelds: Path: wuarchive!sdd.hp.com!hp-pcd!hpcvra.cv.hp.com!rnews!hpcvbbs!akcs.dnickel From: akcs.dnickel@hpcvbbs.UUCP (Derek Scott Nickel) Newsgroups: comp.sys.handhelds Subject: REV - string reverse routine Keywords: rev Message-ID: <277c1d80:1523comp.sys.handhelds@hpcvbbs.UUCP> Date: 29 Dec 90 04:40:11 GMT Lines: 55 Here is an updated copy of my string reversing routine. REV takes one arguement, the string to reverse. (Use ASC\-> to decode). Derek S. Nickel %%HP: T(3)A(R)F(.); "D9D20D29512BF81D0040D9D208813063650FD5502C230F6E30C1C1632230CCD2 0940008F146608FB9760CC4C2147134169174147C2C213517914F14C1611C1CC 51F8D34150B9F06B2130B213063F9" ======================================================================== REV 80000: 02D9D ! Program 80005: 1592D ; Set last RPL token to <0h> and verify DEPTH >= 1 8000A: 18FB2 ; Check arguments for type 8000F: 0400D ; <3h> 80014: 02D9D ! Program 80019: 03188 ; Internal DUP 8001E: 05636 ; Internal SIZE (1:String) -> System Binary 80023: 055DF ; "" 80028: 032C2 ; Internal OVER 8002D: 03E6F ; Internal multiply by 2 (1:System Binary) 80032: 61C1C ; allocate nibbles (2:sized object,1:System Binary) 80037: 03223 ; Internal SWAP 8003C: 02DCC ! Code 80041: 00049 ! 73 nibbles (next RPL at 8008A) 80046: 8F14660 GOSBVL 06641 ; MC: pop TOS (System Binary) into A.A 8004D: 8FB9760 GOSBVL 0679B ; MC: save D0,D1,B,D (uses C,D0), clear carry 80054: CC A=A-1 A ; set-up loop, etc (size-1) 80056: 4C2 GOC 80083 ; exit if null string 80059: 147 C=DAT1 A ; D1: ptr to new str data 8005C: 134 D0=C ; ... 8005F: 169 D0=D0+ 10 ; ... 80062: 174 D1=D1+ 5 ; D0: ptr to last char of orig str data 80065: 147 C=DAT1 A ; ... 80068: C2 C=C+A A ; ... 8006A: C2 C=C+A A ; ... 8006C: 135 D1=C ; ... 8006F: 179 D1=D1+ 10 ; ... 80072: 14F C=DAT1 B ; get character from orig string 80075: 14C DAT0=C B ; put character to new string 80078: 161 D0=D0+ 2 ; next character 8007B: 1C1 D1=D1- 2 ; ... 8007E: CC A=A-1 A ; ... 80080: 51F GONC 80072 ; go if more 80083: 8D34150 GOVLNG 05143 ; MC: restore D,B,D1,D0 (C=D0), clear carry and continue RPL . . . . . . ! End of Code 8008A: 60F9B ; drop level two object 8008F: 0312B ! End Marker 80094: 0312B ! End Marker