Shouldn't the loop be incrementing R15? -- Shmuel (Seymour J.) Metz http://mason.gmu.edu/~smetz3 עַם יִשְׂרָאֵל חַי נֵ֣צַח יִשְׂרָאֵ֔ל לֹ֥א יְשַׁקֵּ֖ר
________________________________________ From: IBM Mainframe Discussion List <[email protected]> on behalf of Kirk Wolf <[email protected]> Sent: Tuesday, October 22, 2024 12:51 PM To: [email protected] Subject: Re: Bounded string move? Caution: This email did not originate from George Mason’s mail system. Do not click links or open attachments unless you recognize the sender and know the content is safe. 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://secure-web.cisco.com/1KfUYH9qUGfnT8P-nUV2mvFGPnLfZCbrLOT3dLUXEf-X3DkEaYz5zU3FUO9hWW536JxkFwmaShHqsoWnEv1lLdg5mQ313r0Bj1hY4C79252qngE5gtFSKiuPQcgL2rcrLB_jZC1WpFmtDTiOWoaSjDeQ72Ei7DKqzCZFSSUc0kF7v_z1t9QoM42LpEJkEE14qXyonEDkzXnHLrZsjYsjELGsqDJqWrMVWvigxkSC0ujTcKkHuOzdsnpwU_YidokqKZmCAw1fZ6skZgO84mfLV-6gohH-82x15xSnloAhFQ0bOqOY1tgrwRVwnmwsVZaRoSTskI6ZQ-MR1DrLmELAoa114CwvOr20Jgel48WQDPYwErFiXB0lB69mafhuzcbsKHVDfmNlcKr-Jua5FGSvV0A/https%3A%2F%2Fcoztoolkit.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 ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to [email protected] with the message: INFO IBM-MAIN
