This is a good question. Considering that "strcpy" (MVST) is generally frowned upon, is there an instruction that is more like "strncpy" ? Apparently not, although this would seem like a very beneficial instruction - i.e. MVSTX with Rx being the limit.
If you look at POP for MVST, you can see this: "Bit positions 32-55 of general register 0 are reserved for possible future extensions and must contain all zeros; otherwise, a specification exception is recognized." Hmm. For a limit? I would assume that the implementers of strncpy in the C optimizing compiler have chosen the best performing instructions, so I looked at a compiler listing of some of my code that used strncpy and here's what they do. @16L690 DS 0H ICM r0,b'0001',(char)(r9,0) STC r0,(char)(r15,0) JE @16L691 LA r9,(char)(,r9,1) BRCT r6,@16L690 J @16L692 @16L691 DS 0H ... It's always important to remember that one the new exotic instructions may not perform as well as a loop of the old stuff once it's translated to microcode. Kirk Wolf Dovetailed Technologies https://coztoolkit.com On Mon, Oct 21, 2024, at 6:28 PM, Seymour J Metz wrote: > If I know the lengths of an input string and the length of a buffer, I can > specify a pad character and copy it with MVCL. If I know that it is > delimited by, e.g., a blank, I can use MVST but I run the risk of a buffer > overrun. Is there a quick way to copy a delimited string without overrunning > either the input or output buffer and without resorting to TRT? > > -- > Shmuel (Seymour J.) Metz > http://mason.gmu.edu/~smetz3 > עַם יִשְׂרָאֵל חַי > נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to [email protected] with the message: INFO IBM-MAIN > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
