Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!think.com!paperboy!hsdndev!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.arch Subject: Re: Computers for users not programmers Message-ID: <14653@lanl.gov> Date: 14 Feb 91 16:18:38 GMT References: <3198@crdos1.crd.ge.COM> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 32 From article <3198@crdos1.crd.ge.COM>, by davidsen@crdos1.crd.ge.COM (Wm E Davidsen Jr): > [... vector character stuff ...] > Did you code your stuff directly in assembler? It has been done in Fortran and could be done in C. The only difference using a high-level language makes is to increase the required set-up time for the operations. That's why I used assembler. Setup time can further be reduced by not-vectorizing and working with the characters one word (8 characters) at a time - this would be the method of choice for, say, compilers: where the length of the strings in use is fairly short on average (tokens, etc.). Actually, it _does_ require some non-portable things. You need to treat the character string as numbers (word-size integers are best - with the characters still packed). For all the operations except the character 'move' operation, you must assume that the character set is 7-bit ASCII and that each character is the low order bits of an 8-bit field (you need the eighth bit to catch carries from arithmetic on the characters). Finally, the characters need to be packed in the word in a sequential way: if loading the string "abcd" into your 32-bit word produces a register with "badc" in it, the algorithm won't work (fortunately, most machines that do such strange things have character instructions and don't need this algorithm anyway). To be sure, if your machine has character instructions, you wouldn't want to use this technique. But not all machines have character instructions - the extra hardware/instruction-set overhead would make them uncompetitive. It is a mistake to believe that the only recourse on such machines is a brute-force unpacking of all the chars, processing them one at a time, and packing them back up. J. Giles