| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | movsb |
Hi, Paul. PE> PE> Actually, I've changed my mind about that. I don't think it is PE> PE> possible to reduce the timing of instructions within that loop, PE> PE> without causing an overrun. I was basically moving the testing PE> PE> before the move, and then special case after the loop, but the PE> PE> testing I was doing would destroy the register. PE> PE> HOWEVER, what could be done is if I give you the maximum length PE> PE> as WELL as just the '\n' terminator, then it could be written PE> PE> just as fast. PE> On the assumption that you are only concerned about not overrunning PE> the buffer, but besides that, you don't mind copying an extra PE> byte or three. Yes, I guess for total safety you should specify the routine as copying up to and including any \n, or the supplied maximum output buffer size, whichever comes first. PE> However, on closer reading of the ISO standard, I cannot see Oh, this is an implementation of an ISO-specified routine? I didn't realise that. PE> anything that would allow me to do that. It says that characters PE> stop getting read when the newline character is read. What I PE> would have LIKED them to have said is "The contents of the PE> array after the newline character will be indeterminant". But True, but if its an ISO standard function you'd have to allow for a user who knew that his input line would never exceed say 41 bytes, and provided an output buffer of exactly that size. You'd clobber the subsequent. PE> as it stands at the moment, people can instead be sure that their PE> array will not be clobbered with extra bytes, which means that PE> they can play silly buggers, and, e.g. do an fgets() and get PE> a line of BBBBBBBBBBBBBBBBBBBB and then an fgets and get a line PE> of AAAAAAA, and then clobber the '\n' with a C, knowing that PE> they will now get a AAAAAACBBBBBBBBBBBB, e.g. Yeah, users do strange things. :-) PE> What this means is that two halfword *stores* instead of a single PE> fullword store is unavoidable in the main loop. Yes it is, in the *main* loop. You'd modify my Test 10 to do all those tests before the "mov [di],eax" and handle the special cases of 1, 2 or 3 bytes as special cases after the main loop. PE> That also means that there is no use in having the length available. I'd still prefer to have such a routine specified as I suggested above, but then I'm a programmer who believes in protecting users from themselves. :-) It might even have a useful application other than the buffer space assignment problem - say you want to display the first n characters of each line of a text file. Regards, FIM. * * Can taglines have sequels? Hmmm..... @EOT: ---* Origin: Pedants Inc. (3:711/934.24) SEEN-BY: 690/718 711/809 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.