Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uflorida!gatech!udel!rochester!pt.cs.cmu.edu!n.sp.cs.cmu.edu!rds From: rds@n.sp.cs.cmu.edu (Robert Sansom) Newsgroups: comp.arch Subject: Re: String lengths Message-ID: <4211@pt.cs.cmu.edu> Date: 7 Feb 89 23:08:55 GMT References: <8882@alice.UUCP> Organization: Carnegie-Mellon University, CS/RI Lines: 32 Cc: dmr@research.att.com In article <8882@alice.UUCP>, dmr@alice.UUCP writes: > Robert Firth justifiably corrects my misstatement about > BCPL strings; they were indeed counted. I evidently edited > my memory. > > Perhaps he or someone else can discuss authoritatively how they > fitted into the language and (to recall the original topic) how string > instructions might help in processing. To quote 'BCPL - the language and its compiler' by Martin Richards and Colin Whitby-Strevens: '... you can use UNPACKSTRING to lay out a string in a vector one character to a word, and PACKSTRING to pack it up again. After unpacking your string, you will discover that the first word contains a count of the number of characters in the sting proper, which starts at the second word.' and: 'Exactly how BCPL strings are stored depends, amongst other things, upon the implementation word size. This dependency is concealed within the string access procedures GETBYTE and PUTBYTE. The call "GETBYTE(S,I)" obtains the Ith byte of the string S. By convention, byte 0 contains the number of characters in the string, which are stored consecutively from byte. The call "PUTBYTE(S,I,C)" sets the Ith byte of the string S to contain the character C.' Robert Sansom (rds@cs.cmu.edu) School of Computer Science Carnegie Mellon University --