On Tue, Oct 22, 2024, at 3:02 PM, Schmitt, Michael wrote:
> 
> So either you need to scan the string first to find its length and then move 
> for that length, or scan and move one byte at a time like the code generated 
> by the C compiler.
> 

If you are coding in Assembler, that's correct.  Write a macro?  In C (or some 
HLL), you use strncpy and don't worry about it.

Be careful If you are making a performance statement about the cost of a loop.  
Instructions are translated to microcode for execution.  You might have a 
single instruction that does something but the microcode might scan and move 
one byte at a time anyway.   In theory, translation heuristics might even 
recognize the "strncpy" loop of instructions and generate microcode that uses 
"strncpy" function in the underlying engine.


Kirk Wolf
Dovetailed Technologies



----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to