With the addition of clone, I started writing some generic routines which might be useful (index,lc,uc,reverse,abs,tr,etc)...and I came across some weirdness:
doing: save S0 restore S1 (since there's no set S1,S0) binds the registers together, so a change to one is a change to both...which doesn't happen on int registers. In addition, I've got a test program which I cannot figure out why it fails...and I believe its related to the above problem. Here's the test code (sorry for the size): set S0,"Hello World" bsr _uc print "UC is: " print S0 print "\n" bsr _lc print "LC is: " print S0 print "\n" end # index - return the position (I0) of a substring (S1) within a string (S0) _index: clones pushi set I0,0 length I1,S1 length I2,S0 $loop: substr S2,S0,I0,I1 eq S1,S2,$done inc I0,1 lt I0,I2,$loop set I0,-1 branch $done $done: save I0 popi pops restore I0 ret # tr - convert the string S0 by replacing chars in S1 with those in S2. _tr: clones pushi length I22,S2 length I21,S1 length I20,S0 set I0,0 substr S22,S2,I0,I22 # no set s,s substr S21,S1,I0,I21 substr S20,S0,I0,I20 set S28,"" # our result string. set I29,0 # zero set I28,1 # one set I27,0 $loop: substr S1,S20,I27,I28 substr S0,S21,I29,I21 bsr _index ne I0,-1,$found concat S28,S1 branch $next $found: substr S1,S22,I0,I28 concat S28,S1 $next: print "building string: " print S28 print ", I27= " print I27 print ", I20= " print I20 print "\n" inc I27,1 lt I27,I20,$loop save S28 popi pops restore S0 ret _lc: clones set S1,"ABCDEFGHIJKLMNOPQRSTUVWXYZ" set S2,"abcdefghijklmnopqrstuvwxyz" bsr _tr save S0 pops restore S0 ret _uc: clones set S2,"ABCDEFGHIJKLMNOPQRSTUVWXYZ" set S1,"abcdefghijklmnopqrstuvwxyz" bsr _tr save S0 pops restore S0 ret Here's what it outputs: building string: H, I27= 0, I20= 11 building string: HE, I27= 1, I20= 11 building string: HEL, I27= 2, I20= 11 building string: HELL, I27= 3, I20= 11 building string: HELLO, I27= 4, I20= 11 building string: HELLO , I27= 5, I20= 11 building string: HELLO W, I27= 6, I20= 11 building string: HELLO WO, I27= 7, I20= 11 building string: HELLO WOR, I27= 8, I20= 11 building string: HELLO WORL, I27= 9, I20= 11 building string: HELLO WORLD, I27= 10, I20= 11 UC is: HELLO WORLD building string: dH, I27= 0, I20= 11 building string: dE, I27= 1, I20= 11 building string: dL, I27= 2, I20= 11 building string: dL, I27= 3, I20= 11 building string: dO, I27= 4, I20= 11 building string: d , I27= 5, I20= 11 building string: dW, I27= 6, I20= 11 building string: dO, I27= 7, I20= 11 building string: dR, I27= 8, I20= 11 building string: dL, I27= 9, I20= 11 building string: dD, I27= 10, I20= 11 LC is: dD S28 is somehow not growing the 2nd time a routine using _tr is called...which leads me to believe that some binding of S28 has occurred. Maybe its a dumb typo. I don't know, and I'm stumped. Anyone have any hints? Brian