One could reverse engineer the XLC/C++ library module for strtok() using your 
local assembler debugger . . . just to see how it's done, mind you.

Peter

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]] On 
Behalf Of Charles Mills
Sent: Thursday, June 14, 2018 3:41 PM
To: [email protected]
Subject: Re: Count Words?

Not the answer to your question but I don't think "TRT performs badly."

It is just that people sometimes assume that because it is a single
instruction in the Pop it must execute roughly as fast as many simple
instructions.

I think it is fast for what it does. Picture "writing TRT in assembler" --
implementing it as a subroutine as if the opcode magically vanished.

Now picture a version of that only somewhat faster because millicode has
some special tricks up its sleeve -- that's TRT.

If I had to count words in a string in assembler I would probably just use a
loop of CLI's and such -- unless there was some incredible need for
optimization. The big cost these days is getting the data into cache, and
that is all the same whether CLI, TRT, SRST, etc. TRT is perhaps a little
worse because you need to get two things into cache, the string and the
table. I might look first at SRST.

Charles

-----Original Message-----
From: IBM Mainframe Assembler List [mailto:[email protected]]
On Behalf Of Paul Gilmartin
Sent: Thursday, June 14, 2018 12:18 PM
To: [email protected]
Subject: Count Words?

Is there a modern, clever, efficient way to count words in a string where:
o A separator is <TAB> or <SP> (+ others ad lib.)
o A word is a maximal non-empty sequence of consecutive non-separator
characters.
(Whew!)

Do TRT and CLI remain the best primitives?  (TRT is reported to
perform badly, perhaps model-dependent.)

Yah, I know: "The compiler knows best!"

--

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

Reply via email to