On Mon, 2001-10-15 at 21:12, Dan Sugalski wrote: > On 15 Oct 2001, Brian Wheeler wrote: > > > 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. > > Right. Save on a string register pushes the pointer to the string > structure in the register onto the stack. The same thing happens with > PMCs, or will when they're implemented. > > The assumption is that, when you push a register onto the stack, you'll > then stomp on the contents of the register. (Rather than what the register > points to...) Otherwise a push would need to create a copy of the string > structure and a copy of the string contents. > > Dan
Ok, that's fair... With that in mind I've implemented "set Sx,Sy" which does a string copy. This is what I was after in the first place, but then noticed the unexpected behavior of save/restore of S registers. It makes sense now :) Brian